This helper function recursively identifies all ancestors (parents, grandparents, etc.) of a given individual in the pedigree.

get_ancestors(id, ped)

Arguments

id

Integer. The ID of the individual whose ancestors are to be found.

ped

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)

Value

An integer vector containing the IDs of all ancestors of the individual. Returns an empty integer vector if the individual has no ancestors or is not found in the pedigree.