From b024b857986d816ec34ef0d450d1e35fceff0342 Mon Sep 17 00:00:00 2001 From: depristo Date: Wed, 22 Dec 2010 20:16:41 +0000 Subject: [PATCH] misc. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4899 348d0f76-0448-11de-a6fe-93d51630548a --- R/titvFPEst.R | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/R/titvFPEst.R b/R/titvFPEst.R index fbf13ccd7..d963565bc 100755 --- a/R/titvFPEst.R +++ b/R/titvFPEst.R @@ -122,4 +122,18 @@ plotQsamples <- function(depths, Qs, Qmax) { } legend("topleft", paste("Q", Qs), fill=cols) -} \ No newline at end of file +} + +pCallHetGivenDepth <- function(depth, nallelesToCall) { + depths = 0:(2*depth) + pNoAllelesToCall = apply(as.matrix(depths),1,function(d) sum(dbinom(0:nallelesToCall,d,0.5))) + dpois(depths,depth)*(1-pNoAllelesToCall) +} + +pCallHets <- function(depth, nallelesToCall) { + sum(pCallHetGivenDepth(depth,nallelesToCall)) +} + +pCallHetMultiSample <- function(depth, nallelesToCall, nsamples) { + 1-(1-pCallHets(depth,nallelesToCall))^nsamples +}