```{r setup, include=FALSE} knitr::opts_chunk$set(echo=TRUE, fig.align="center") ``` #### Statistics for Laboratory Scientists ( 140.615 ) ## Multiple Comparisons - Advanced For this part, you need to install the 'qvalue' package from Bioconductor. Uncomment the first two lines for the installation. Note this can take a wee bit. ```{r} # install.packages("BiocManager") # BiocManager::install("qvalue") library(qvalue) ``` #### Null results ```{r} # 100,000 independent p-values under the null set.seed(1) n <- 1e5 p <- runif(n) hist(p,breaks=101,col="lightgrey") hist(p,breaks=101,col="lightgrey",prob=T) abline(h=1,lwd=2,col="red") ``` #### Example 1: enrichment for low p-values ```{r} # 100,000 independent p-values under the null set.seed(1) p <- runif(n) # 5,000 p-values under some alternatives ns <- 5000 psmall <- rbeta(ns,1,10) hist(psmall,breaks=101,col="lightgrey",xlim=c(0,1)) # replace 5,000 null p-values at random entries wh <- sample(1:n,size=ns) p[wh] <- psmall hist(p,breaks=101,col="lightgrey",prob=T) abline(h=1,lwd=2,col="red") # bonferroni cut-off cut.b <- 0.05/n cut.b min(p) min(p)*n which(p