get_descendants.RdThis function recursively identifies all descendants (children, grandchildren, etc.) of a given individual in the pedigree.
get_descendants(id, ped, generations = NULL)Integer. The ID of the individual whose descendants are to be found.
A data frame containing pedigree information with columns:
id: Unique identifier for each individual
mother: ID of the individual's mother (0 for unknown/founder)
father: ID of the individual's father (0 for unknown/founder)
Integer or NULL. Number of generations to descend. NULL means all generations.
A list containing:
descendants: Integer vector containing the IDs of all descendants
generation_map: Named integer vector mapping descendant IDs to their generation relative to the input individual (1 for children, 2 for grandchildren, etc.)
ped <- simulate_pedigree(n_founders = 5, n_generations = 3)
#> Warning: No offspring produced in generation 2
desc <- get_descendants(1, ped)
# Get only children and grandchildren
desc2 <- get_descendants(1, ped, generations = 2)