probGen2expGen {PhenotypeSimulator} | R Documentation |
Compute expected genotypes from genotype probabilities.
Description
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).
Usage
probGen2expGen(probGeno)
Arguments
probGeno |
Vector [numeric] with genotype probabilites; has to be a multiple of 3. |
Value
Numeric vector of length [length(probGeno)/3] with the expected genotype value per individual.
Examples
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)
[Package PhenotypeSimulator version 0.3.4 Index]