Computes the probability of a genotypes (0, 1, or 2) given the allele frequencies in the population and the assumption that it is non-contaminated (DNA of only one individual is represented) or is contaminated (DNA of two randomly sampled individuals is present)
A vector of allele frequencies for loci ordered as in gt giving the freqency of the 1 allele in the population. Note that gt could be much longer than af. For example, if gt is a vector where say the first L elements are the L loci at individual 1 and the next L are the loci at individual 2 and so on. In that case, af will recycle as it should.
Vector of genotypes. They should be integers, 0, 1, or 2 (or NA), where the values record the number of copies of the "1" allele in the diploid genotype. This can be omitted, in which case the just the genotype probability matrices are returned
Returns a list of four named components:
Matrix with three rows (corresponding the genotypes 0, 1, and 2) and number of columns equal to length of af. Given probabilities of the three possible genotypes for each SNP under the hypothesis of contamination.
Same as above but for no contamination.
Vector of genotype probabilities under the assumption of contamination
Vector of genotype probabilities under the assumption of no contamination
1 2 3 4 5 6 7 8 9 10
# call it with just allele frequencies to get the genotype probability for two SNPs. # note that af can have names likelihood(af = c(SNP1 = .1, SNP2 = .2)) # call it with af and also genotypes you want to evaluate probabilities for likelihood(af = c(SNP1 = .1, SNP2 = .2), c(0,0,0,1,1,1,1,1,1,2)) # for illustration, get the contam probs and turn them into a matrix # of values where the individuals are columns and the rows are SNPs matrix(likelihood(af = c(SNP1 = .1, SNP2 = .2), c(0,0,0,1,1,1,1,1,1,2))$contam, nrow = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.