DAVID数据制作KEGG的气泡图和柱状图
rm(list=ls())
library(ggplot2)
library(Cairo)
setwd("C:\\Users\\wyccccc\\Desktop\\DAVIDKEGG")
GO_BP <- read.table("DAVIDKEGG.tsv",header = T,sep="\t")
png_path="./figure/GO_BP.png"
CairoPNG(png_path, width = 12, height = 7, units='in', dpi=600)
ggplot(data=GO_BP)+
geom_bar(aes(x=reorder(Term,Count),y=Count, fill=-log10(PValue)), stat='identity') +
coord_flip() +
scale_fill_gradient(expression(-log["10"](P.value)),low="red", high = "blue") +
xlab("") +
ylab("Gene count") +
scale_y_continuous(expand=c(0, 0))+
theme(
axis.text.x=element_text(color="black",size=rel(1.5)),
axis.text.y=element_text(color="black", size=rel(1.6)),
axis.title.x = element_text(color="black", size=rel(1.6)),
legend.text=element_text(color="black",size=rel(1.0)),
legend.title = element_text(color="black",size=rel(1.1))
# legend.position=c(0,1),legend.justification=c(-1,0)
# legend.position="top",
)
dev.off()
成功
另:气泡图的代码
rm(list=ls())
library(ggplot2)
library(Cairo)
setwd("/home/ ")
GO_BP <- read.table("./enh_statistics/A549_GO_BP_spe.tsv",header = T,sep="\t")
png_path="./figure/GO_BP.png"
CairoPNG(png_path, width = 12, height = 7, units='in', dpi=600)
ggplot(data=GO_BP)+
geom_bar(aes(x=reorder(Term,Count),y=Count, fill=-log10(PValue)), stat='identity') +
coord_flip() +
scale_fill_gradient(expression(-log["10"](P.value)),low="red", high = "blue") +
xlab("") +
ylab("Gene count") +
scale_y_continuous(expand=c(0, 0))+
theme(
axis.text.x=element_text(color="black",size=rel(1.5)),
axis.text.y=element_text(color="black", size=rel(1.6)),
axis.title.x = element_text(color="black", size=rel(1.6)),
legend.text=element_text(color="black",size=rel(1.0)),
legend.title = element_text(color="black",size=rel(1.1))
# legend.position=c(0,1),legend.justification=c(-1,0)
# legend.position="top",
)
dev.off()