Introduction
Theory, R functions & Examples
# PCoA and NMDS ordiagrams using Vltava data (added categorical variable) vltava.spe <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/vltava-spe.txt', row.names = 1) vltava.env <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/vltava-env.txt') library (vegan) png ('pcoa_nmds.png', width = 8, height = 4, units = 'in', res = 300, pointsize = 11) par (mfrow = c(1,2)) pcoa <- capscale (log1p (vltava.spe) ~ 1, distance = 'bray', sqrt.dist = TRUE, scaling = 1) plot (pcoa, main = 'PCoA (MDS)', type = 'n') points (pcoa, display = 'si', col = vltava.env$GROUP, pch = vltava.env$GROUP) text (pcoa, display = 'sp', col = "#FF000080", cex = 0.6, scaling = 1, select = colSums (vltava.spe>0)>20) legend ('bottomleft', pch = 1:4, col = 1:4, legend = 1:4, title = 'GROUP', cex = 0.6) nmds <- metaMDS (log1p (vltava.spe), distance = 'bray', scaling = 1) plot (nmds, main = 'NMDS', type = 'n', display = 'si') points (nmds, display = 'si', col = vltava.env$GROUP, pch = vltava.env$GROUP) text (nmds, display = 'sp', col = "#FF000080", cex = 0.6, select = colSums (vltava.spe>0)>20) dev.off ()