文献名称: Blood metabolome predicts gut microbiome α-diversity in humans
文献译名:血液代谢组学预测人类肠道菌群α-多样性
Nature Biotechnology: volume 37, pages1217–1228(2019)
- 文献链接:https://nature.com/articles/s41587-019-0233-9
- 原图链接: https://www.nature.com/articles/s41587-019-0233-9/figures/1
1.数据准备与读取:
library(readxl)
DF<-as.data.frame(read_xlsx(file.choose()))
head(DF)
2.作图与修饰:
library(ggplot2)
p1 <- ggplot(data = DF, aes(x = DF$`mShannon diversity`, y = DF$`Observed Shannon diversity`)) + geom_point()
p1
p3<-p1+geom_smooth(method = "lm", se=FALSE, color="red", formula = y ~ x)
p3
p4<-p3+ theme_bw()
p4
p5<-p4+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),panel.background = element_blank(), axis.line = element_line(colour = "black"))
p5
p6<-p5+ theme(panel.border = element_blank())
p6
p7<-p6+ggtitle("a") + xlab("mShannon diversity") + ylab("Observed Shannon diversity")
p7
-
添加图面上的文字注释:
-
备注:平方的标注为 label=expression(R^{2})
p8<-p7+annotate(geom="text", x=2.361, y=5.4, label= "Out-of-sample ")+annotate(geom="text", x=2.734, y=5.4, label=expression(R^{2}))+annotate(geom="text", x=2.93, y=5.4, label= "= 0.45") +annotate(geom="text", x=2.5,y=5.1, label= " Pearson’s r = 0.68")+annotate(geom="text", x=2.461, y=4.7, label= "P = 3.21 × ")+annotate(geom="text", x=2.74, y=4.754, label=expression(10^{-56}))
p8
p9<-p8+scale_x_continuous( breaks = seq(2,5.5,by=0.5))+scale_y_continuous( breaks = seq(2,5.5,by=0.5) )
p9
3. 保存与输出:
ggsave(plot = p9, width =8, height = 6, dpi = 300, filename = "C:/Users/Mr.R/Desktop/Fig1_a.jpg")
4. 完整的代码为:
library(ggplot2)
p1 <- ggplot(data = DF, aes(x = DF$`mShannon diversity`, y = DF$`Observed Shannon diversity`)) + geom_point()
p1
p3<-p1+geom_smooth(method = "lm", se=FALSE, color="red", formula = y ~ x)
p3
p4<-p3+ theme_bw()
p4
p5<-p4+theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),panel.background = element_blank(), axis.line = element_line(colour = "black"))
p5
p6<-p5+ theme(panel.border = element_blank())
p6
p7<-p6+ggtitle("a") + xlab("mShannon diversity") + ylab("Observed Shannon diversity")
p7
p8<-p7+annotate(geom="text", x=2.361, y=5.4, label= "Out-of-sample ")+annotate(geom="text", x=2.734, y=5.4, label=expression(R^{2}))+annotate(geom="text", x=2.93, y=5.4, label= "= 0.45") +annotate(geom="text", x=2.5,y=5.1, label= " Pearson’s r = 0.68")+annotate(geom="text", x=2.461, y=4.7, label= "P = 3.21 × ")+annotate(geom="text", x=2.74, y=4.754, label=expression(10^{-56}))
p8
p9<-p8+scale_x_continuous( breaks = seq(2,5.5,by=0.5))+scale_y_continuous( breaks = seq(2,5.5,by=0.5) )