Last data update: 2014.03.03

R: Compute the posterior probabilities for P(m|n0) for a given...
pContribR Documentation

Compute the posterior probabilities for P(m|n0) for a given prior P(m) and observed vector n0 of locus counts

Description

where m ranges from 1 to code{m.max} and n0 is the observed locus counts.

Usage

pContrib(n0, probs=NULL, m.prior=rep(1/m.max,m.max), m.max=8, pnoa=NULL, theta=0)

Arguments

n0

Vector of observed allele counts - same length as the number of loci.

probs

List of vectors with allele probabilities for each locus

m.prior

A vector with prior probabilities (summing to 1), where the length of m.prior determines the plausible range of m

m.max

Derived from the length of m.prior, and if m.prior=NULL a uniform prior is speficied by m.max: m.prior = rep(1/m.max,m.max).

pnoa

A named list of locus specific probabilities. Output from pNoA with locuswise=TRUE.

theta

The coancestery coefficient

Details

Computes a vector P(m|n0) evaluated over the plausible range 1,...,m.max.

Value

Returns a vector P(m|n0) for m=1,...,m.max

Author(s)

Torben Tvedebrink

References

T Tvedebrink (2013). 'On the exact distribution of the number of alleles in DNA mixtures', International Journal of Legal Medicine: (under review).

Examples

  ## Simulate some allele frequencies:
  freqs <-  structure(replicate(10, { g = rgamma(n=10,scale=4,shape=3); g/sum(g)},
              simplify=FALSE),.Names=paste("locus",1:10,sep="."))
  m <- 2
  n0 <- unlist(lapply(freqs, function(x){
      length(unique(sample(length(x),size=2*m,replace=TRUE,prob=x)))}
      ))
  ## Compute P(m|n0) for m=1,...,4 and the sampled n0
  pContrib(n0=n0,probs=freqs,m.max=4)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(DNAtools)
Loading required package: Rsolnp
Loading required package: multicool
Loading required package: Rcpp
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DNAtools/pContrib.Rd_%03d_medium.png", width=480, height=480)
> ### Name: pContrib
> ### Title: Compute the posterior probabilities for P(m|n0) for a given
> ###   prior P(m) and observed vector n0 of locus counts
> ### Aliases: pContrib
> 
> ### ** Examples
> 
>   ## Simulate some allele frequencies:
>   freqs <-  structure(replicate(10, { g = rgamma(n=10,scale=4,shape=3); g/sum(g)},
+               simplify=FALSE),.Names=paste("locus",1:10,sep="."))
>   m <- 2
>   n0 <- unlist(lapply(freqs, function(x){
+       length(unique(sample(length(x),size=2*m,replace=TRUE,prob=x)))}
+       ))
>   ## Compute P(m|n0) for m=1,...,4 and the sampled n0
>   pContrib(n0=n0,probs=freqs,m.max=4)
   P(m=1|n0)    P(m=2|n0)    P(m=3|n0)    P(m=4|n0) 
0.000000e+00 9.999948e-01 5.238303e-06 1.600036e-12 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>