Lecture3_One-hundred-software-in-bioinformatics005_WeGO
Jimmy(jmzeng1314@outlook.com)
library(GOstats)
library(org.Hs.eg.db)
tmp=toTable(org.Hs.egGO)
new_tmp=unlist(tapply(tmp[,2],as.factor(tmp[,1]),function(x) paste(x,collapse =" "),simplify =F))
EG2GO=tapply(tmp[,2],as.factor(tmp[,1]),function(x) x)
GO2EG=tapply(tmp[,1],as.factor(tmp[,2]),function(x) x)
all_go_gene=names(EG2GO);
diff_gene=all_go_gene[unique(floor(runif(1000,0,18000)) + 1)]
diff_gene_go=new_tmp[diff_gene]
write.table(diff_gene_go,"diff_gene_go",quote =
F,sep="\t",col.names = F)
GOES = c('BP','CC', 'MF');
annotationPKG='org.Hs.eg.db'
for (ontology in GOES) {
# perform enrichment test. locusid is DEGs
hyperG.params = new("GOHyperGParams", geneIds=diff_gene, universeGeneIds=NULL, annotation=annotationPKG,
ontology=ontology, pvalueCutoff=1, conditional = FALSE, testDirection = "over")
hyperG.results = hyperGTest(hyperG.params);
outHTMLname=paste("GO_",ontology,".enrichment.html",sep="")
htmlReport(hyperG.results, file=outHTMLname, summary.args=list("htmlLinks"=TRUE))
}
useful links : http://www.bio-info-trainee.com/?p=359
http://wego.genomics.org.cn/cgi-bin/wego/index.pl