Environmental factors shaping the gut microbiome in a Dutch population
https://github.com/GRONINGEN-MICROBIOME-CENTRE/DMP
https://zenodo.org/record/5910709#.YmAcp4VBzic
今天的推文重复一下论文中的 figureS3a山脊图和S3b小提琴图加箱线图
image.png
因为论文中提供的不是真实数据集,是一个模拟数据集,所以出图和论文原图相差比较大
image.png
dag3_species_plot<-readr::read_csv("newdataset/FigureS3a.csv")
head(dag3_species_plot)
主要是用来调节Y轴的顺序
dag3_species_plot$Level <-
factor(dag3_species_plot$Level,
levels = c("Bacteroides_vulgatus",
"Bacteroidales_bacterium_ph8",
"Alistipes_shahii",
"Sutterella_wadsworthensis",
"Alistipes_onderdonkii",
"Bacteroides_uniformis",
"Subdoligranulum_unclassified",
"Prevotella_copri",
"Faecalibacterium_prausnitzii",
"Alistipes_putredinis"))
dag3_species_plot$Relative=-log2(dag3_species_plot$Relative)
library(randomcoloR)
palette <- distinctColorPalette(10)
这里randomcoloR
这个R包是第一次使用,主要作用是生成比较容易区分的颜色
library(ggridges)
library(ggplot2)
ggplot(dag3_species_plot,
aes(x = Relative, y = Level,fill=Level,color=Level)) +
theme_classic() +
geom_density_ridges(alpha=0.8,scale = 2,show.legend = FALSE)+
scale_fill_manual(values = palette) +
scale_color_manual(values = palette)+
ylab("")+
xlab("Norm. Rel. Abundance (-log2)")
image.png
这个图可能是因为数据分布的原因看起来不是很美观,重新构造一份数据集画个图
Level<-rep(c("Bacteroides_vulgatus",
"Bacteroidales_bacterium_ph8",
"Alistipes_shahii",
"Sutterella_wadsworthensis",
"Alistipes_onderdonkii",
"Bacteroides_uniformis",
"Subdoligranulum_unclassified",
"Prevotella_copri",
"Faecalibacterium_prausnitzii",
"Alistipes_putredinis"),
rep(2000,10))
library(tidyverse)
Relative<-10:19 %>%
map(function(x)rnorm(n=2000,mean=10,sd=x)) %>% unlist()
dat01<-data.frame(Level,Relative)
head(dat01)
dat01$Level<-
factor(dat01$Level,
levels = c("Bacteroides_vulgatus",
"Bacteroidales_bacterium_ph8",
"Alistipes_shahii",
"Sutterella_wadsworthensis",
"Alistipes_onderdonkii",
"Bacteroides_uniformis",
"Subdoligranulum_unclassified",
"Prevotella_copri",
"Faecalibacterium_prausnitzii",
"Alistipes_putredinis"))
ggplot(dat01,
aes(x = Relative, y = Level,fill=Level,color=Level)) +
theme_classic() +
geom_density_ridges(alpha=0.8,scale = 2,show.legend = FALSE)+
scale_fill_manual(values = palette) +
scale_color_manual(values = palette)+
ylab("")+
xlab("Norm. Rel. Abundance (-log2)")+
theme(axis.text.y = element_text(face="italic"),
axis.text.x = element_text(face="bold"))
image.png
这个就看起来好看了很多,这里只是为了学作图,如果是自己试验的真实数据用山脊图呈现的不是太美观,这种情况如何解决我暂时还想不到比较好的办法。
library(ggsci)
library(ggplot2)
cluster_plot<-readr::read_csv("newdataset/cluster_plot.csv",
col_types = "ccd")
g <- ggplot(cluster_plot,
aes(x=Cluster, y=Prevotella_copri,fill=Cluster)) +
geom_violin()+
geom_boxplot(width=0.1, fill="white")+
scale_fill_npg()+theme_classic()+
ylab("Prevotella Copri, Norm. Rel. Abundance (-log2)")
print(g)
image.png
library(patchwork)
g+theme(legend.position = "none")+figureS3A
image.png