View source: R/admix_last_gen.R
admix_last_gen | R Documentation |
A wrapper around the more general admix_fam()
, specialized to save memory when only the last generation is desired (admix_fam()
returns admixture for the entire pedigree in a single matrix).
This function assumes that generations are non-overlapping (met by the output of sim_pedigree()
), in which case each generation g
can be drawn from generation g-1
data only.
That way, only two consecutive generations need be in memory at any given time.
The partitioning of individuals into generations is given by the ids
parameter (again matches the output of sim_pedigree()
).
admix_last_gen(admix, fam, ids, missing_vals = c("", 0))
admix |
The admixture proportions matrix of the founders (individuals along rows and ancestries along columns).
This matrix must have row names that identify each founder (matching codes in |
fam |
The pedigree data.frame, in plink FAM format.
Only columns |
ids |
A list containing vectors of IDs for each generation.
All these IDs must be present in |
missing_vals |
The list of ID values treated as missing.
|
The admixture proportions matrix of the last generation (the intersection of ids[ length(ids) ]
and fam$id
).
The rows of this matrix are last-generation individuals in the order that they appear in fam$id
.
Plink FAM format reference: https://www.cog-genomics.org/plink/1.9/formats#fam
# A small pedigree, two parents and two children. # A minimal fam table with the three required columns. # Note "mother" and "father" have missing parent IDs, while children do not library(tibble) fam <- tibble( id = c('father', 'mother', 'child', 'sib'), pat = c(NA, NA, 'father', 'father'), mat = c(NA, NA, 'mother', 'mother') ) # need an `ids` list separating the generations ids <- list( c('father', 'mother'), c('child', 'sib') ) # admixture proportions of the parents admix <- rbind( c(0.3, 0.3, 0.4), c(0.5, 0.25, 0.25) ) # Name the parents with same codes as in `fam` # (order can be different) rownames( admix ) <- c('mother', 'father') # name ancestries too colnames( admix ) <- c('African', 'European', 'Asian') # calculate the admixture matrix of the children admix2 <- admix_last_gen( admix, fam, ids ) admix2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.