R:KEGG通路气泡图(两组数据联合分析)
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)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)