Beta diversity describes how the species composition changes from one place to the next. Along an accumulation curve that change has two sources: a new site can bring different species in place of those already seen (turnover), or it can hold a species-poor subset of them (nestedness). This article tracks both along spatial orders following Baselga (2010), repeats the partition between groups of sites, counts the effectively distinct communities with Hill numbers (Jost 2007), removes the sampling effect from that count, and repeats the partition in trait space and on a phylogeny. Installation is covered in Get started; the phylogenetic example also needs the ape package.
Partition turnover and nestedness along the curve with
spaccBeta().Pool sites into groups with the
poolargument to compare two resolutions.Count effectively distinct communities at each step with
spaccHillBeta().Standardise that count to equal sample coverage with
standardize = "coverage".Partition trait volume or branch length with the
traitsortreeargument ofspaccBeta().
Example
Simulating clustered communities
The example uses 60 sites in a 100 by 100 plane and 30 species. Each
species has a random centre, and its expected count at a site falls off
as a Gaussian kernel of the squared distance from that centre, with a
peak of 5 individuals and about 1.8 individuals at 32 units. Counts are
drawn from a Poisson distribution, so each species is confined to a
patch of the plane and neighbouring sites share many species.
species holds the counts, pa the
presence/absence version, and coords the site positions in
columns x and y.
Simulation code
set.seed(123)
n_sites <- 60
n_species <- 30
coords <- data.frame(x = runif(n_sites, 0, 100),
y = runif(n_sites, 0, 100))
species <- matrix(0L, n_sites, n_species)
for (sp in seq_len(n_species)) {
cx <- runif(1, 10, 90)
cy <- runif(1, 10, 90)
lambda <- 5 * exp(-0.001 * ((coords$x - cx)^2 + (coords$y - cy)^2))
species[, sp] <- rpois(n_sites, lambda)
}
colnames(species) <- paste0("sp", seq_len(n_species))
pa <- (species > 0) * 1LSeparating turnover from nestedness
spaccBeta() orders the sites by nearest-neighbour distance from each starting site. At each step it compares the newly added site with the species accumulated so far and splits the Sørensen dissimilarity between them into turnover and nestedness, which sum to the total.
beta <- spaccBeta(pa, coords, n_seeds = 20, progress = FALSE)
beta
#> spacc beta diversity: 60 sites, 20 seeds
#> Index: sorensen, Method: knn
#> Mean final beta: 0.608 (turnover: 0.000, nestedness: 0.608)
plot(beta)as.data.frame() gives the mean and standard deviation
over the seeds at each step; the rows below are steps 1, 5, 10, 20, 30
and 59.
beta_df <- as.data.frame(beta)
beta_df[c(1, 5, 10, 20, 30, 59), 1:4]
#> sites beta_total beta_turnover beta_nestedness
#> 1 1 0.2283959 0.145112585 0.08328333
#> 5 5 0.1721366 0.054651915 0.11748468
#> 10 10 0.2518886 0.014432751 0.23745582
#> 20 20 0.3328397 0.004272727 0.32856702
#> 30 30 0.3931817 0.000000000 0.39318169
#> 59 59 0.6083405 0.000000000 0.60834052At the first step the new site is compared with a single neighbour, and turnover is the larger part (0.15 of 0.23). As the walk proceeds the accumulated set approaches all 30 species, so a new site can bring few species it has not seen, and turnover falls to zero by step 30. The total then grows as nestedness: a site with 15 of the 30 species is a subset of the accumulated set, with a Sørensen dissimilarity of \(15 / 45 = 0.33\). The rise of nestedness late in the curve measures how species-poor single sites are against the region.
Comparing sites with pooled assemblages
The partition depends on the resolution at which assemblages are
compared (Jones et al. 2025). pool
takes one value per site, such as habitat type or region, and repeats
the partition between the pooled assemblages along the same orders. A
species is present in a pool if it occurs in any of its sites. Here the
sites fall into three bands from west to east.
band <- cut(coords$x, breaks = c(-Inf, 33, 66, Inf),
labels = c("west", "centre", "east"))
table(band)
#> band
#> west centre east
#> 21 18 21
beta_pool <- spaccBeta(pa, coords, n_seeds = 20, progress = FALSE,
pool = band)
beta_pool
#> spacc beta diversity: 60 sites, 20 seeds
#> Index: sorensen, Method: knn
#> Mean final beta: 0.569 (turnover: 0.000, nestedness: 0.569)
#> Mean final beta, 3 pools: 0.044 (turnover: 0.000, nestedness: 0.044)
plot(beta_pool, resolution = "both")Each site order becomes the order in which its pools are first
reached, so three pools give two steps, and the distance between two
pools is the mean distance between their sites.
summary(beta_pool, resolution = "pooled") returns the
pooled partition as a table.
summary(beta_pool, resolution = "pooled")[, c("step", "beta_total",
"beta_turnover")]
#> step beta_total beta_turnover
#> 1 1 0.04355717 0
#> 2 2 0.04355717 0Single sites differ strongly from the accumulated set (final beta 0.57), while the three bands are nearly alike (0.04), because each band of about 20 sites contains almost every species. With pools that stand for habitats, the same comparison shows, for example, degraded habitats homogenised at the pool level while their individual sites still differ.
Counting distinct communities with Hill numbers
spaccHillBeta() computes, at each step and for each order \(q\), the gamma diversity of the accumulated sites, their alpha diversity and the ratio beta = gamma / alpha. Beta is then an effective number of distinct communities, between 1 and the number of sites accumulated, instead of a dissimilarity between 0 and 1.
hb <- spaccHillBeta(species, coords, q = c(0, 1, 2),
n_seeds = 15, progress = FALSE)
hb
#> spacc Hill beta diversity: 60 sites, 30 species, 15 seeds
#> Orders (q): 0, 1, 2
#> q = 0: mean final beta = 1.99
#> q = 1: mean final beta = 2.56
#> q = 2: mean final beta = 3.24
plot(hb, component = "beta")Beta rises as sites accumulate, and here it rises fastest at \(q = 2\), to 3.24 at 60 sites against 1.99 at \(q = 0\). Each site is dominated by the species centred nearby while the pooled community is nearly even, so alpha falls with \(q\) faster than gamma (Accumulating Hill numbers and partitioning diversity shows both evenness values). The two partitions answer different questions: Baselga’s asks whether the dissimilarity comes from replacement or from loss, Hill beta asks how many distinct communities the accumulated sites are worth. Report both when the distinction matters.
Removing the sampling effect
Part of the rise in Hill beta is a sampling effect. Each site is an incomplete sample, so the alpha of a few sites and the gamma of their pool are estimated at different completeness, and their ratio grows with the number of sites even where composition does not change (Chao et al. 2023). The data below have no turnover by construction: 60 sites all draw Poisson counts of the same 80 species from the same log-normal mean abundances, so the true beta is 1 at every step.
set.seed(42)
lambda <- rlnorm(80, -0.5, 1.3)
homog <- matrix(rpois(60 * 80, rep(lambda, each = 60)), nrow = 60)
homog_xy <- data.frame(x = runif(60, 0, 100), y = runif(60, 0, 100))
hb_obs <- spaccHillBeta(homog, homog_xy, n_seeds = 15,
progress = FALSE, seed = 1)
hb_std <- spaccHillBeta(homog, homog_xy, n_seeds = 15,
progress = FALSE, seed = 1,
standardize = "coverage")The table compares the mean \(q = 0\) beta of the two runs after 2, 10, 30 and 60 sites.
at <- c(2, 10, 30, 60)
drift <- rbind(observed = colMeans(hb_obs$beta$q0)[at],
standardised = colMeans(hb_std$beta$q0)[at])
colnames(drift) <- paste(at, "sites")
round(drift, 2)
#> 2 sites 10 sites 30 sites 60 sites
#> observed 1.33 1.77 1.84 1.91
#> standardised 1.05 1.02 1.02 1.02The observed beta climbs from 1.33 at two sites to 1.91 at sixty,
while the standardised beta stays between 1.02 and 1.05. With
standardize = "coverage", gamma and alpha are both brought
to the same sample coverage before their ratio is taken (the
iNEXT.beta3D standardisation). By default that coverage is, at each
step, the lower of the two observed coverages; a fixed
coverage = 0.9, for example, puts every step and every
dataset on the same completeness. The standardised result also carries
the four dissimilarities of Chao et al. (2023), which
plot(hb_std, component = "1-CqN") shows for the
Sørensen-type one.
Partitioning trait volume and branch length
Replacing a species with one of near-identical traits changes the
species list but hardly the functions the community performs. Passing
traits to spaccBeta() runs the same partition
on the trait space the assemblages fill (Villéger et al. 2013): in place
of the species the accumulated set and the new site share, it takes the
volume of trait space they share, and in place of the species found on
one side only, the volume each fills alone. The volume of an assemblage
is its functional richness as spaccFunc() computes it, the box
spanned by the ranges of its species on each trait. The traits here are
two simulated continuous variables, one row per species.
set.seed(1)
traits <- data.frame(body_size = rnorm(n_species),
wing_length = rnorm(n_species))
rownames(traits) <- colnames(species)
beta_func <- spaccBeta(pa, coords, traits = traits,
n_seeds = 20, progress = FALSE, seed = 1)
as.data.frame(beta_func)[c(1, 5, 10, 20, 30, 59), 1:4]
#> sites beta_total beta_turnover beta_nestedness
#> 1 1 0.1821135 0.03772214 0.1443914
#> 5 5 0.1917556 0.01447917 0.1772764
#> 10 10 0.1876868 0.00000000 0.1876868
#> 20 20 0.1204621 0.00000000 0.1204621
#> 30 30 0.1719717 0.00000000 0.1719717
#> 59 59 0.4102554 0.00000000 0.4102554
plot(beta_func)Functional turnover is small from the start, 0.04 of a total of 0.18 at the first step against 0.15 of 0.23 for species, and is zero by step 10, where species turnover is still 0.01. The traits are drawn independently of where the species live, so a few sites already hold species near the extremes of both traits, and the box of a new site then lies inside the box of the accumulated set. What remains is nestedness: a single site fills less of the trait space than the region, and the total reaches 0.41 at the last step.
Passing tree runs the partition on branch length
(Leprieur et al. 2012): the branches of the tree the two assemblages
share, and the branches each holds alone. An assemblage holds every
branch between one of its species and the root, so two close relatives
share most of their branches and swapping one for the other counts for
less than swapping distant lineages. The tree needs branch lengths and a
root. The one here is a random coalescent tree from ape with one tip per
species.
set.seed(2)
tree <- ape::rcoal(n_species, tip.label = colnames(species))
beta_phylo <- spaccBeta(pa, coords, tree = tree,
n_seeds = 20, progress = FALSE, seed = 1)
as.data.frame(beta_phylo)[c(1, 5, 10, 20, 30, 59), 1:4]
#> sites beta_total beta_turnover beta_nestedness
#> 1 1 0.1240047 5.373773e-02 0.07026697
#> 5 5 0.1366524 1.828080e-02 0.11837155
#> 10 10 0.1319166 2.888996e-03 0.12902761
#> 20 20 0.1223806 5.336259e-05 0.12232722
#> 30 30 0.1359317 0.000000e+00 0.13593168
#> 59 59 0.2817790 0.000000e+00 0.28177900
plot(beta_phylo)The last step of each variant puts their levels side by side.
last_step <- function(b) tail(as.data.frame(b), 1)[, 2:4]
rbind(taxonomic = last_step(beta),
functional = last_step(beta_func),
phylogenetic = last_step(beta_phylo))
#> beta_total beta_turnover beta_nestedness
#> taxonomic 0.6083405 0 0.6083405
#> functional 0.4102554 0 0.4102554
#> phylogenetic 0.2817790 0 0.2817790The three variants share one scale, from 0 for two assemblages with the same species, trait volume or branches to 1 for two with none in common. At the last step all three are nestedness, 0.61 for species, 0.41 for trait volume and 0.28 for branch length: the last site holds about a quarter of the regional species, which fill about 40% of the regional trait volume and hold more than half of the branch length of the tree, because the branches near the root are shared by many species. Phylogenetic beta is below taxonomic beta at every step shown for the same reason. Turnover that registers taxonomically but barely functionally or phylogenetically suggests the region swaps species that are ecologically and evolutionarily interchangeable; turnover on all three suggests it replaces distinct lineages with distinct ecological roles, as expected at a biogeographic boundary.
How the partitions are computed
At each step spaccBeta() compares the accumulated set
with the new site. Let \(a\) be the
number of species in both, \(b\) the
number only in the accumulated set and \(c\) the number only in the new site.
Following Baselga (2010), the Sørensen dissimilarity and its turnover
part are
\[ \beta_{\text{sor}} = \frac{b + c}{2a + b + c}, \qquad \beta_{\text{sim}} = \frac{\min(b, c)}{a + \min(b, c)}, \]
and nestedness is the difference \(\beta_{\text{sor}} - \beta_{\text{sim}}\).
With index = "jaccard" the total is \((b + c)/(a + b + c)\) and the turnover part
\(2\min(b, c)/(a + 2\min(b, c))\)
(Baselga 2012). Turnover is zero when the new site holds no species
absent from the accumulated set (\(c =
0\)), so a site that is a subset of what came before contributes
only nestedness.
With tree, \(a\), \(b\) and \(c\) are branch lengths (Leprieur et
al. 2012). Let \(PD(X)\) be the summed
length of the branches between the species of \(X\) and the root. For the accumulated set
\(A\) and the new site \(B\), \(a = PD(A)
+ PD(B) - PD(A \cup B)\) is the length they share, \(b = PD(A \cup B) - PD(B)\) and \(c = PD(A \cup B) - PD(A)\). The Sørensen
total is then one minus the PhyloSor similarity of Bryant et al. (2008),
and the values equal those of betapart::phylo.beta.pair()
for the same two assemblages. A star tree with equal branch lengths
gives the taxonomic partition.
With traits, \(a\),
\(b\) and \(c\) are volumes of trait space (Villéger et
al. 2013). The volume \(V(X)\) of an
assemblage is the product of the ranges of its species on each trait,
and 0 unless it has more species than there are traits. The volume two
assemblages share is the product of the overlaps of their ranges, trait
by trait, so \(a = V(A \cap B)\), \(b = V(A) - a\) and \(c = V(B) - a\). Villéger et al. (2013) and
betapart::functional.beta.pair() use the convex hull of the
species in trait space, which the box contains. The two agree for a
single trait and wherever the hulls are boxes; otherwise the box counts
the corners of trait space that no species occupies as filled. On the
example of functional.beta.pair(), whose community D has a
hull that is not a box, the Sørensen totals of the pairs with D are
0.85, 0.14 and 0.75 from boxes against 0.83, 0.40 and 0.74 from
hulls.
spaccHillBeta() uses the decomposition of Jost (2007).
At step \(k\), gamma is the Hill number
of the \(k\) accumulated sites pooled,
alpha is the power mean of their per-site Hill numbers, and beta = gamma
/ alpha. Beta is 1 when all \(k\) sites
are identical and \(k\) when no two
share a species. With standardize = "coverage", gamma is
the Hill number of the pooled sample and alpha that of the joint sample
(every species-by-site cell a unit) divided by \(k\), both rarefied or extrapolated to the
same coverage with the estimators of Chao et al. (2014). For \(q = 0\), Chao et al. (2023) advise against
extrapolating beyond the coverage of twice the sample size. The four
dissimilarities 1-CqN (Sørensen-type), 1-UqN
(Jaccard-type), 1-VqN and 1-SqN lie between 0
and 1 and are NA at the first step, where there is one
site.
Practical guidance
Input. spaccBeta() works on
presence/absence by design; abundances are converted to presence.
spaccHillBeta() needs counts for every order above 0, and
integer counts for standardize = "coverage".
Which partition to report. Baselga’s partition for the question of replacement against loss; Hill beta for the number of distinct communities. Compare observed Hill beta between datasets or along a curve only after coverage standardisation, because the observed ratio drifts upwards with the number of sites even without turnover, as the example above shows.
Number of seeds and sites. Use at least 50 seeds for reporting and 100 or more when the band itself is the result; this article uses 15 to 20 to keep the build fast. Read turnover only with 30 or more sites; beta from fewer than about 5 sites rests on very few comparisons.
Traits and trees. A site needs more species than
there are traits to have a volume, so keep the number of traits well
below the species count of single sites; a site without volume scores a
total of 1 against an accumulated set that has one, all of it
nestedness. Traits may be on different scales, since a ratio of box
volumes does not change when a trait is rescaled. A phylogenetic
partition needs a rooted tree with branch lengths that covers every
species in the matrix; tips are matched to the column names of
x. A matrix of pairwise distances is accepted in place of
the tree when it is ultrametric, as the tip distances of a dated tree
are.
When not to use these. map = TRUE,
which runs every site as a starting site and maps the partition at step
map_k (the first map_k - 1 sites accumulated
from it against the next one), is available for taxonomic beta only. The
box around an assemblage is larger than its convex hull when traits are
correlated, so with strongly correlated traits the functional partition
overstates the shared volume; reduce them to uncorrelated axes first, or
compute hull-based values for pairs of sites with betapart.
| Question | Function | Input | Result |
|---|---|---|---|
| Is turnover replacement or species loss | spaccBeta() |
presence/absence | turnover, nestedness |
| Does the partition change between sites and groups of sites | spaccBeta(pool = ) |
presence/absence + grouping | both partitions |
| How many distinct communities | spaccHillBeta() |
abundance | beta per order |
| Same, free of the sampling effect | spaccHillBeta(standardize = "coverage") |
integer abundance | standardised beta, dissimilarities |
| Does turnover involve distinct traits or lineages |
spaccBeta(traits = ),
spaccBeta(tree = )
|
presence/absence + traits or tree | partition of trait volume or branch length |
Where next
Accumulating Hill numbers and partitioning diversity splits the diversity of all sites into alpha and beta at once.
Accumulating phylogenetic and functional diversity measures the diversity of the accumulated community itself on a tree or in trait space.
Measuring distance decay and zeta diversity relates turnover to the distance between sites.
References
- Baselga, A. (2010). Partitioning the turnover and nestedness components of beta diversity. Global Ecology and Biogeography, 19, 134-143.
- Baselga, A. (2012). The relationship between species replacement, dissimilarity derived from nestedness, and nestedness. Global Ecology and Biogeography, 21, 1223-1232.
- Bryant, J.A., Lamanna, C., Morlon, H., Kerkhoff, A.J., Enquist, B.J., et al. (2008). Microbes on mountainsides: contrasting elevational patterns of bacterial and plant diversity. Proceedings of the National Academy of Sciences of the United States of America, 105, 11505-11511.
- Chao, A., Gotelli, N.J., Hsieh, T.C., et al. (2014). Rarefaction and extrapolation with Hill numbers: a framework for sampling and estimation in species diversity studies. Ecological Monographs, 84, 45-67.
- Chao, A., Thorn, S., Chiu, C.-H., et al. (2023). Rarefaction and extrapolation with beta diversity under a framework of Hill numbers: the iNEXT.beta3D standardization. Ecological Monographs, 93, e1588. https://doi.org/10.1002/ecm.1588
- 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. https://doi.org/10.1111/ddi.70080
- Jost, L. (2007). Partitioning diversity into independent alpha and beta components. Ecology, 88, 2427-2439.
- Leprieur, F., Albouy, C., De Bortoli, J., Cowman, P.F., Bellwood, D.R., et al. (2012). Quantifying phylogenetic beta diversity: distinguishing between “true” turnover of lineages and phylogenetic diversity gradients. PLoS ONE, 7, e42760. https://doi.org/10.1371/journal.pone.0042760
- Villéger, S., Grenouillet, G. & Brosse, S. (2013). Decomposing functional beta-diversity reveals that low functional beta-diversity is driven by low functional turnover in European fish assemblages. Global Ecology and Biogeography, 22, 671-681.