?用DAVID或者clusterprofiler 做基因富集的常常需要挑選一下想展示的通路或者排一下通路的順序帘睦,而且竣付,clusterprofiler展示的順序有時候跟輸入的順序不一樣古胆。因此逸绎,用ggplot可以方便對各種來源的富集結(jié)果實現(xiàn)氣泡圖棺牧。
如用clusterprofiler做富集
#GeneSymbol為輸入的基因集
toENTREZID = bitr(GeneSymbol,fromType = "SYMBOL",toType = "ENTREZID",OrgDb = "org.Mm.eg.db")
goBP = enrichGO(OrgDb="org.Mm.eg.db",gene = as.vector(toENTREZID$ENTREZID),ont = "BP", pvalueCutoff = 0.05, readable= TRUE)
dotplot(goBP,showCategory=10)+scale_color_gradient(low = "#132B43", high = "#56B1F7")
head(goBP@result)
image
image
我們再用ggplot畫氣泡圖采蚀,結(jié)果看起來和clusterprofiler畫的差不多榆鼠,不一樣的地方在于clusterproliler的x軸默認(rèn)的gene ratio,而ggplot我們用的是count妆够,這個可以自己選擇,再就是ggplot我們可以用level調(diào)節(jié)go term的順序家妆,如最上面兩個紅框里相同基因數(shù)但是pvalue不同的go term 在ggplot里面符合上面表中的順序伤极,而clusterprofiler是相反的
#goBP為clusterprofiler的富集結(jié)果,取前10個來畫圖当编。
goinput<-goBP@result[1:10,]
head(goinput)
#使畫出go term的順序與輸入的一致
goinput$Description<-factor(goinput$Description,levels = rev(goinput$Description))
#reorder使縱軸按照go term 和count排序
?goinput$Description<-factor(goinput$Description,levels = rev(goinput$Description))
ggplot(goinput,aes(x = Count, y =reorder(Description,Count)))+
geom_point(aes(size=Count,color=p.adjust))+
scale_colour_gradient(low="#132B43",high="#56B1F7")+
labs(
color=expression(p.adjust),
size=" Count Number",
x="Gene Count"
)+
theme_bw()+
theme(
axis.text.y = element_text(size = rel(1.8)),
axis.title.x = element_text(size=rel(1.8)),
axis.title.y = element_blank()
)+ scale_size(range=c(5, 10))
?
image