跟着Nature Genetics学作图:R语言ggpairs散点图一次性展示很多个主成分/拼图
2023-02-19 12:27:43 时间
论文
Plasma proteome analyses in individuals of European and African ancestry identify cis-pQTLs and models for proteome-wide association studies
https://www.nature.com/articles/s41588-022-01051-w
本地pdf s41588-022-01051-w.pdf
代码链接
https://zenodo.org/record/6332981#.YroV0nZBzic
https://github.com/Jingning-Zhang/PlasmaProtein/tree/v1.2
今天的推文重复一下论文中的Extended Data Fig. 10
image.png
部分示例数据截图
image.png
这个是已经做好了主成分分析,现在只是可视化展示结果
读取数据
pc2<-read.delim(file = "data/20220627/ExtendedDataFig10.txt",
header = TRUE,
sep="\t")
head(pc2)
作图代码
library(ggplot2)
library(GGally)
pc.pr <- ggpairs(pc2[,3:7],
aes(color = pc2$V1),
upper = list(continuous = "points"),
diag = list(continuous = "blank")) +
scale_color_manual(values=c("#238b45","#2171b5")) +
theme(panel.background = element_blank(),
legend.position = "bottom",
axis.text = element_text(size = 6),
axis.title = element_text(size = 7)) +
scale_x_continuous(breaks = c(-0.01,0,0.01),
labels = c(-0.01,0,0.01)) +
scale_y_continuous(breaks = c(-0.01,0,0.01),
labels = c(-0.01,0,0.01))
pc.pr
image.png
拼图代码
pc.pr+
scale_color_manual(values = c("#f47720","#459943")) -> p2
library(patchwork)
pdf(file="Rplot05.pdf",
width = 9.4,
height = 4)
wrap_elements(ggmatrix_gtable(pc.pr))+
wrap_elements(ggmatrix_gtable(p2))
dev.off()
image.png
新知识点:ggpairs()
函数作图后的拼图代码wrap_elements(ggmatrix_gtable(pc.pr))+ wrap_elements(ggmatrix_gtable(p2))
参考链接
https://github.com/thomasp85/patchwork/issues/100
示例数据和代码可以自己到论文中获取
相关文章
- 什么是web框架?
- HTTP真的很简单
- 十分钟搞懂什么是CGI
- HTTP状态码大全(转自wiki)
- 什么是真正的程序员?
- 小printf的故事(未完待续)
- [编辑器]走上atom之路1
- MassTransit 知多少 | 基于StateMachine实现Saga编排式分布式事务
- MassTransit 知多少 | 基于MassTransit Courier实现Saga 编排式分布式事务
- MassTransit 知多少 | .NET 分布式应用框架
- Dapr 知多少 | 分布式应用运行时
- Istio 知多少 | 下一代微服务的守护者
- eShopOnContainers 知多少[12]:Envoy gateways
- 诊断日志知多少 | DiagnosticSource 在.NET上的应用
- Orleans 知多少 | Orleans 中文文档上线
- .NET Core + K8S + Apollo 玩转配置中心
- .NET Core + K8S + Loki 玩转日志聚合
- 五分钟快速搭建Serverless免费邮件服务
- eShopOnContainers 知多少[11]:服务间通信之gRPC
- IO 模型知多少 | 代码篇