prune_fam {simfam} | R Documentation |
Remove non-ancestors of a set of individuals from pedigree
Description
This function accepts an input pedigree and a list of individuals of interest, and returns the subset of the pedigree including only the individuals of interest and their direct ancestors. This is useful in simulations, to avoid modeling/drawing genotypes of individuals without descendants in the last generation.
Usage
prune_fam(fam, ids, missing_vals = c("", 0))
Arguments
fam |
The pedigree data.frame, in plink FAM format.
Only columns |
ids |
The list of individuals of interest, whose ancestors we want to keep.
All must be present in |
missing_vals |
The list of ID values treated as missing.
|
Value
The filtered FAM table with non-ancestors of ids
excluded.
IDs that are NA
-equivalent (see missing_vals
) will be mapped to NA
.
Examples
# construct a family with three founders, but one "bob" has no descendants
library(tibble)
fam <- tibble(
id = c('mom', 'dad', 'bob', 'child'),
pat = c( NA, NA, NA, 'dad'),
mat = c( NA, NA, NA, 'mom')
)
# only want 'child' and its ancestors
ids <- 'child'
fam2 <- prune_fam( fam, ids )
# the filtered pedigree has "bob" removed:
fam2