模式物種進(jìn)行GO富集分析繪圖
爾云間? 一個(gè)專門做科研的團(tuán)隊(duì)
原創(chuàng) 小果 生信果?

今天通過clusterProfiler包對(duì)模式物種進(jìn)行GO富集分析,并繪制富集分析圖片,今天以小鼠數(shù)據(jù)為例進(jìn)行,代碼如下:
安裝所需的R包
Install.packages(“BiocManager”)
Install.packages(“clusterProfiler”)
Install.packages(“ggplot2”)
Install.packages(“tidyverse”)
導(dǎo)入所需的R包
library(clusterProfiler)
library(ggplot2)
差異分析結(jié)果文件

富集分析
#讀取小鼠基因差異分析結(jié)果數(shù)據(jù)
gsym.fc <- read.csv("easy_input_Mm.csv", as.is = T)
#獲取基因名與ENTREZID的對(duì)應(yīng)關(guān)系。
gsym.id <- bitr(gsym.fc$SYMBOL, #基因名
??????????????? fromType = "SYMBOL", #從gene symbol
??????????????? toType = "ENTREZID", #提取ENTREZ ID
??????????????? OrgDb = "org.Mm.eg.db") #相應(yīng)物種
idvec <- gsym.id$ENTREZID
names(idvec) <- gsym.id$SYMBOL
gsym.fc$ENTREZID <- idvec[gsym.fc$SYMBOL]
write.csv(gsym.fc[,c(3,2)], "very_easy_input_Mm.csv", quote = F, row.names = F)
id.fc <- read.csv("very_easy_input_Mm.csv", as.is = T)
#enrich進(jìn)行富集分析
ego <- enrichGO(gene = id.fc$ENTREZID,
??????????????? #小鼠用這行
??????????????? OrgDb = org.Mm.eg.db,
??????????????? #人類用這行
??????????????? #OrgDb = org.Hs.eg.db,
??????????????? #非模式生物用這行,例如玉米
??????????????? #OrgDb = maize.db,
??????????????? ont = "BP", #或MF或CC
??????????????? pAdjustMethod = "BH",
??????????????? #pvalueCutoff? = 0.001,
??????????????? qvalueCutoff? = 0.01)
write.csv(ego,"enrichGO_output.csv",quote = F)
egox <- setReadable(ego, 'org.Mm.eg.db', #物種
??????????????????? 'ENTREZID')
geneList <- id.fc$log2fc
names(geneList)<- gsym.fc$SYMBOL
#繪制圈圖,通過circular來確定。
cnetplot(egox,
???????? foldChange = geneList,
???????? #foldChange = NULL, #不展示倍數(shù)
???????? circular = TRUE,
???????? #node_label = FALSE, #如果太多,就不要顯示基因名了
???????? showCategory = 4, #顯示富集的term數(shù)量,默認(rèn)5
???????? colorEdge = TRUE)
ggsave("clusterProfiler_circle.pdf", width = 8, height = 5)
cnetplot(egox,
???????? foldChange = geneList,
???????? #foldChange = NULL, #不展示倍數(shù)
???????? #circular = TRUE,
???????? #node_label = FALSE, #不顯示基因名
???????? showCategory = 4, #顯示的富集term數(shù)量,默認(rèn)5
???????? colorEdge = TRUE)
ggsave("clusterProfiler_not_circle.pdf", width = 8, height = 5)


Go富集分析結(jié)果

今天的分享又結(jié)束了,歡迎大家找小果溝通、交流哦~
推薦閱讀