# likelihood: Probability of genotype given contamination and... In eriqande/SNPcontam: Detecting contaminated samples from SNP genotypes

## Description

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)

## Usage

 `1` ```likelihood(af, gt = integer(0)) ```

## Arguments

 `af` 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. `gt` 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

## Value

Returns a list of four named components:

contam_prob

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.

clean_prob

Same as above but for no contamination.

contam

Vector of genotype probabilities under the assumption of contamination

clean

Vector of genotype probabilities under the assumption of no contamination

## Examples

 ``` 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) ```

eriqande/SNPcontam documentation built on May 13, 2017, 8:20 p.m.