rm(list = ls())
library(ggplot2)
setwd("C:\\Users\\Administrator\\Desktop\\Pei\\Trans_Kegg")
data1 <- read.table("1.txt", header = TRUE, sep = "\t")
data2 <- read.table("2.txt", header = TRUE, sep = "\t")
# 添加文件来源列,区分两个数据
data1$Type <- "meta"
data2$Type <- "gene"
# 合并两个数据集
data <- rbind(data1, data2)
# 绘制图形
p <- ggplot(data, aes(x = Ratio, y = Term)) +
geom_point(aes(size = Count, color = Pvalue, shape = Type)) +
scale_shape_manual(values = c("meta" = 16, "gene" = 17)) + # 1.txt 使用圆形(16), 2.txt 使用三角形(17)
scale_colour_gradient(low="#7CFC00", high="#FF4500") +
labs(color = "P value", size = "Count", x = "Ratio", y = "Term") +
ggtitle("Top15 of pathway enrichment ") + # 添加题目
theme(axis.text.x = element_text(color = "black", size = 10),
axis.text.y = element_text(color = "black", size = 10),
plot.title = element_text(hjust = 0.5, size = 14, face = "bold")) + # 设置题目居中并加粗
theme_bw() +
theme(panel.grid.major = element_blank(), # 去掉大网格线
panel.grid.minor = element_blank()) # 去掉小网格线
# 展示图形
print(p)
# 保存图形
ggsave("output.png", plot = p, width = 7, height = 6, dpi = 1200)
标签:KEGG,通路,setwd,Users,两组,气泡 From: https://www.cnblogs.com/wzbzk/p/18427392