# Read in the FDR sample size library library(FDRsampsize) ################### Power for Cox regression analysis ########################## # Specify an effect size vector logHR<-c(rep(log(2),1000), # 1000 genes with hazard ratio = 2 rep(0,9000)) # 9000 genes with no association with survival # Compute no. of events and store results in object called res1 res.cox<-fdr.sampsize(fdr=0.1, # want 10% FDR ave.pow=0.8, # want 80% average power eff.size=logHR, # specified above pow.func=power.cox, # Defined in the library v=1) # Variance of covariate, another argument of power.cox # Show Results res.cox$OK # Did sample size achieve desired power and FDR? res.cox$n # Computed sample size res.cox$alpha # Anticipated p-value cut-off in final analysis res.cox$fdr.hat # Anticipated FDR estimate at that p-value cut-off res.cox$act.fdr # Anticipated actual FDR at that p-value cut-off res.cox$ave.pow # Anticipated average power at that p-value cut-off res.cox$act.pi # Actual value of pi0 given effect size estimates res.cox$pi.hat # Anticipated estimate of pi0 in final analysis # Compute power of FDR control at 0.1 given 40 events fdr.power(fdr=.1,n=8,eff.size=logHR,pow.func=power.cox,v=1) ################## Power for two-sample t-test ######################## # Specify an effect size vector delta<-c(rep(1,100), # 100 genes with effect size = 1 rep(0,900)) # 900 genes with no effect res.2t<-fdr.sampsize(fdr=0.1, # Want 10% FDR ave.pow=0.5, # Want 50% Average Power eff.size=delta, # specified above pow.func=power.twosampt, # Defined in the library sigma=1) # Effect sizes are divided by standard deviation res.2t$OK # Did sample size achieve desired power and FDR? res.2t$n # Computed sample size res.2t$alpha # Anticipated p-value cut-off in final analysis res.2t$fdr.hat # Anticipated FDR estimate at that p-value cut-off res.2t$act.fdr # Anticipated actual FDR at that p-value cut-off res.2t$ave.pow # Anticipated average power at that p-value cut-off res.2t$act.pi # Actual value of pi0 given effect size estimates res.2t$pi.hat # Anticipated estimate of pi0 in final analysis # Compute power of FDR control with 20 per group fdr.power(fdr=0.1,n=20,eff.size=delta,pow.func=power.twosampt,sigma=1) ################### Power for one-way ANOVA ########################## # Specify an effect size vector theta<-c(rep(1,100), # 100 genes with theta = 1 rep(0,900)) # 900 genes with no effect res.1way<-fdr.sampsize(fdr=0.1, # want 10% FDR ave.pow=0.5, # want 50% Average Power eff.size=theta, # Specified above pow.func=power.oneway, # Defined in the library k=3) # No. of groups to compare, argument of power.oneway res.1way$OK # Did sample size achieve desired power and FDR? res.1way$n # Computed sample size res.1way$alpha # Anticipated p-value cut-off in final analysis res.1way$fdr.hat # Anticipated FDR estimate at that p-value cut-off res.1way$act.fdr # Anticipated actual FDR at that p-value cut-off res.1way$ave.pow # Anticipated average power at that p-value cut-off res.1way$act.pi # Actual value of pi0 given effect size estimates res.1way$pi.hat # Anticipated estimate of pi0 in final analysis # Compute power of FDR control with 10 per group fdr.power(fdr=0.1,n=10,eff.size=theta,pow.func=power.oneway,k=3) ################## Power for one sample t-test ########################## # Specify an effect size vector delta<-c(rep(1,100), # 100 genes with delta = 1 rep(0,900)) # 900 genes with no effect res.1t<-fdr.sampsize(fdr=0.1, # Want 10% FDR ave.pow=0.5, # Want 50% Average Power eff.size=delta, # Specified Above pow.func=power.onesampt, # Defined in the library sigma=1) # standard deviation res.1t$OK # Did sample size achieve desired power and FDR? res.1t$n # Computed sample size res.1t$alpha # Anticipated p-value cut-off in final analysis res.1t$fdr.hat # Anticipated FDR estimate at that p-value cut-off res.1t$act.fdr # Anticipated actual FDR at that p-value cut-off res.1t$ave.pow # Anticipated average power at that p-value cut-off res.1t$act.pi # Actual value of pi0 given effect size estimates res.1t$pi.hat # Anticipated estimate of pi0 in final analysis # Compute power of FDR control with sample size 20 fdr.power(.1,20,delta,power.onesampt,sigma=1) #################### Power for correlation analysis ###################### # Specify an effect size vector rho<-c(rep(0.3,100), # 100 genes with correlation = 0.3 rep(0,900)) # 900 genes with no effect res.corr<-fdr.sampsize(fdr=0.1, # Want 10% FDR ave.pow=0.5, # Want 50% Average Power eff.size=rho, # Correlation vector, specified above pow.func=power.tcorr) # Defined in library res.corr$OK # Did sample size achieve desired power and FDR? res.corr$n # Computed sample size res.corr$alpha # Anticipated p-value cut-off in final analysis res.corr$fdr.hat # Anticipated FDR estimate at that p-value cut-off res.corr$act.fdr # Anticipated actual FDR at that p-value cut-off res.corr$ave.pow # Anticipated average power at that p-value cut-off res.corr$act.pi # Actual value of pi0 given effect size estimates res.corr$pi.hat # Anticipated estimate of pi0 in final analysis # Compute power of FDR control with sample size 50 fdr.power(fdr=0.1,n=50,eff.size=rho,pow.func=power.tcorr) #################### Power for the rank-sum test ############################# p<-c(rep(0.9,1000), # 500 genes with Pr(X>Y) = 0.7 rep(0.1,1000), # 500 genes with Pr(X>Y) = 0.3 rep(0.5,48000)) # 9000 genes with Pr(X>Y) = 0.5 (Null Hypothesis) rs.res<-fdr.sampsize(fdr=0.1,ave.pow=0.4,eff.size=p,pow.func=power.ranksum,null.effect=0.5) rs.res$OK # Did sample size achieve desired power and FDR? rs.res$n # Computed sample size rs.res$alpha # Anticipated p-value cut-off in final analysis rs.res$fdr.hat # Anticipated FDR estimate at that p-value cut-off rs.res$act.fdr # Anticipated actual FDR at that p-value cut-off rs.res$ave.pow # Anticipated average power at that p-value cut-off rs.res$act.pi # Actual value of pi0 given effect size estimates rs.res$pi.hat # Anticipated estimate of pi0 in final analysis fdr.power(fdr=0.1, n=20, eff.size=p, pow.func=power.ranksum, null.effect=0.5) # For this test, p = 0.5 corresponds to the null hypothesis ################### Power for the sign test ################################ p<-c(rep(0.7,500), # 500 genes with Pr(X>Y) = 0.7 rep(0.1,500), # 500 genes with Pr(X>Y) = 0.3 rep(0.5,9000)) # 9000 genes with Pr(X>Y) = 0.5 (Null Hypothesis) sgn.res<-fdr.sampsize(fdr=0.1,ave.pow=0.8,eff.size=p,pow.func=power.ranksum,null.effect=0.5) sgn.res$OK # Did sample size achieve desired power and FDR? sgn.res$n # Computed sample size sgn.res$alpha # Anticipated p-value cut-off in final analysis sgn.res$fdr.hat # Anticipated FDR estimate at that p-value cut-off sgn.res$act.fdr # Anticipated actual FDR at that p-value cut-off sgn.res$ave.pow # Anticipated average power at that p-value cut-off sgn.res$act.pi # Actual value of pi0 given effect size estimates sgn.res$pi.hat # Anticipated estimate of pi0 in final analysis fdr.power(fdr=0.1, n=20, eff.size=p, pow.func=power.signtest, null.effect=0.5) # For this test, p = 0.5 corresponds to the null hypothesis