x<-x x_go=x[,1:5] xbp=x_go[grep("BP",x_go$Category),] xcc=x_go[grep("CC",x_go$Category),] xmf=x_go[grep("MF",x_go$Category),] xkegg=x_go[grep("KEGG",x_go$Category),] xbp$Term=gsub(".*\\~","",xbp$Term)#Biological Process xcc$Term=gsub(".*\\~","",xcc$Term)#Cell Component xmf$Term=gsub(".*\\~","",xmf$Term)#Molecular Function xkegg$Term=gsub(".*\\:","",xkegg$Term)#KEGG pathway #加载 ggplot2 包## library(ggplot2) make_GO_bubble<-function(go_data,term_name){ GO_DATA=go_data[order(go_data$Count,decreasing = T),] GO_DATA=head(GO_DATA,10) ##前10组或前20组## p = ggplot(GO_DATA,aes(X.,Term)) bubble=p+ geom_point(aes(size=Count,color=-log10(PValue))) bubble =bubble+ scale_colour_gradient(low="green",high="red") pr=bubble + theme_test(base_size = 16,base_rect_size = 1) pr=pr+labs(x="Rich factor",y=term_name,title="Enrichment of DEGs") return(pr) } make_GO_bubble(xbp,term_name="Biological Process")#HEIGHT 550 make_GO_bubble(xcc,term_name = "Cell Component") make_GO_bubble(xmf,term_name = "Molecular Function") make_GO_bubble(xkegg,term_name = "KEGG pathway")