library(clusterProfiler)
setwd("D:/Desktop/")
a=read.table("universeGeneIDs.txt",header = F,sep = "\t")
gene=as.character(a[,1])
ego<-enrichGO(gene = gene,'org.Hs.eg.db',ont = 'BP',pvalueCutoff = 0.01,readable = T)
write.table(ego,"go.txt",sep = "\t",quote = F,row.names = F)
barplot(ego,showCategory = 15,title = "EnrichmentGO")
dotplot(ego,title="EnrichmentGO_dot")
library(ggThemeAssist)
p<-dotplot(ego,title="EnrichmentGO_dot")
ggThemeAssistGadget(p)
ekk<-enrichKEGG(gene = gene,organism = "hsa",pAdjustMethod = "BH",pvalueCutoff = 0.01)
write.table(ekk,"kegg.txt",sep = "\t",quote = F,row.names = F)
barplot(ekk,showCategory = 15,title = "EnrichmentKEGG")
dotplot(ekk,title="EnrichmentKEGG_dot")
此外,还能做GSEA富集
gmtfile<- system.file("extdata", "c5.cc.v5.0.entrez.gmt", package="clusterProfiler")#选择GSEA数据库用的,http://software.broadinstitute.org/gsea/msigdb/collections.jsp,前面俩行大概就是来选择GSEA的数据库用的,c5.cc.v5.0.entrez.gmt这里他事例用的是GO的cc数据库,这个可以调整的,参考GSEA的网站来选择
egmt <- enricher(gene, TERM2GENE=c5)
write.table(egmt,"egmt.txt",sep = "\t",quote = F)
另外,多个基因集时(eg,WGCNA得到的不同module的基因集),用compareCluster。
1.基因ID转换
2.代码
3.画图
网友评论