asc_pairwise: Functional Differences Among Many Communities

View source: R/asc_pairwise.R

asc_pairwiseR Documentation

Functional Differences Among Many Communities

Description

Measures the three layers (position, dispersion and volume) for every pair of communities, e.g. sites along a gradient or the months of a series. To test whether the communities differ, pass the result to asc_null, which runs one global test per layer over all communities (instead of one p-value per pair).

Usage

asc_pairwise(
  traits,
  abund,
  dist_method = "gower",
  dim_retention = c("msd", "variance", "broken_stick"),
  var_tol = 0.8,
  na.rm = TRUE,
  correction = c("none", "sqrt"),
  type = NULL,
  weights = NULL
)

Arguments

traits

A data frame or matrix of functional traits, one row per species (row names = species). Categorical traits should be factors.

abund

A data frame or matrix of abundances, one row per community (unique row names, which name the pairs) and one column per species (matched to traits by name). Use counts of individuals for null model A.

dist_method

Distance metric for the trait matrix. Default is "gower".

dim_retention

Character. How many PCoA axes to keep: "msd" (default since 0.5.1: the number of axes, 2 to 10, whose Euclidean distances best reproduce the trait distances, i.e. the minimum mean squared deviation of Maire et al. 2015), "variance" (axes needed to reach var_tol of the positive variance; the default up to 0.5.0, use it to reproduce earlier results) or "broken_stick" (axes explaining more than the broken-stick expectation). assess_functional_space shows the fidelity for each number of axes.

var_tol

Numeric. Proportion of cumulative variance to retain when dim_retention = "variance". Default is 0.80.

na.rm

Logical. Remove missing values? Default is TRUE.

correction

Character. "none" (default) builds the PCoA on the Gower dissimilarity, as in 0.1.1. "sqrt" uses its square root, which Gower (1971) showed to be Euclidean for complete data with constant weights (no negative eigenvalues). It changes the distances between species (and the shape of the space), so results with and without it are not comparable; its effect on the tests has not been evaluated by simulation. An option when the space quality is low, not a default recommendation.

type, weights

Optional; passed unchanged to daisy (e.g. to declare asymmetric binary traits or to down-weight traits coded in several columns). Default: not used.

Value

An S3 object of class ascent_pairwise (it also carries the class ascfcd_pw of ascent 0.5.0, which will be dropped in 0.6.0), a list whose main element is pairwise_results (one row per pair: Community_A, Community_B, Delta_C_abs, rDelta_C_pct, Delta_FDis, Delta_FRic), with the functional space (F_space, k_retained, dim_retention, quality) and the inputs needed by asc_null().

Note

Direction of each pair: each pair goes from Community_A to Community_B, in the order of the rows of abund (the pair of rows 1 and 2 is named "row1_vs_row2"). Reversing the order reverses the sign of the shifts and of the leverages.

Normalization: Delta FDis and Delta FRic are absolute differences (see asc_paired for details).

Examples

# Five communities along a gradient from primary forest to farmland
pw <- asc_pairwise(birds_sim$traits, birds_sim$landscape)

# One row per pair of communities; rDelta_C_pct is the centroid shift
# between the two (% of the functional space)
summary(pw)

# The three most different pairs
pr <- pw$pairwise_results
head(pr[order(-pr$rDelta_C_pct), c("Community_A", "Community_B", "rDelta_C_pct")], 3)


# Do the communities differ (A), and is the variation organised by traits (B)?
pw <- asc_null(pw, n_perm = 99, seed = 1)
summary(pw)



ascent documentation built on Nov. 30, 2026, 1:07 a.m.