跟著Nature Communications學(xué)作圖:R語言ggtern包畫三元相圖(Ternary plots )

論文

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

數(shù)據(jù)代碼鏈接

https://github.com/PlantNutrition/Liyu

今天的推文我們重復(fù)一下論文中的Figure2f

image.png

這個(gè)圖怎們看,然后表達(dá)的是什么含義,我暫時(shí)還想不明白,論文中給的圖注是

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.

作圖數(shù)據(jù)部分截圖

image.png

ggtern 這個(gè)R包是我第一次使用,首先需要安裝,運(yùn)行代碼install.packages("ggtern")

讀取數(shù)據(jù)集

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

調(diào)整圖例的位置,可以用ggplot2中調(diào)整圖例的方法

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

試了一下和其他ggplot2的圖進(jìn)行組合,patchwork沒有成功,找找有沒有其他辦法可以實(shí)現(xiàn)組合圖

示例數(shù)據(jù)和代碼可以在公眾號后臺留言20220612獲取

歡迎大家關(guān)注我的公眾號

小明的數(shù)據(jù)分析筆記本

小明的數(shù)據(jù)分析筆記本 公眾號 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容