Calculate correlations between NMDS ordination axes (from beta diversity distances) and metadata, and plot a ggplot2 heatmap with numeric labels and significance stars.

For continuous variables, Pearson correlation is used. P values follow this convention: p < 0.001, p < 0.01, p < 0.05 = three, two, one stars, respectively.

Default num_mds is 10, but function will internally set max number of NMDS to be n-1 where n is your number of samples.

PlotOrdCorr(object, num_mds = 10, meta_cols = NULL, distance = "bray")

Arguments

object

A geneda object containing normalized and metadata.

num_mds

Number of NMDS axes to correlate. Default = 10

meta_cols

Optional character vector of metadata column names to include. Defaults to all metadata columns.

distance

Distance metric for vegdist (default "bray").

Value

A list with elements: cor_matrix, pval_matrix, stars, plot (ggplot), and variance explained (squared correlations between ordination distances and observed dissimilarities.)