Script testing different distance metrics to estimate beta diversity using the whole and core fish gut communities across a range of environmental variables.
Next, we turn our attention to beta diversity estimates of fish guts. For both the whole community (i.e., all ASVs) and the core community (i.e., only core ASVs), we assess beta diversity against the following conditions:
For each condition or combination of conditions, we perform the following beta diversity estimates: Jaccard, Modified Gower, Bray Curtis, UNIFRAC, GUNIFRAC, WUNIFRAC. For each diversity metric, we a) calculate a dissimilarity matrix, b) assess beta dispersions, c) run a PERMANOVA, and in some cases, d) look at pairwise comparisons.
First, we load the rarefied whole fish gut microbiome data.
<- readRDS("rdata/p3/ps_16S_bocas_fish_final.rds") ps.whole
set.seed(1911)
<- phyloseq::distance(ps.whole, method = "jaccard", binary = T)
type.jaccard <- data.frame(sample_data(ps.whole)) sampledf
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner,
type.jaccard.inner method = "jaccard", binary = T)
<- data.frame(sample_data(ps.whole.inner)) sampledf.inner
<- betadisper(type.jaccard, sampledf$Zone,
beta.jaccard1 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard1, binary = TRUE, pairwise = TRUE,
permutations = 10000)
<- betadisper(type.jaccard, sampledf$Position,
beta.jaccard2 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard2, binary = TRUE, pairwise = TRUE,
permutations = 10000)
<- betadisper(type.jaccard.inner, sampledf.inner$Reef_type,
beta.jaccard3 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard3, binary = TRUE, pairwise = TRUE,
permutations = 10000)
<- adonis(type.jaccard ~ Zone, data = sampledf,
adonis.jaccard0 permutations = 10000)
<- adonis(type.jaccard ~ Reef, data = sampledf,
adonis.jaccardR permutations = 10000)
<- adonis(type.jaccard ~ Zone/Reef, data = sampledf,
adonis.jaccard1permutations = 10000)
<- adonis(type.jaccard ~ Position/Reef, data = sampledf,
adonis.jaccard2 permutations = 10000)
The variable reef type is healthy and disturbed (based on level coral cover).
<- adonis(type.jaccard.inner ~ Reef_type/Reef,
adonis.jaccard3 data = sampledf.inner, permutations = 10000)
<- pairwise.adonis(type.jaccard, factors = sampledf$Zone) pairwise1
<- pairwise.adonis(type.jaccard, factors = sampledf$Reef) pairwise2
For the modified Gower, we log transform the data using the microbiome package transformation because it uses the vegan deconstand
function. The distance matrix will be created from the log transformed data.
set.seed(1911)
<- microbiome::transform(ps.whole, transform = "log10p")
data.log10<- data.frame(sample_data(data.log10))
sampledf.log10 <- phyloseq::distance(data.log10, method = "altGower") type.modGower
<- betadisper(type.modGower, sampledf.log10$Zone,
beta.Gower1 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.modGower, sampledf.log10$Reef,
beta.GowerR type = "centroid", bias.adjust = TRUE)
permutest(beta.GowerR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.modGower, sampledf.log10$Position,
beta.Gower2 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower2, pairwise = TRUE, permutations = 10000)
<- subset_samples(data.log10, Zone != "Outer bay")
data.log10.inner <- phyloseq::distance(data.log10.inner, method = "altGower")
type.modGower.inner <- data.frame(sample_data(data.log10.inner))
sampledf.inner <- betadisper(type.modGower.inner, sampledf.inner$Reef_type,
beta.Gower3 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower3, binary = TRUE, pairwise = TRUE,
permutations = 10000)
set.seed(1911)
<- adonis(type.modGower ~ Zone, data = sampledf.log10,
adonis.modGower0 permutations = 10000)
<- adonis(type.modGower ~ Reef, data = sampledf.log10,
adonis.modGowerR permutations = 10000)
<- adonis(type.modGower ~ Zone/Reef, data = sampledf.log10,
adonis.modGower1 permutations = 10000)
<- adonis(type.modGower ~ Position/Reef, data = sampledf.log10,
adonis.modGower2 permutations = 10000)
<- subset_samples(data.log10, Zone != "Outer bay")
data.log10.inner <- phyloseq::distance(data.log10.inner, method = "altGower")
type.modGower.inner <- data.frame(sample_data(data.log10.inner))
sampledf.inner.log10 <- adonis(type.modGower.inner ~ Reef_type/Reef,
adonis.modGower3 data = sampledf.inner.log10, permutations = 10000)
set.seed(1911)
pairwise.adonis(type.modGower, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.modGower, factors = sampledf$Reef)
set.seed(1911)
<- phyloseq::distance(ps.whole, method = "bray")
type.bray <- data.frame(sample_data(ps.whole)) sampledf
<- betadisper(type.bray, sampledf$Zone,
beta.bray1 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.bray, sampledf$Reef,
beta.brayR type = "centroid", bias.adjust = TRUE)
permutest(beta.brayR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.bray, sampledf$Position,
beta.bray2 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray2, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner, method = "bray")
type.bray.inner <- betadisper(type.bray.inner, sampledf.inner$Reef_type,
beta.bray3 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.bray ~ Zone, data = sampledf,
adonis.bray0 permutations = 10000)
<- adonis(type.bray ~ Reef, data = sampledf,
adonis.brayR permutations = 10000)
<- adonis(type.bray ~ Zone/Reef, data = sampledf,
adonis.bray1 permutations = 10000)
<- adonis(type.bray ~ Position/Reef, data = sampledf,
adonis.bray2 permutations = 10000)
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner, method = "bray")
type.bray.inner <- data.frame(sample_data(ps.whole.inner))
sampledf.inner <- adonis(type.bray.inner ~ Reef_type/Reef, data = sampledf.inner,
adonis.bray3 permutations = 10000)
set.seed(1911)
pairwise.adonis(type.bray, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.bray, factors = sampledf$Reef)
set.seed(1911)
<- phyloseq::distance(ps.whole, method = "unifrac", weighted = F)
type.unifrac <- data.frame(sample_data(ps.whole)) sampledf
<- betadisper(type.unifrac, sampledf$Zone,
beta.unifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.unifrac, sampledf$Reef,
beta.unifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.unifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.unifrac, sampledf$Position,
beta.unifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac2, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner, method = "unifrac")
type.unifrac.inner <- data.frame(sample_data(ps.whole.inner))
sampledf.whole.inner <- betadisper(type.unifrac.inner, sampledf.whole.inner$Reef_type,
beta.unifrac3 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.unifrac ~ Zone, data = sampledf,
adonis.unifrac0 permutations = 10000)
<- adonis(type.unifrac ~ Reef, data = sampledf,
adonis.unifracR permutations = 10000)
<- adonis(type.unifrac ~ Zone/Reef, data = sampledf,
adonis.unifrac1 permutations = 10000)
<- adonis(type.unifrac ~ Position/Reef, data = sampledf,
adonis.unifrac2 permutations = 10000)
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner, method = "unifrac")
type.unifrac.inner <- data.frame(sample_data(ps.whole.inner))
sampledf.inner
<- adonis(type.unifrac.inner ~ Reef_type/Reef,
adonis.unifrac3 data = sampledf.inner, permutations = 10000)
set.seed(1911)
pairwise.adonis(type.unifrac, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.unifrac, factors = sampledf$Reef)
<-otu_table(ps.whole)
asv.tab<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- otu_table(ps.whole.inner)
asv.tab.inner
<-phy_tree(ps.whole)
tree.fish<-phy_tree(ps.whole.inner)
tree.fish.inner
<-sample_data(ps.whole)
fish.sample<-sample_data(ps.whole.inner)
fish.sample.inner
<- fish.sample$Zone
groups2.whole <- fish.sample$Reef
groupsR.whole <- fish.sample.inner$Zone
groups.inner <- fish.sample$Position position.whole
<- GUniFrac(asv.tab, tree.fish,
unifracs alpha=c(0, 0.5, 1))$unifracs
<- GUniFrac(asv.tab.inner, tree.fish.inner,
unifracs.inner alpha=c(0, 0.5, 1))$unifracs
<- unifracs[, , "d_0.5"]
d5.all <- unifracs.inner[, , "d_0.5"]
d5.inner <- as.dist(d5.all)
type.gunifrac <- as.dist(d5.inner) type.gunifrac.inner
set.seed(1911)
<- betadisper(as.dist(d5.all), groups2.whole,
beta.gunifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac1, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.all), groupsR.whole,
beta.gunifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.all), position.whole,
beta.gunifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac2, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.inner), groups.inner,
beta.gunifrac.inner type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac.inner, pairwise = TRUE, permutations = 10000)
<- data.frame(sample_data(ps.whole))
sampledf <- data.frame(sample_data(ps.whole.inner))
sampledf.inner <- adonis(type.gunifrac ~ Zone/Reef, data = sampledf,
adonis.gunifrac1permutations = 10000)
<- adonis(type.gunifrac ~ Position/Reef, data = sampledf,
adonis.gunifrac2permutations = 10000)
<- adonis(type.gunifrac.inner ~ Reef_type/Reef,
adonis.gunifrac3data = sampledf.whole.inner, permutations = 10000)
as a substitute for posthoc test of PERMANOVA
pairwise.adonis(type.gunifrac, factors = sampledf$Zone,
p.adjust.m = "bonferroni")
pairwise.adonis(type.gunifrac, factors = sampledf$Reef,
p.adjust.m = "bonferroni")
set.seed(1911)
<- phyloseq::distance(ps.whole, method = "wunifrac")
type.wunifrac <- data.frame(sample_data(ps.whole)) sampledf
<- betadisper(type.wunifrac, sampledf$Zone,
beta.wunifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.wunifrac, sampledf$Reef,
beta.wunifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.wunifrac, sampledf$Position,
beta.wunifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac2, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.whole, Zone != "Outer bay")
ps.whole.inner <- phyloseq::distance(ps.whole.inner, method = "wunifrac")
type.wunifrac.inner <- data.frame(sample_data(ps.whole.inner)) sampledf.inner
<- betadisper(type.wunifrac.inner, sampledf.inner$Reef_type,
beta.wunifrac3 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.wunifrac ~ Zone, data = sampledf,
adonis.wunifrac0 permutations = 10000)
<- adonis(type.wunifrac ~ Reef, data = sampledf,
adonis.wunifracR permutations = 10000)
<- adonis(type.wunifrac ~ Zone/Reef, data = sampledf,
adonis.wunifrac1 permutations = 10000)
<- adonis(type.wunifrac ~ Position/Reef, data = sampledf,
adonis.wunifrac2 permutations = 10000)
set.seed(1911)
pairwise.adonis(type.wunifrac, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.wunifrac, factors = sampledf$Reef)
First, we load the unrarefied core fish gut microbiome data.
<- readRDS("rdata/p1/ps_indv01_core_fish.rds")
ps.core ps.core
set.seed(1911)
<- phyloseq::distance(ps.core, method = "jaccard", binary = T)
type.jaccard <- data.frame(sample_data(ps.core)) sampledf
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner,
type.jaccard.inner method = "jaccard", binary=T)
<- data.frame(sample_data(ps.core.inner)) sampledf.inner
<- betadisper(type.jaccard, sampledf$Zone,
beta.jaccard1 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard1, binary = TRUE, pairwise = TRUE, permutations = 10000)
<- betadisper(type.jaccard, sampledf$Position,
beta.jaccard2 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard2, binary = TRUE, pairwise = TRUE, permutations = 10000)
<- betadisper(type.jaccard.inner, sampledf.inner$Reef_type,
beta.jaccard3 type = "centroid", bias.adjust = TRUE)
permutest(beta.jaccard3, binary = TRUE, pairwise = TRUE, permutations = 10000)
<- adonis(type.jaccard ~ Zone, data = sampledf,
adonis.jaccard0permutations = 10000)
<- adonis(type.jaccard ~ Reef, data = sampledf,
adonis.jaccardRpermutations = 10000)
#by Zone with Reef nested in Zone
<- adonis(type.jaccard ~ Zone/Reef, data = sampledf,
adonis.jaccard1permutations = 10000)
<- adonis(type.jaccard ~ Position/Reef, data = sampledf,
adonis.jaccard2 permutations = 10000)
<- adonis(type.jaccard.inner ~ Reef_type/Reef,
adonis.jaccard3 data = sampledf.inner, permutations = 10000)
set.seed(1911)
<- pairwise.adonis(type.jaccard, factors = sampledf$Zone) pairwise1
<- pairwise.adonis(type.jaccard, factors = sampledf$Reef) pairwise2
Again, for the modified Gower, we log transform the data using the microbiome package transformation because it uses the vegan deconstand
function. The distance matrix will be created from the log transformed data.
set.seed(1911)
<- microbiome::transform(ps.core, transform = "log10p")
data.log10<- data.frame(sample_data(data.log10))
sampledf.log10 <- phyloseq::distance(data.log10, method = "altGower") type.modGower
<- betadisper(type.modGower, sampledf.log10$Zone,
beta.Gower1 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.modGower, sampledf.log10$Reef,
beta.GowerR type = "centroid", bias.adjust = TRUE)
permutest(beta.GowerR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.modGower, sampledf.log10$Position,
beta.Gower2 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower2, pairwise = TRUE, permutations = 10000)
<- subset_samples(data.log10, Zone != "Outer bay")
data.log10.inner <- phyloseq::distance(data.log10.inner,
type.modGower.inner method = "altGower")
<- data.frame(sample_data(data.log10.inner))
sampledf.inner <- betadisper(type.modGower.inner, sampledf.inner$Reef_type,
beta.Gower3 type = "centroid", bias.adjust = TRUE)
permutest(beta.Gower3, binary = TRUE, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.modGower ~ Zone, data = sampledf.log10,
adonis.modGower0 permutations = 10000)
<- adonis(type.modGower ~ Reef, data = sampledf.log10,
adonis.modGowerR permutations = 10000)
<- adonis(type.modGower ~ Zone/Reef, data = sampledf.log10,
adonis.modGower1 permutations = 10000)
<- adonis(type.modGower ~ Position/Reef, data = sampledf.log10,
adonis.modGower2 permutations = 10000)
<- subset_samples(data.log10, Zone != "Outer bay")
data.log10.inner <- phyloseq::distance(data.log10.inner, method = "altGower")
type.modGower.inner <- data.frame(sample_data(data.log10.inner))
sampledf.inner.log10 <- adonis(type.modGower.inner ~ Reef_type/Reef,
adonis.modGower3 data = sampledf.inner.log10, permutations = 10000)
pairwise.adonis(type.modGower, factors = sampledf$Zone)
pairwise.adonis(type.modGower, factors = sampledf$Reef)
set.seed(1911)
<- phyloseq::distance(ps.core, method = "bray")
type.bray <- data.frame(sample_data(ps.core)) sampledf
<- betadisper(type.bray, sampledf$Zone,
beta.bray1 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.bray, sampledf$Reef,
beta.brayR type = "centroid", bias.adjust = TRUE)
permutest(beta.brayR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.bray, sampledf$Position,
beta.bray2 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray2, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "bray")
type.bray.inner <- betadisper(type.bray.inner, sampledf.inner$Reef_type,
beta.bray3 type = "centroid", bias.adjust = TRUE)
permutest(beta.bray3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.bray ~ Zone, data = sampledf,
adonis.bray0 permutations = 10000)
<- adonis(type.bray ~ Reef, data = sampledf,
adonis.brayR permutations = 10000)
adonis.brayR<- adonis(type.bray ~ Zone/Reef, data = sampledf,
adonis.bray1 permutations = 10000)
<- adonis(type.bray ~ Position/Reef, data = sampledf,
adonis.bray2 permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "bray")
type.bray.inner <- data.frame(sample_data(ps.core.inner))
sampledf.inner <- adonis(type.bray.inner ~ Reef_type/Reef, data = sampledf.inner,
adonis.bray3 permutations = 10000)
set.seed(1911)
pairwise.adonis(type.bray, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.bray, factors = sampledf$Reef)
set.seed(1911)
<- phyloseq::distance(ps.core, method = "unifrac", weighted=F)
type.unifrac <- data.frame(sample_data(ps.core)) sampledf
<- betadisper(type.unifrac, sampledf$Zone,
beta.unifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac1, pairwise = TRUE, permutations = 10000)
<- betadisper(type.unifrac, sampledf$Reef,
beta.unifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.unifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.unifrac, sampledf$Position,
beta.unifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac2, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "unifrac")
type.unifrac.inner <- data.frame(sample_data(ps.core.inner))
sampledf.core.inner <- betadisper(type.unifrac.inner, sampledf.core.inner$Reef_type,
beta.unifrac3 type = "centroid", bias.adjust = TRUE)
permutest(beta.unifrac3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.unifrac ~ Zone, data = sampledf,
adonis.unifrac0 permutations = 10000)
<- adonis(type.unifrac ~ Reef, data = sampledf,
adonis.unifracR permutations = 10000)
<- adonis(type.unifrac ~ Zone/Reef, data = sampledf,
adonis.unifrac1 permutations = 10000)
<- adonis(type.unifrac ~ Position/Reef, data = sampledf,
adonis.unifrac2 permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "unifrac")
type.unifrac.inner <- data.frame(sample_data(ps.core.inner)) sampledf.inner
<- adonis(type.unifrac.inner ~ Reef_type/Reef,
adonis.unifrac3 data = sampledf.inner,
permutations = 10000)
set.seed(1911)
pairwise.adonis(type.unifrac, factors = sampledf$Zone)
set.seed(1911)
pairwise.adonis(type.unifrac, factors = sampledf$Reef)
<-otu_table(ps.core)
asv.tab<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- otu_table(ps.core.inner) asv.tab.inner
<-phy_tree(ps.core)
tree.fish.core<-phy_tree(ps.core.inner) tree.fish.core.inner
<-sample_data(ps.core)
fish.sample.core<-sample_data(ps.core.inner) fish.sample.core.inner
<- fish.sample.core$Zone
groups2.core <- fish.sample.core$Reef
groupsR.core <- fish.sample.core.inner$Zone
groups.inner.core <- fish.sample.core$Position position.core
<- GUniFrac(asv.tab, tree.fish.core,
unifracs alpha=c(0, 0.5, 1))$unifracs
<- GUniFrac(asv.tab.inner, tree.fish.core.inner,
unifracs2 alpha=c(0, 0.5, 1))$unifracs
<- unifracs[, , "d_0.5"]
d5.all <- unifracs2[, , "d_0.5"] d5.inner
<- as.dist(d5.all)
type.gunifrac <- as.dist(d5.inner) type.gunifrac.inner
set.seed(1911)
<- betadisper(as.dist(d5.all), groups2.core,
beta.gunifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac1, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.all), groupsR.core,
beta.gunifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.all), position.core,
beta.gunifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac2, pairwise = TRUE, permutations = 10000)
<- betadisper(as.dist(d5.inner), groups.inner.core,
beta.gunifrac.inner type = "centroid", bias.adjust = TRUE)
permutest(beta.gunifrac.inner, pairwise = TRUE, permutations = 10000)
<- data.frame(sample_data(ps.core))
sampledf <- data.frame(sample_data(ps.core.inner)) sampledf.inner
<- adonis(type.gunifrac ~ Zone, data = sampledf,
adonis.gunifrac0permutations = 10000)
<- adonis(type.gunifrac ~ Zone, data = sampledf,
adonis.gunifracRpermutations = 10000)
<- adonis(type.gunifrac ~ Zone/Reef, data = sampledf,
adonis.gunifrac1permutations = 10000)
<- adonis(type.gunifrac ~ Position/Reef, data = sampledf,
adonis.gunifrac2permutations = 10000)
<- adonis(type.gunifrac.inner ~ Reef_type/Reef,
adonis.gunifrac3data = sampledf.core.inner, permutations = 10000)
pairwise.adonis(type.gunifrac, factors = sampledf$Zone,
p.adjust.m = "bonferroni")
pairwise.adonis(type.gunifrac, factors = sampledf$Reef,
p.adjust.m = "bonferroni")
set.seed(1911)
<- phyloseq::distance(ps.core, method = "wunifrac")
type.wunifrac <- data.frame(sample_data(ps.core)) sampledf
<- betadisper(type.wunifrac, sampledf$Zone,
beta.wunifrac1 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac1, pairwise = TRUE, permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "wunifrac")
type.wunifrac.inner <- data.frame(sample_data(ps.core.inner)) sampledf.inner
<- betadisper(type.wunifrac, sampledf$Reef,
beta.wunifracR type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifracR, pairwise = TRUE, permutations = 10000)
<- betadisper(type.wunifrac, sampledf$Position,
beta.wunifrac2 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac2, pairwise = TRUE, permutations = 10000)
<- betadisper(type.wunifrac.inner, sampledf.inner$Reef_type,
beta.wunifrac3 type = "centroid", bias.adjust = TRUE)
permutest(beta.wunifrac3, pairwise = TRUE, permutations = 10000)
set.seed(1911)
<- adonis(type.wunifrac ~ Zone, data = sampledf,
adonis.wunifrac0 permutations = 10000)
<- adonis(type.wunifrac ~ Reef, data = sampledf,
adonis.wunifracR permutations = 10000)
<- adonis(type.wunifrac ~ Zone/Reef, data = sampledf,
adonis.wunifrac1 permutations = 10000)
<- adonis(type.wunifrac ~ Position/Reef, data = sampledf,
adonis.wunifrac2 permutations = 10000)
<- subset_samples(ps.core, Zone != "Outer bay")
ps.core.inner <- phyloseq::distance(ps.core.inner, method = "wunifrac")
type.wunifrac.inner <- data.frame(sample_data(ps.core.inner)) sampledf.inner
<- adonis(type.wunifrac.inner ~ Reef_type/Reef,
adonis.wunifrac3 data = sampledf.inner, permutations = 10000)
pairwise.adonis(type.wunifrac, factors = sampledf$Zone)
pairwise.adonis(type.wunifrac, factors = sampledf$Reef)
That’s the end of Script 5. In the next Script we assess Beta Dispersion for all beta diversity estimates.
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 ...".