Skip to contents

Analyze how beta diversity changes as sites are accumulated spatially. Partitions beta diversity into turnover (species replacement) and nestedness (species loss) components following Baselga (2010).

Usage

spaccBeta(
  x,
  coords,
  traits = NULL,
  tree = NULL,
  n_seeds = 50L,
  method = c("knn", "nn_walk"),
  index = c("sorensen", "jaccard"),
  distance = c("euclidean", "haversine"),
  parallel = TRUE,
  n_cores = NULL,
  progress = TRUE,
  seed = NULL,
  map = FALSE,
  focal_points = NULL,
  focal_domain = NULL,
  pool = NULL
)

Arguments

x

A site-by-species matrix (presence/absence or abundance).

coords

A data.frame with columns x and y, or a spacc_dist object.

traits

Optional species-by-traits matrix or data.frame (row names matching species). When supplied, functional beta diversity is computed.

tree

Optional phylogenetic tree of class phylo, or a pairwise phylogenetic distance matrix. When supplied, phylogenetic beta diversity is computed. Supply at most one of traits or tree.

n_seeds

Integer. Number of random starting points. Default 50.

method

Character. Accumulation method: "knn" or "nn_walk".

index

Character. Dissimilarity index: "sorensen" (default) or "jaccard".

distance

Character. Distance method: "euclidean" or "haversine".

parallel

Logical. Use parallel processing? Default TRUE.

n_cores

Integer. Number of cores.

progress

Logical. Show progress? Default TRUE.

seed

Integer. Random seed.

map

Logical. If TRUE, run accumulation from every site as seed and store per-site final beta values for spatial mapping. Enables as_sf() and plot(type = "map"). Default FALSE.

focal_points

Optional focal points for method = "knn". See spacc().

focal_domain

Optional polygonal focal domain. See spacc().

pool

Optional vector with one value per site (habitat, degradation level, region) grouping sites into pools. The partition is then also computed between pooled assemblages along the same orders.

Value

An object of class spacc_beta containing:

beta_total

Matrix of total beta diversity (n_seeds x n_sites-1)

beta_turnover

Matrix of turnover component

beta_nestedness

Matrix of nestedness component

distance

Matrix of cumulative distances

pooled

With pool: the same four matrices for the pooled assemblages (n_seeds x n_pools-1), plus pool and n_pools; else NULL

n_seeds, n_sites, method, index

Parameters used

Details

At each step of spatial accumulation, beta diversity is calculated between the accumulated species pool and the newly added site. This reveals how species composition changes as you expand spatially.

Interpretation:

  • High turnover: New sites contribute different species (replacement)

  • High nestedness: New sites contribute subsets of existing species (loss)

The sum of turnover and nestedness equals total beta diversity.

Supplying traits computes functional beta diversity, weighting the partition by the trait distinctiveness of the species exchanged between the accumulated pool and each new site. Supplying tree computes phylogenetic beta diversity (PhyloSor), weighting by shared branch length. The taxonomic, functional, and phylogenetic variants all return a spacc_beta object whose beta_type field records which was computed. map = TRUE is supported for the taxonomic variant only.

With pool, sites are aggregated into pooled assemblages (a species is present in a pool if it occurs in any of its sites) and the partition is repeated between pools: each site order becomes the order in which its pools are first reached, and the distance between two pools is the mean distance between their sites. Partitions at the two resolutions can disagree, for example when degraded habitats are homogenised at the pool level while individual sites still differ (Jones et al. 2025). summary(x, resolution = "pooled") and plot(x, resolution = "pooled") or "both" show the pooled partition.

References

Baselga, A. (2010). Partitioning the turnover and nestedness components of beta diversity. Global Ecology and Biogeography, 19, 134-143.

Jones, F.A.M., Hardenbol, A.A., Hekkala, A.-M., et al. (2025). Partitioning beta diversity at two spatial resolutions reveals biotic homogenisation with habitat degradation. Diversity and Distributions, 31, e70080. doi:10.1111/ddi.70080

See also

betapart::beta.pair() for pairwise beta diversity

Examples

# \donttest{
coords <- data.frame(x = runif(50), y = runif(50))
species <- matrix(rbinom(50 * 30, 1, 0.3), nrow = 50)

beta <- spaccBeta(species, coords, n_seeds = 30)
plot(beta)

# Compare Sorensen vs Jaccard
beta_jac <- spaccBeta(species, coords, index = "jaccard")

# Functional beta diversity (pass a species-by-traits matrix)
traits <- matrix(rnorm(30 * 3), nrow = 30)
rownames(traits) <- colnames(species) <- paste0("sp", 1:30)
beta_func <- spaccBeta(species, coords, traits = traits)
# }