Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bootstrap method for enrichment analysis
# http://ygc.name/2012/04/29/bootstrap-for-enrichment-analysis/
goboot <- cmpfun(function(goid,
sampleSize,
nboot=1000) {
ratio <- rep(0, nboot)
allgene <- unique(mappedkeys(org.Hs.egGO))
allgeneInCategory <- unique(get(goid, org.Hs.egGO2ALLEGS))
for (i in 1:nboot) {
gene.sample <- sample(allgene, sampleSize)
k <- sum(gene.sample %in% allgeneInCategory)
ratio[i] <- k/sampleSize
}
return(ratio)
})
ratio <- goboot(goid="GO:0042221", sampleSize=100, nboot=1000)
## suppose a sample (100 genes) which have 35 genes annotated by GO:0042221
## the p value is:
pnorm(35/100, mean=mean(ratio), sd=sd(ratio), lower.tail=F)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.