fam_ancestors: Construct an ancestors-only pedigree for one person...

View source: R/fam_ancestors.R

fam_ancestorsR Documentation

Construct an ancestors-only pedigree for one person G-generations deep

Description

Creates an idealized pedigree listing all ancestors of one individual starting from G generations ago, without inbreeding (a binary tree). IDs are automatically generated strings indicating generation and individual number within generation. Useful for simple simulations of individuals with explicit ancestors.

Usage

fam_ancestors(G)

Arguments

G

The desired number of generations. G=1 returns a trivial pedigree with a single individual; G=2 an individual and its two parents; G=3 an individual, its parents and grandparents, etc.

Value

A list with two named elements:

  • fam: a tibble describing the pedigree, with the following columns

    • id: The ID of each individual, a string in the format "g-i" joining with a dash the generation number ("g", numbered backward in time) and the individual number within the generation ("i").

    • pat: The paternal ID. For individual "g-i" parent is (g+1)"-"(2*i-1), except for last generation it is NA (their parents are missing).

    • mat: The maternal ID. For individual "g-i" parent is (g+1)"-"(2*i), except for last generation it is NA (their parents are missing).

    • sex: 1 (male) for all odd-numbered individuals, 2 (female) for even-numbered individuals, consistent with pedigree structure. Side-effect is first-generation individual ("1-1") is always male (edit afterwards as desired).

  • ids: A list containing vectors of IDs separated by generation, but here starting from the last generation (highest "g"), to be consistent with output of sim_pedigree() and the expected input of all *_last_gen functions.

See Also

sim_pedigree() to simulate a random pedigree with a given number of generations, generation sizes, and other parameters.

Examples

# construct the 8-generation ancestor tree of one individual:
data <- fam_ancestors( 8 )
# this is the pedigree
fam <- data$fam
# and this is the handy list of IDs by discrete generation,
# used by `*_last_gen` functions to reduce memory usage
ids <- data$ids


simfam documentation built on Jan. 10, 2023, 1:06 a.m.