Description Usage Arguments Value Examples
View source: R/find_ancestors_and_relatives_of_samples.R
This is a fairly general function that can be applied to pedigree output from any simulation program. It calls a function written in C++ to do all the recursive pedigree searching.
1 |
P |
a tibble that gives the pedigree. It must have the columns |
S |
a vector of the IDs of the sampled individuals. Obviously, all members of S must appear in P. |
n |
number of generations back from the sampled individuals to return in each individual's ancestor vector. 0 = self, 1 = back to and including the parents, 2 = back to and including the grandparents, and so on. |
A tibble with three columns:
sample_id
: the ID names of the sampled individuals
ancestors
: a list column. Each element is a vector of the ids of the ancestors of the
sampled individual in the 2^(n+1) - 1 positions. The first is the sampled individual, the second
is pa, third is ma, fourth is pa's pa, fifth is pa's ma, sixth is ma's pa, and so forth.
relatives
: a list column. Each element is a vector of the ids of the individuals that are sampled relatives
within the n generations. The first element is the sampled individual itself, and the remaining
ones are all the relatives of that individual whom were also sampled.
1 2 3 4 5 6 | # get some input variables
P <- three_pops_with_mig_slurped_results$pedigree
S <- three_pops_with_mig_slurped_results$samples$ID
n <- 2
result <- find_ancestors_and_relatives_of_samples(P, S, n)
result
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.