大部分的生物學(xué)高通量數(shù)據(jù)處理后都是得到基因集,不管是上調(diào)下調(diào)表達(dá)基因集,還是共表達(dá)的模塊基因集,都是需要注釋到生物學(xué)功能數(shù)據(jù)庫來看基因集的意義,最常見的是GO/KEGG數(shù)據(jù)庫啦,還有很多其它在MsigDB的,比如reactome和biocarta數(shù)據(jù)庫等等。 這樣分析起來就很麻煩,尤其是GO數(shù)據(jù)庫,還有 BP,CC,MF的區(qū)別,這個時候推薦使用Y叔的神器,使用library(ggplot2) library(stringr) library(clusterProfiler) # 我這里演示的是brown_down_gene,是WGCNA的一個模塊,基因集 # 因?yàn)楸磉_(dá)矩陣是symbol,所以需要轉(zhuǎn)為ENTREZID,才能走clusterProfiler的函數(shù)。 gene.df <- bitr(brown_down_gene$symbol, fromType="SYMBOL", toType="ENTREZID", OrgDb = "org.Hs.eg.db") go <- enrichGO(gene = gene.df$ENTREZID, OrgDb = "org.Hs.eg.db", ont="all") barplot(go, split="ONTOLOGY")+ facet_grid(ONTOLOGY~., scale="free") 會得到如下所示的圖,當(dāng)然,理解起來需要耗費(fèi)一點(diǎn)功夫,如果你是第一次看到的話!不僅僅是要理解GO數(shù)據(jù)庫,以及BP,MF,CC的分類系統(tǒng),超幾何分布檢驗(yàn),不同的閾值過濾,篩選指標(biāo)等等。 因?yàn)樯厦娴拇a并沒有修改默認(rèn)的統(tǒng)計(jì)學(xué)指標(biāo)篩選參數(shù),如果你的基因確實(shí)沒有規(guī)則,有可能拿不到結(jié)果哦!這個時候可以設(shè)置:pvalueCutoff = 0.9, qvalueCutoff =0.9 甚至為1,來不做篩選。而且基因集的大小也是被限制了。如果你想分開計(jì)算上下調(diào)基因的GO數(shù)據(jù)庫注釋而且還想保留富集分析結(jié)果到csv文件,代碼如下:library(ggplot2) library(stringr) library(clusterProfiler) # 通過前面的差異分析,我們拿到了 gene_up 和 gene_down 這兩個基因集 # 后面的分析,只需要 gene_up 和 gene_down 這兩個變量即可 go_up <- enrichGO(gene_up, OrgDb = "org.Hs.eg.db", ont="all", pvalueCutoff = 0.9, qvalueCutoff =0.9) go_up=DOSE::setReadable(go_up, OrgDb='org.Hs.eg.db',keyType='ENTREZID') write.csv(go_up@result,paste0(pro,'_go_down.up.csv')) barplot(go_up, split="ONTOLOGY",font.size =10)+ facet_grid(ONTOLOGY~., scale="free") + scale_x_discrete(labels=function(x) str_wrap(x, width=50))+ ggsave(paste0(pro,'gene_up_GO_all_barplot.png'))
go_down <- enrichGO(gene_down, OrgDb = "org.Hs.eg.db", ont="all", pvalueCutoff = 0.9, qvalueCutoff =0.9) go_down=DOSE::setReadable(go_down, OrgDb='org.Hs.eg.db',keyType='ENTREZID') write.csv(go_down@result,paste0(pro,'_go_down.up.csv')) barplot(go_down, split="ONTOLOGY",font.size =10)+ facet_grid(ONTOLOGY~., scale="free") + scale_x_discrete(labels=function(x) str_wrap(x, width=50))+ ggsave(paste0(pro,'gene_down_GO_all_barplot.png')) 其實(shí)就是兩個獨(dú)立的基因集,獨(dú)立的走enrichGO流程啦!有趣的是,如果你是多組基因,不僅僅是上下調(diào),甚至可以走compareCluster流程,不過Y叔的這個函數(shù)總是喜歡在線獲取KEGG數(shù)據(jù)庫的最新信息,這一點(diǎn)對很多人來說,考驗(yàn)網(wǎng)速:# 這里需要制作一個 DEG 的數(shù)據(jù)框,其中有兩列ENTREZID,是基因id,和new是分組信息 xx.formula <- compareCluster(ENTREZID~new, data=DEG, fun='enrichKEGG') dotplot(xx.formula, x=~GeneRatio) + facet_grid(~new)
如果是多組基因集走GO數(shù)據(jù)庫富集如下,構(gòu)建一個數(shù)據(jù)框,list_de_gene_clusters, 含有兩列信息:list_de_gene_clusters <- split(de_gene_clusters$ENTREZID, de_gene_clusters$cluster)
# Run full GO enrichment test formula_res <- compareCluster( ENTREZID~cluster, data=de_gene_clusters, fun="enrichGO", OrgDb="org.Mm.eg.db", ont = "BP", pAdjustMethod = "BH", pvalueCutoff = 0.01, qvalueCutoff = 0.05 )
# Run GO enrichment test and merge terms # that are close to each other to remove result redundancy lineage1_ego <- simplify( formula_res, cutoff=0.5, by="p.adjust", select_fun=min )
感興趣的可以把這個結(jié)果跟3個出名的網(wǎng)頁工具進(jìn)行比較- https://amp.pharm./Enrichr/
- https://biit.cs./gprofiler
另外,強(qiáng)推Y叔clusterProfiler的一些可視化方法好幾個都是以前沒有介紹過的,有趣的是我準(zhǔn)備瀏覽這些可視化函數(shù)的幫助文檔的時候,看到了這樣的話:重點(diǎn)來了,Y叔特意為其包寫了一本書來介紹其用法。Please go to https://yulab-smu./clusterProfiler-book/ for the full vignette.
|