Add unilineal parental ancestor chains to a pedigree
Source:R/addParentalChain.R
addParentalChain.RdAdds an ordered unilineal parental ancestor chain for each individual in a pedigree. The chain can follow either paternal links only or maternal links only.
Usage
addParentalChain(
ped,
personID = "personID",
dadID = "dadID",
momID = "momID",
chain_col = "chain",
chain_string_col = "chain_string",
collapse = "|",
component = c("dadID", "momID"),
traversal_direction = "in"
)Arguments
- ped
A pedigree data frame.
- personID
Character string giving the name of the column containing individual IDs.
- dadID
Character string giving the name of the column containing paternal IDs.
- momID
Character string giving the name of the column containing maternal IDs.
- chain_col
Character string giving the name of the output list-column that will contain the ordered parental ancestor chain for each individual.
- chain_string_col
Character string giving the name of the output character column that will contain the collapsed parental ancestor chain.
- collapse
Character string used to collapse ancestor IDs into `chain_string_col`.
- component
Character string specifying which parental component to follow. Must be either `"dadID"` for paternal chains or `"momID"` for maternal chains.
- traversal_direction
Character giving the mode of transversion: defaults to "in". If set to out, will procedure a list of descendants.
Value
A data frame with two added columns:
- `chain_col`
A list-column containing the ordered unilineal parental ancestor chain for each individual.
- `chain_string_col`
A character column containing the collapsed ancestor chain, or `NA_character_` when no ancestors are found in the selected component.
Details
For `component = "dadID"`, the chain follows: father, paternal grandfather, paternal great-grandfather, and so on.
For `component = "momID"`, the chain follows: mother, maternal grandmother, maternal great-grandmother, and so on.
The function constructs a parent-specific version of the pedigree, converts it to a graph using [ped2graph()], identifies reachable ancestors for each individual, orders those ancestors by graph distance from the focal individual, and adds both a list-column representation and a collapsed string representation to the original pedigree.
All pedigree IDs used to construct the parent-specific graph are coerced to character. Individuals that are not represented as graph vertices receive an empty chain in `chain_col` and `NA_character_` in `chain_string_col`.
The ordering of each chain is based on graph distance from the focal individual, where distance 1 is the selected parent, distance 2 is the selected parent's same-component parent, and so forth.