This script generates faceted boxplot of beta dispersion for all six beta diversity metrics from the whole & core fish gut microbiomes.
We start by loading the beta dispersion data generated in script 5 for the whole and core microbiomes, respectively.
<- read.csv("tables/p5/boxplot_dispersion_data_whole_jjs.csv",
data.all row.names = NULL, header = T, sep = ",")
<- read.csv("tables/p5/boxplot_dispersion_data_core_NEW2_jjs.csv",
data.all.core row.names = NULL, header = T, sep = ",")
$Reef <- factor(data.all$Reef, levels = c('SCR', 'PPR', 'CCR',
data.all'ALR', 'SIS', 'ROL',
'RNW', 'PST','PBL'))
$Reef <- factor(data.all.core$Reef, levels = c('SCR', 'PPR',
data.all.core'CCR', 'ALR',
'SIS', 'ROL',
'RNW', 'PST',
'PBL'))
Then we set some plot themes.
<- c('SCR', 'PPR', 'CCR', 'ALR', 'SIS', 'ROL', 'RNW', 'PST','PBL')
level_order3 <- c('Outer bay', 'Inner bay', 'Inner bay disturbed')
level_order <- c('Jaccard', 'Modified Gower', 'Bray Curtis', 'Unifrac',
level_order2 'Generalized Unifrac', 'Weighted Unifrac')
<- c("royalblue4", "royalblue3", "royalblue1",
disp.pal4 "aquamarine4", "mediumaquamarine", "aquamarine2",
"chocolate3", "chocolate2", "sienna1")
<- c("midnightblue", "royalblue4", "royalblue3","darkslategrey",
disp.pal5 "aquamarine4", "mediumaquamarine", "chocolate4", "sienna",
"chocolate3")
= theme(
font_theme axis.title.x = element_text(size = 14),
axis.text.x = element_text(size = 10),
axis.title.y = element_text(size = 14),
axis.text.y = element_text(size = 8))
<-
fig4A ggplot(data = data.all, aes(x = factor(Zone, level = level_order),
y=Distance_to_centroid))+
stat_boxplot(aes(colour=Reef), geom ='errorbar', alpha=1) +
geom_boxplot(aes(fill=Reef, colour=Reef), alpha=1,
outlier.alpha = 0.7, outlier.shape = 16)+
scale_colour_manual(values=disp.pal5)+
scale_fill_manual(values=disp.pal4)+
ggtitle("Multivariate Dispersion", subtitle="Whole microbiome")+
theme(plot.title=element_text(size=18, face="bold"))+
theme(plot.subtitle=element_text(size=16))+
+
font_themestat_summary(aes(fill=Reef), fun="mean", geom="point",
size=2.5, shape=18,
position=position_dodge(width=0.75),
color=c("midnightblue", "royalblue4", "royalblue3",
"darkslategrey", "aquamarine4", "mediumaquamarine",
"chocolate4", "sienna", "chocolate3",
"midnightblue", "royalblue4", "royalblue3",
"darkslategrey", "aquamarine4", "mediumaquamarine",
"chocolate4", "sienna", "chocolate3", "midnightblue",
"royalblue4", "royalblue3","darkslategrey",
"aquamarine4", "mediumaquamarine","chocolate4",
"sienna", "chocolate3", "midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3", "midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3","midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3"), show.legend = FALSE)+
scale_x_discrete(name="Zone") +
scale_y_continuous(name="Distance to centroid")+
facet_wrap(~factor(Metric, levels=unique(Metric)),
scales="free",ncol = 3)+
theme(strip.background = element_rect(color="black", fill="white",
size=1, linetype="blank"),
strip.text.x = element_text(size = 14),
panel.border = element_rect(fill = NA, color="black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "white",colour = NA),
legend.key = element_rect(fill = "transparent", color = NA),
legend.text = element_text(size = 12),
legend.title = element_text(size = 14))
fig4A
<-
fig4B ggplot(data = data.all.core, aes(x = factor(Zone, level = level_order),
y=Distance_to_centroid))+
stat_boxplot(aes(colour=Reef), geom ='errorbar', alpha=1) +
geom_boxplot(aes(fill=Reef, colour=Reef), alpha=1,
outlier.alpha = 0.7, outlier.shape = 16)+
scale_colour_manual(values=disp.pal5)+
scale_fill_manual(values=disp.pal4)+
ggtitle("", subtitle="Core microbiome")+
theme(plot.subtitle=element_text(size=16))+
+
font_themestat_summary(aes(fill=Reef), fun="mean", geom="point", size=2.5, shape=18,
position=position_dodge(width=0.75),
color=c("midnightblue", "royalblue4", "royalblue3",
"darkslategrey", "aquamarine4", "mediumaquamarine",
"chocolate4", "sienna", "chocolate3","midnightblue",
"royalblue4", "royalblue3","darkslategrey",
"aquamarine4", "mediumaquamarine","chocolate4",
"sienna", "chocolate3","midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3","midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3", "midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna",
"chocolate3", "midnightblue", "royalblue4",
"royalblue3","darkslategrey", "aquamarine4",
"mediumaquamarine","chocolate4", "sienna", "chocolate3"),
show.legend = FALSE)+
scale_x_discrete(name="Zone") +
scale_y_continuous(name = "Distance to centroid") +
facet_wrap(~factor(Metric, levels=unique(Metric)),scales = "free", ncol = 3) +
theme(strip.background = element_rect(color="black", fill = "white",
size=1, linetype="blank"),
strip.text.x = element_text(size = 14),
panel.border = element_rect(fill = NA, color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "white",colour = NA),
legend.key = element_rect(fill = "transparent", color = NA),
legend.text = element_text(size = 12),
legend.title = element_text(size = 14))
fig4B
That’s the end of Script 6. In the next Script we use PIME as an additional tool to identify the core fish gut microbiome.
The source code for this page can be accessed on GitHub by clicking this link.
If you see mistakes or want to suggest changes, please create an issue on the source repository.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/bocasbiome/web/, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".