热点新闻
跟着Nature Communications学作图:R语言ggtern包画三元相图(Ternary plots )
2023-07-13 04:00  浏览:279  搜索引擎搜索“促展会”
温馨提示:为防找不到此信息,请务必收藏信息以备急用! 联系我时,请说明是在促展会看到的信息,谢谢。
展会发布 展会网站大全 报名观展合作 软文发布

论文

A highly conserved core bacterial microbiota with nitrogen-fixation capacity inhabits the xylem sap in maize plants

https://www.nature.com/articles/s41467-022-31113-w

本地pdf s41467-022-31113-w.pdf

数据代码链接

https://github.com/PlantNutrition/Liyu

今天的推文我们重复一下论文中的Figure2f




image.png

这个图怎们看,然后表达的是什么含义,我暂时还想不明白,论文中给的图注是

Ternary plots of OTUs in xylem sap across three fertilisation treatments. Size of each point represents relative abundance of OTU. Position is determined by the contribution of three fertilisation treatments to the total relative abundance, proximity to that vertex indicates enrichment of that OTU in that fertilisation treatment. Colours of circles correspond to different genera. Grey circles indicate OTUs with no significant differences in abundance.

作图数据部分截图




image.png

ggtern 这个R包是我第一次使用,首先需要安装,运行代码install.packages("ggtern")

读取数据集

plot_data <- read.table("data/20220612/Tern_data.txt", header=T, row.names= 1, sep="\t", comment.char = "")

作图代码

library(ggtern) p <- ggtern(data=plot_data, aes(x=CK, y=NPK, z=NPKM)) + geom_mask() + geom_point(aes(size=size, color=Genus),alpha=0.8) + scale_size(range = c(0, 10)) + scale_color_manual(values = c('#E31A1C','#228B22','#1F78B4', '#FDB462', '#8B658B', '#4876FF', '#00BFFF', '#EE82EE','#8B8682','#CDC9C9'), limits = c('Klebsiella','Pseudomonas','Enterobacteriaceae_unclassified','Rosenbergiella','Oxalobacteraceae_unclassified','Sphingobacterium','Lactococcus','Erwinia','Others','NotSig')) + guides(size="none") +theme_bw() + theme(axis.text=element_blank(), axis.ticks=element_blank()) p

论文中的代码出图




image.png

调整图例的位置,可以用ggplot2中调整图例的方法

p+ theme(legend.position = "bottom")+ guides(color=guide_legend(nrow = 3, override.aes = list(size = 5), title.position = "top"))


image.png

试了一下和其他ggplot2的图进行组合,patchwork没有成功,找找有没有其他办法可以实现组合图

示例数据和代码可以在公众号后台留言20220612获取

欢迎大家关注我的公众号

小明的数据分析笔记本

小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!

发布人:0d31****    IP:125.64.72.***     举报/删稿
展会推荐
让朕来说2句
评论
收藏
点赞
转发