Description Usage Arguments Value Examples
View source: R/utilityFunctions.R
Convert genotypes encoded as triplets of probablities (p(AA), p(Aa), p(aa)) into their expected genotype frequencies by 0*p(AA) + p(Aa) + 2p(aa).
1 | probGen2expGen(probGeno)
|
probGeno |
Vector [numeric] with genotype probabilites; has to be a multiple of 3. |
Numeric vector of length [length(probGeno)/3] with the expected genotype value per individual.
1 2 3 4 5 6 7 | nrSamples <- 10
# Construct genotype probability vector (usually from external input)
# First, assign zero probabilty of AA, Aa and aa for all samples
genotype_prob <- rep(0, 3*nrSamples)
# Second, for each sample draw one of 0,1,2 (corresponding to AA, Aa and aa)
genotype_prob[seq(1, nrSamples*3, 3) + sample(0:2, 10, replace=TRUE)] <- 1
genotype_exp <- probGen2expGen(genotype_prob)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.