Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To compare the overall differences between groups within your chosen variable, a Permutational Multivariate Analysis of Variance (PERMANOVA) test can be performed and similarly a pairwise Permutational Multivariate Analysis of Variance ( PERMANOVA ) test can be performed to compare differences between each group.

The R-squared value represents the percentage of variance explained by the examined groups. E.g. if R = 0.23 then 23% of the total diversity is explained by groupwise differences. PERMANOVA is based on groupwise differences, thus cannot be applied to continuous data.

PERMANOVA:

Code Block
# Need to remove rows (from ASV abundance table) with all 0 counts first
asvmatrix <- ampvisdata$abund
asvmatrix <- asvmatrix[rowSums(asvmatrix) > 0, ]
# Also need to transpose (samples need to be as rows, asv's as columns)
asvmatrix <- t(asvmatrix)
# Then generate pairwise distance matrix
sampdist <- vegdist(asvmatrix, method="bray")
# Subset samples table by samples in ampvis2 object (in case some were filtered out)
samples_table_filt <- samples_table[samples_table$ID %in% ampvisdata$metadata$ID, ]
# Use adonis function (vegan package: "Permutational Multivariate Analysis of Variance Using Distance Matrices") to run PERMANOVA on distances
pathotype.adonis <- adonis2(sampdist ~ get(group), data = samples_table_filt)
# Output the r squared and p values as variables
r2 <- pathotype.adonis$R2[1]
pval <- pathotype.adonis$`Pr(>F)`[1]

...