shepard_plot: Plot Shepard diagram

View source: R/shepard_plot.R

shepard_plotR Documentation

Plot Shepard diagram

Description

This function helps to estimate the representativeness of ordinations obtained using any reduced-space ordination method.

Usage

shepard_plot(dis, ord, k = 2, show = TRUE)

Arguments

dis

Original dissimilarity matrix (class "dist")

ord

Ordination scores (class "matrix" or "data.frame") or (class "dist")

k

Number of dimensions (default, 2) that will be taken into account (only if the ordination scores were provided in 'ord')

show

Logical; show the resulting plot on screen

Details

This function compares original dissimilarities among the objects with Euclidean distances in reduced space obtained with ordination (object scores or coordinates of the objects in the reduced space). If the points are close to diagonal then the projection in reduced space accounts for a high fraction of the variance.

Value

Invisible returns ggplot-object.

References

Legendre P. & Legendre L. Numerical Ecology. 2012. 3rd Ed. - Chapter 9 (Ordination in reduced space).

See Also

vegan::stressplot, MAAS::Shepard

Examples

library(vegan)
data(dune)
ds <- decostand(dune, method = "total", MARGIN = 1)  # standardize data to species relative abundance
dd <- vegdist(ds, method = "bray")                   # compute dissimilarity between samples
ord <- monoMDS(dd, k = 5)                            # NMDS (non-metric multidimensional scaling)
dd.ord <- dist( scores(ord) )                        # Euclidean distance in reduced space

shepard_plot(dis = dd, ord = dd.ord)               # Bray-Curtis vs distance in reduced space (k-dimensional)
shepard_plot(dis = dd, ord = scores(ord), k = 2)   # Bray-Curtis vs distance in reduced space (only first 2 dimensions)
shepard_plot(dis = dd, ord = scores(ord), k = 3)   # Bray-Curtis vs distance in reduced space (first 3 dimensions)

# Example with phyloseq wrappers
data("GlobalPatterns")
dd <- distance(GlobalPatterns, method = "unifrac", type = "samples")
ord <- ordinate(GlobalPatterns, method = "NMDS", distance = dd)
shepard_plot(dis = dd, ord = scores(ord))


vmikk/metagMisc documentation built on June 20, 2024, 7:20 a.m.