Last data update: 2014.03.03

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

Compute the posterior probabilities for P(m|n0) for a given prior P(m)

Description

Compute a matrix of posterior probabilties P(m|n0) where m ranges from 1 to code{m.max}, and n0 is 0,..,code{m.max}. This is done by evaluating P(m|n0)=P(n0|m)P(m)/P(n), where P(n0|m) is evaluated by pNoA.

Usage

pContrib.locus(prob=NULL, m.prior=NULL, m.max=8, pnoa.locus=NULL, theta=0)

Arguments

prob

Vectors with allele probabilities for the specific 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.locus

A named vector of locus specific probabilities P(N(m)=n), n=1,..,2m.

theta

The coancestery coefficient

Details

Computes a matric of P(m|n0) values for a specific locus.

Value

Returns a matrix [P(m|n0)] for m=1,...,m.max and n0=1,...,2m.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="."))
  ## Compute P(m|n0) for m=1,...,5 and n0=1,...10 for the first locus:
  pContrib.locus(prob=freqs[[1]],m.max=5)

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.locus.Rd_%03d_medium.png", width=480, height=480)
> ### Name: pContrib.locus
> ### Title: Compute the posterior probabilities for P(m|n0) for a given
> ###   prior P(m)
> ### Aliases: pContrib.locus
> 
> ### ** 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="."))
>   ## Compute P(m|n0) for m=1,...,5 and n0=1,...10 for the first locus:
>   pContrib.locus(prob=freqs[[1]],m.max=5)
    P(m|n0)
   m
n0           1          2           3           4            5
  1  0.9558086 0.04119117 0.002784636 0.000201019 0.0000146259
  2  0.8694246 0.11371443 0.014641252 0.001959463 0.0002602608
  3  0.0000000 0.73445437 0.205843066 0.048840399 0.0108621626
  4  0.0000000 0.40320945 0.371254570 0.165126705 0.0604092734
  5  0.0000000 0.00000000 0.385848004 0.378883737 0.2352682583
  6  0.0000000 0.00000000 0.125947204 0.407121018 0.4669317780
  7  0.0000000 0.00000000 0.000000000 0.284639221 0.7153607793
  8  0.0000000 0.00000000 0.000000000 0.108604857 0.8913951425
  9  0.0000000 0.00000000 0.000000000 0.000000000 1.0000000000
  10 0.0000000 0.00000000 0.000000000 0.000000000 1.0000000000
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>