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數(shù)據(jù)庫(kù)用的,http://software.broadinstitute.org/gsea/msigdb/collections.jsp,前面?zhèn)z行大概就是來(lái)選擇GSEA的數(shù)據(jù)庫(kù)用的,c5.cc.v5.0.entrez.gmt這里他事例用的是GO的cc數(shù)據(jù)庫(kù),這個(gè)可以調(diào)整的,參考GSEA的網(wǎng)站來(lái)選擇
egmt <- enricher(gene, TERM2GENE=c5)
write.table(egmt,"egmt.txt",sep = "\t",quote = F)

另外,多個(gè)基因集時(shí)(eg,WGCNA得到的不同module的基因集),用compareCluster。


1.基因ID轉(zhuǎn)換

2.代碼

3.畫圖

