论文
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
本日的推文我们重复一下论文中的Figure2e
关于平滑曲线,之前的推文有过先容,可以参考
我们看下这个论文里是用什么代码来实现的
示例数据集部分截图
读取数据
top_genus <- read.delim("data/20220616/top_genus.txt", header=T, row.names=1, sep="\t", stringsAsFactors = FALSE, check.names = FALSE)赋予因子程度
top_genus$Genus<-factor( top_genus$Genus, levels=c("Bacillus","Cronobacter", "Unclassified_Enterobacterales", "Klebsiella"," antoea", " seudomonas","Rosenbergiella"), labels = c("Bacillus","Cronobacter", "Unclassified_Enterobacterales", "Klebsiella"," antoea", " seudomonas","Rosenbergiella"))预备配色
phy.cols <- c("#85BA8F", "#A3C8DC", "#349839","#EA5D2D", "#EABB77","#F09594","#2072A8")普通折线图的代码
library(ggplot2)p=ggplot(data=top_genus, aes(x=Compartment,y=RA, group=Genus,colour=Genus))+ geom_point(size=3)+ labs(x="Compartments", y="Relative abundance (%)")+ geom_line()+ scale_x_discrete(limits=c("RS","RE","VE","SE","LE"," ","BS"))+ scale_colour_manual(values=phy.cols) p
论文中提供的代码没有效BS的数据,以是会有告诫信息
平滑曲线他用到的是 ggalt包中的 geom_xspline函数
library(ggalt)p2<-ggplot(data=top_genus,aes(x=Compartment,y=RA, group=Genus,colour=Genus))+ geom_point(size=3)+ labs(x="Compartments", y="Relative abundance (%)")+ geom_xspline(spline_shape = -0.5)+ scale_x_discrete(limits=c("RS","RE","VE","SE","LE"," "))+ scale_colour_manual(values=phy.cols) p2拼图
mytheme = theme_bw() + theme(axis.text.x = element_text(size = 8),axis.text.y = element_text(size = 8))+ theme(axis.title.y= element_text(size=12))+theme(axis.title.x = element_text(size = 12))+ theme(legend.title=element_text(size=5),legend.text=element_text(size=5))+theme(legend.position = "bottom")library(patchwork)p+mytheme + p2 + mytheme + plot_layout(guides = "collect")+ plot_annotation(theme = theme(legend.position = "bottom"))
示例数据和代码可以到论文中去下载,大概直接在公众号配景留言20220616获取
欢迎各人关注我的公众号
小明的数据分析条记本
小明的数据分析条记本 公众号 重要分享:1、R语言和python做数据分析和数据可视化的简朴小例子;2、园艺植物相干转录组学、基因组学、群体遗传学文献阅读条记;3、生物信息学入门学习资料及本身的学习条记!
|