> plotGO <- read.csv(file = "clipboard",header = T,sep = "\t")
> head(plotGO)
上圖中Sig_gene_number表示該條目下顯著性基因的個數(shù)肠骆,B_gene_number表示該條目下共有幾個基因(背景基因)廷痘。geneRatio就是Sig_gene_number除以B_gene_number诗良。
GO_term1 <- c("Biological Process","Cellular Component")? ?# 設(shè)置分面時,會用到,這是我想要在分面的標(biāo)題上展示出來的
names(GO_term1) <- c("biological_process","cellular_component")? ?# 這是數(shù)據(jù)中的內(nèi)容断箫,默認(rèn)會作為分面的標(biāo)題
ggplot(data = plotGO)+
? geom_point(mapping = aes(geneRatio,y = reorder(GO_Term,Sig_gene_number),size = Sig_gene_number,color = pvalue))+
? scale_color_gradient(low = "#FF0000",high = "#0000FF")+? ? ? ? ??# 調(diào)整主函數(shù)中color的顏色
? labs(color = "P-value",size = "Sig gene number",y = "GO term")+????????????# 調(diào)整圖例的名稱
? theme(panel.background = element_blank(),
? ? ? ? panel.grid.major.y = element_line(colour = "grey",linetype = 2),
? ? ? ? axis.line = element_line(colour = "black",size = rel(2)),
? ? ? ? axis.title = element_text(size = rel(1.2)),
? ? ? ? axis.text = element_text(size = rel(1.2)),
? ? ? ? axis.text.y = element_text(angle = 30,hjust = 1),? ? ? ??#調(diào)整縱坐標(biāo)文字的角度
? ? ? ? axis.ticks = element_line(size = rel(1.5)),
? ? ? ? strip.background = element_rect(fill = "white",color = "red",size = rel(1.2)),
? ? ? ? strip.text = element_text(size = rel(1.2)))+
? facet_wrap(facets = "GO_function",scales = "free_y",nrow = 3,strip.position = "left",labeller = labeller(GO_function = GO_term1))
#分面函數(shù)默终,參數(shù)facets表示以哪個因素為基準(zhǔn)進(jìn)行分面,參數(shù)scales表示調(diào)整哪個坐標(biāo)軸的刻度來適應(yīng)分面后的圖形(默認(rèn)為固定)文搂,參數(shù)strip.position表示將分面的標(biāo)題放在上下左右那個位置适刀,參數(shù)labeller可以修改分面的標(biāo)題(需要另外設(shè)置,上文中已提到如何設(shè)置)煤蹭,其他更詳細(xì)的調(diào)整可以使用theme函數(shù)(上面用到了strip.background和strip.text)
最終畫出來的圖片展示: