Skip to content

Commit

Permalink
Change total mutation count calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ctokheim committed May 29, 2016
1 parent 677c9b5 commit 7cba23b
Showing 1 changed file with 42 additions and 36 deletions.
78 changes: 42 additions & 36 deletions R/ratioMetric.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,27 @@ ratiometric.binom.power <- function(p, N, mu,
for(i in N){
# step one, find the # of mutations where
# it is expected to occur at least 90% of the time
j <- 1
while(j){
prob <- pbinom(j-1, round(Leff*i), muEffect)
if(prob >= .1){
mutEffect <- j
break
}
j <- j+1
}
j <- 1
while(j){
prob <- pbinom(j-1, round((1-nonsil.frac)*1/nonsil.frac*Leff*i), mu)
if(prob >= .1){
mutEffect <- mutEffect + j
break
}
j <- j+1
}
#j <- 1
#while(j){
#prob <- pbinom(j-1, round(Leff*i), muEffect)
#if(prob >= .1){
#mutEffect <- j
#break
#}
#j <- j+1
#}
#j <- 1
#while(j){
#prob <- pbinom(j-1, round((1-nonsil.frac)*1/nonsil.frac*Leff*i), mu)
#if(prob >= .1){
#mutEffect <- mutEffect + j
#break
#}
#j <- j+1
#}
totRiskBases = 1/nonsil.frac*Leff*i
nonsilRiskBases = Leff*i
mutEffect <- ceiling(nonsilRiskBases*muEffect + (totRiskBases-nonsilRiskBases)*mu)

# step two, find critical threshold
j <- 1
Expand Down Expand Up @@ -109,24 +112,27 @@ ratiometric.bbd.power <- function(my.alpha, my.beta,
for(i in N){
# step one, find the # of mutations where
# it is expected to occur at least 90% of the time
j <- 1
while(j){
prob <- pbinom(j-1, round(Leff*i), muEffect)
if(prob >= .1){
mutEffect <- j
break
}
j <- j+1
}
j <- 1
while(j){
prob <- pbinom(j-1, round((1-nonsil.frac)*1/nonsil.frac*Leff*i), mu)
if(prob >= .1){
mutEffect <- mutEffect + j
break
}
j <- j+1
}
#j <- 1
#while(j){
#prob <- pbinom(j-1, round(Leff*i), muEffect)
#if(prob >= .1){
#mutEffect <- j
#break
#}
#j <- j+1
#}
#j <- 1
#while(j){
#prob <- pbinom(j-1, round((1-nonsil.frac)*1/nonsil.frac*Leff*i), mu)
#if(prob >= .1){
#mutEffect <- mutEffect + j
#break
#}
#j <- j+1
#}
totRiskBases = 1/nonsil.frac*Leff*i
nonsilRiskBases = Leff*i
mutEffect <- ceiling(nonsilRiskBases*muEffect + (totRiskBases-nonsilRiskBases)*mu)

# step two, find critical threshold
j <- 1
Expand Down

0 comments on commit 7cba23b

Please sign in to comment.