Environmental factors shaping the gut microbiome in a Dutch population
https://github.com/GRONINGEN-MICROBIOME-CENTRE/DMP
https://zenodo.org/record/5910709#.YmAcp4VBzic
今天的推文重复一下论文中的 figureS3c 误差线图
image.png
image.png
disease_enterotype<-readr::read_csv("newdataset/FigureS3c.csv")
disease_enterotype$Sig=NA
disease_enterotype$Sig[disease_enterotype$Pvalue<0.5]="Significant"
disease_enterotype$Sig[disease_enterotype$Pvalue>=0.5]="Non-Significant"
这里的p值我选择0.5是因为论文中的数据是模拟数据,没啥实际意义。自己真实的数据集需要酌情考虑
disease_enterotype=disease_enterotype[order(disease_enterotype$OR),]
disease_enterotype=na.omit(disease_enterotype)
disease_enterotype$Disease=factor(disease_enterotype$Disease,levels = disease_enterotype$Disease)
library(ggplot2)
g <- ggplot(disease_enterotype, aes(x = OR, y = Disease,color=Sig)) +
geom_vline(aes(xintercept = 1), size = .25, linetype = "dashed") +
geom_errorbarh(aes(xmax = `CI_up`, xmin = `CI_low`), size = .3,
height = 0.2) +
geom_point(size = 3.5,shape=7) +
theme_bw()+ theme(panel.grid.minor = element_blank()) +
ylab("") + xlab("Odds ratio")+scale_color_lancet()
print(g)
image.png
论文中的图x轴还有一些注释信息,可以出图后借助其他软件编辑,如果先用代码实现的话可以借助annotate_custom()
函数,上一篇推文由关于这个函数的介绍,可以找来参考
论文中figureS3的布局,上面已经有两个图,下面这个图可能改成水平方向的会美观一点
g+coord_flip()+
theme(legend.position = "top",
axis.text.x = element_text(angle=90,
hjust=1,vjust=0.5))