git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4899 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-12-22 20:16:41 +00:00
parent 5265f943b0
commit b024b85798
1 changed files with 15 additions and 1 deletions

View File

@ -122,4 +122,18 @@ plotQsamples <- function(depths, Qs, Qmax) {
}
legend("topleft", paste("Q", Qs), fill=cols)
}
}
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
}