| Title: | Multi-Layer Characterization of Functional Community Restructuring |
| Version: | 0.5.1 |
| Description: | Implements the 'ASC-CFD' (Assemblage Shift Characterization - Community Functional Dynamics) framework for characterizing functional community restructuring through positional (centroid displacement), dispersive (functional dispersion), and boundary (convex hull volume) components. Tests each component against two null models: a sampling null model (individuals or replicates reassigned between communities, optionally only within blocks of matched samples) and a stratified trait-permutation null model, with a single global test when many communities are compared. Species-level leverage identifies the taxa driving functional shifts, and functional entities (species with similar traits) allow an exploratory look at replacement among similar species. Supports both temporal (paired) and spatial (pairwise) comparisons. |
| Depends: | R (≥ 2.10) |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.3 |
| Imports: | cluster, ggplot2, stats, utils, geometry, withr |
| Suggests: | knitr, patchwork, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| URL: | https://github.com/V3ndetta96/ascent |
| BugReports: | https://github.com/V3ndetta96/ascent/issues |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-11-29 23:23:57 UTC; Usuario |
| Author: | Rogelio R. Muñoz-Li [aut, cre], Flavia Alvarez-Denis [aut] |
| Maintainer: | Rogelio R. Muñoz-Li <munozrogelio16@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-29 23:40:02 UTC |
ascent: Multi-Layer Characterization of Functional Community Restructuring
Description
ascent implements the ASC-CFD framework (Assemblage Shift
Characterization - Community Functional Dynamics). It characterizes the
change in the functional structure of a community through three layers
measured in a functional space (a PCoA of Gower distances between species
traits): position (shift of the abundance-weighted centroid), dispersion
(FDis) and volume (FRic). Each layer is tested against two null models: A
(sampling: is the change larger than sampling noise?) and B (traits,
stratified by abundance: is the change directed by the species' traits?).
Workflow
-
assess_functional_space: check the functional space built from the traits (number of axes and quality). Describe the design.
asc_paired: a reference state against a comparison state at each site, with replicate samples if available and, if both states were sampled in matched units (the same months, plots), those units asblocks.asc_pairwise: many communities (a gradient, a series).-
asc_null: test each layer against A and B (one global test per layer forasc_pairwise()objects), thensummary()for a reading of each test, the permutation used and the trait that moved most. -
asc_transitions: which species moved the centroid (leverage), and how much of the shift comes from shared, gained or lost species.plot()draws the shift and the leverages. Optional, exploratory:
asc_entitiesgroups species with similar traits, to look at replacement among similar species.
asc_baseline gives the metrics of each community without
contrasts. summary() and plot() work on every result.
Start with the tutorial: vignette("ascent_tutorial", package = "ascent").
The data set birds_sim is used in the tutorial and examples.
Author(s)
Maintainer: Rogelio R. Muñoz-Li munozrogelio16@gmail.com
Authors:
Flavia Alvarez-Denis
See Also
Useful links:
Functional Metrics of Each Community
Description
Calculates, for each community separately and without contrasts, the abundance-weighted centroid on each axis of the functional space (CWM), functional dispersion (FDis) and convex hull volume (FRic). Useful to describe the communities before comparing them.
Usage
asc_baseline(
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
and one column per species (matched to |
dist_method |
Distance metric for the trait matrix. Default is "gower". |
dim_retention |
Character. How many PCoA axes to keep: |
var_tol |
Numeric. Proportion of cumulative variance to retain when
|
na.rm |
Logical. Remove missing values? Default is TRUE. |
correction |
Character. |
type, weights |
Optional; passed unchanged to |
Value
An S3 object of class ascent_baseline (it also carries the
class ascfcd_base of ascent 0.5.0, which will be dropped in 0.6.0), a
list whose main element is entities_results (one row per community:
Entity, the CWM on each axis, FDis and FRic). Here
"Entity" means community (row of abund), not a functional entity
of asc_entities.
Examples
# Absolute metrics of each community (no contrasts): community-weighted
# position on each axis (CWM), dispersion (FDis) and volume (FRic)
base <- asc_baseline(birds_sim$traits, birds_sim$landscape)
summary(base)
# Compare FDis and FRic along the gradient from primary forest to farmland
base$entities_results[, c("Entity", "FDis", "FRic")]
Identify Functional Entities (Species Clustering)
Description
Groups species with similar traits into functional entities by hierarchical
clustering (Gower distance and Ward's method by default). If neither
k nor h is given, the number of entities is chosen as the one
with the highest mean silhouette width. The result can be passed to
asc_null (A on counts summed by entity) and
asc_transitions (displacement between vs within entities)
to explore whether species were replaced by functionally similar ones.
This use is exploratory: only replacement within an entity is seen
(similar species placed in different entities look like a change between
entities, so a negative result does not rule out redundancy), the signal
was weak in the validation except for strong compensation, and it depends
on the number of entities.
Usage
asc_entities(
traits,
dist_method = "gower",
hclust_method = "ward.D2",
k = NULL,
h = NULL,
k_max = 15,
B = 100,
seed = NULL,
correction = c("none", "sqrt"),
type = NULL,
weights = NULL
)
Arguments
traits |
A data frame or matrix of functional traits (row names = species). |
dist_method |
Character. Distance metric. Default is |
hclust_method |
Character. Agglomeration method. Default is |
k |
Integer. Number of entities. If |
h |
Numeric. Height at which to cut the dendrogram (alternative to |
k_max |
Integer. Largest |
B |
Integer. Number of reference data sets for the gap statistic. Default 100. |
seed |
Integer or |
correction, type, weights |
Passed to the trait distance; see
|
Details
Three criteria are computed for k = 2, ..., k_max on the same tree:
-
Mean silhouette width (Rousseeuw 1987), on the trait distance. Used to choose
kby default. Below 0.25: no clear groups; 0.25-0.5: weak structure. -
Mojena's rule: first fusion height above the mean plus 1.25 standard deviations of all fusion heights.
-
Gap statistic (Tibshirani et al. 2001), on the PCoA coordinates, with the
"Tibs2001SEmax"rule.k = 1means no natural groups: the entities then discretise a continuum, which is still useful, but conclusions should be checked with neighbouring values ofk.
In the validation (continuous traits of 42 butterfly species), very coarse
entities (k = 5, Mojena's choice there) classified part of a directed change
as "within entities", whereas the silhouette choice (k = 13) did not. Even
with k = 13, compensation between similar species was detected only when it
was strong, and not when the species fell in different entities. With discrete traits,
h = 0 gives entities in the strict sense (species sharing exactly the
same trait combination); this use has not been evaluated by simulation.
Value
An S3 object of class ascent_entities (it also carries the
class ascfcd_entities of ascent 0.5.0, which will be dropped in
0.6.0) with
membership (named vector: species -> entity, accepted by
asc_null() and asc_transitions()), k,
entity_classification (species, entity and traits),
indices (silhouette and gap by k), suggestions
(k by silhouette, Mojena and gap), silhouette_max,
n_species_per_entity, distance_matrix, hclust_obj,
method and metric.
References
Rousseeuw, P. J. (1987). Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics, 20, 53-65.
Tibshirani, R., Walther, G. & Hastie, T. (2001). Estimating the number of clusters in a data set via the gap statistic. Journal of the Royal Statistical Society B, 63, 411-423.
Mojena, R. (1977). Hierarchical grouping methods and stopping rules: an evaluation. The Computer Journal, 20, 359-363.
Examples
# Group the 24 species of birds_sim by their traits
ent <- asc_entities(birds_sim$traits, k_max = 10, B = 50, seed = 1)
# Suggested number of entities (silhouette, Mojena, gap) and their sizes
summary(ent)
# Is the change at "Logged" a reorganisation of the functional groups
# (shift between entities) or a replacement among similar species (within)?
res <- asc_paired(birds_sim$traits, birds_sim$counts,
sites = birds_sim$samples$site,
time = birds_sim$samples$time, ref_time = "Before")
asc_transitions(res, entities = ent)$Logged$entities
Null Models for Multi-Layer Functional Shifts
Description
Tests each ASC-CFD layer (position, dispersion, volume) against two
complementary null models, and dispatches on the class of x:
objects from
asc_paired(classascent_paired) get one set of tests per contrast (reference vs comparison);objects from
asc_pairwise(classascent_pairwise) get a single global test over all communities at once (no p-value per pair).
The letters differ from version 0.1.x: A is now the sampling null model and B the stratified trait null model. The 0.1.x models (Curveball, SAD reshuffle and trait shuffle), written A0, B0 and C0 since 0.5.0, were removed.
Usage
asc_null(
x,
n_perm = 999,
seed = NULL,
stratum_size = 5,
entities = NULL,
two_sided = c("centred", "doubled"),
p_adjust = "BH"
)
Arguments
x |
An object of class |
n_perm |
Integer. Number of permutations. Default is 999. When the
number of possible allocations of samples is at most |
seed |
Integer or |
stratum_size |
Integer. Number of species per abundance stratum in null model B. Default 5 (the validated value). Strata group species of similar abundance; larger values approach the unstratified permutation. |
entities |
Optional. An object from |
two_sided |
Character. Convention for the two-tailed p-value of
dispersion and volume (see Two-tailed p-values): |
p_adjust |
Character. Method used to adjust the p-values of the three
layers within each contrast and test (see Multiple testing). One of
|
Value
The input object with null_models appended: a data frame
with one row per contrast, test and layer, and columns Contrast,
Test, Layer, Observed, Null_mean,
Null_sd, SES, P_upper, P_lower and
P_two (two-tailed, with the convention set by two_sided),
and P_adj
(the p-value used for interpretation, adjusted with p_adjust).
P-values are (b + 1)/(n + 1) and are not rounded. For B, the row
of position refers to the axis-standardised statistic (Observed,
Null_mean, Null_sd, SES and the p-values).
b_position_norm gives B for position with the statistic of 0.5.0
(||\Delta C||, or the mean distance to the common centroid in the
global test), one row per contrast. trait_shifts (see Which trait
changed) gives, per contrast, Trait, Type ("numeric"
or "level"), Delta and Std_shift, ordered by
|Std_shift|; in the
global test Delta is the standard deviation among communities of
the weighted mean of the trait and Std_shift its variance relative
to the null mean. For pairwise
objects, site_contribution is also appended. null_settings
records the options used and, in permutation, how samples were
permuted for A in each contrast (design, number of blocks, number of
possible allocations, exact enumeration or not, and the smallest
attainable p-value for position). Use summary() for a reading of
each test.
Null model A (sampling)
H0: the communities are samples of the same community. Individuals are
pooled and reassigned at random keeping sample sizes. When both states of
a contrast have replicates, whole replicates are permuted instead (A by
samples), which accounts for variation among replicates (individuals that
are captured in groups inflate A by individuals). If the samples of both
states were taken in matched units (blocks in asc_paired),
samples are exchanged only within each block. A needs counts of
individuals; with relative abundances it is skipped with a warning.
Choosing the permutation for A
The permutation is chosen from the design described in
asc_paired; summary() reports which one was used.
-
One sample per state: A by individuals. It tests multinomial sampling error only; ordinary variation between samples (e.g. between two months of the same community) can look like a change. Use replicates whenever possible.
-
Replicates taken in matched units (both states sampled in the same months, plots or survey rounds): give that unit as
blocksinasc_paired(). Samples are exchanged between states only within each block, so effects shared by the samples of a block (weather of a month, a survey round) are removed from the test. Blocks do not correct temporal autocorrelation within the series of each state: in the validation, with month-to-month persistence like that of the butterfly data (rho = 0.28), A within blocks still gave 6-16\ pseudoreplication. -
Independent replicates (spaced in time or space, not matched): free permutation of whole samples (no
blocks). -
Consecutive replicates (e.g. consecutive months of each state, matched or not): they are not independent (pseudoreplicates). No permutation removes this dependence; A, like PERMANOVA and other tests that permute samples, becomes liberal (9.7-17\ validation). Space the samples in time or treat the p-values as indicative.
When the number of possible allocations of samples is at most
n_perm, all of them are enumerated (exact test). With
blocks, there are \prod_j \binom{n_j}{r_j} allocations
(n_j samples in block j, r_j of them in the reference
state); with one sample of each state per block, 2^{B} for
B blocks. Ask for n_perm at least that large to enumerate them.
Few blocks give few allocations: with four matched pairs there are 16, and
the smallest attainable p-value for position is 0.125, so the test cannot
reject at alpha = 0.05 (a warning is given).
Null model B (traits, stratified)
H0: the shift does not depend on which traits the species have. Abundances
are kept and species coordinates are permuted only among species of similar
abundance (groups of stratum_size species ranked by mean abundance).
Stratification calibrates the test in empirical trait spaces; it does not
add power. stratum_size = Inf gives the unstratified permutation
among the species present, which was biased in empirical trait spaces and
is not recommended; values near 5 (e.g. 3 to 10) can be used to check that
conclusions do not depend on the stratum size.
B is read from its upper tail: the shift is larger than expected if traits were unrelated to the change in abundances, i.e. the change is directed by traits. Read B where A detects a change. The lower tail (a shift smaller than expected from the traits) is reported for description only: it had little power to detect compensation in the validation.
For position, the statistic of B is axis-standardised: the shift of the
centroid along each axis is divided by its standard deviation under the
null and the squares are summed over axes (\sum_k (v_k / s_k)^2,
about the number of axes when there is no change). Each axis counts in
units of its own chance variation, so a change along a minor axis (a trait
unrelated to the first axis) is detected as well as one along the first
axis. With the length of the shift, ||\Delta C|| (the statistic up
to 0.5.0), the first axis dominated and changes in minor traits were rarely
detected; the price of the new statistic is somewhat less power when the
change lies along the first axis. B with ||\Delta C||, from the same
permutations, is kept in b_position_norm; with the same seed the
permutations are those of 0.5.0.
In the validation, B was slightly liberal for dispersion (6.5\ positives at alpha = 0.05), when individuals are captured in groups (7.2\ changes (about 7-8\ 0.05 with caution.
Which trait changed
The same permutations of B give, for each trait, the change of its
abundance-weighted mean, returned in trait_shifts; summary()
names the trait with the largest standardised shift. Numeric traits are
used as they are (Delta in the units of the trait). Each level of a
categorical trait (factor, character or logical) is used as a 0/1
indicator, named "trait = level" (only the second level when there are two),
so its Delta is the change in the share of abundance of species with
that level. Std_shift is the shift in null standard deviations:
values of about 1 or less are within chance variation. This describes which
trait moved most; it is not a test (no p-value is given: in the validation,
with numeric traits, its maximum was liberal under changes not related to
traits, and it has not been evaluated with categorical traits). Traits that
are correlated move together, so it points to a group of related traits,
not necessarily to the trait that caused the change. Missing values are set
to the mean of the trait.
Entities
With entities (from asc_entities or a named vector
assigning each species to an entity), A is repeated on counts summed by
entity. This is exploratory. "A significant for species but not for
entities", together with a large fraction of the shift occurring within
entities (asc_transitions), is consistent with replacement
among functionally similar species. Only replacement within an entity is
seen: similar species placed in different entities look like a change
between entities, so a negative result does not rule out redundancy. In
the validation the signal was weak except for strong compensation, and it
depends on the number of entities; check neighbouring values of k.
Global test (pairwise objects)
With many communities, one test per pair would multiply false alarms, so
asc_null() runs one global test per layer over all communities.
Statistics: the mean distance of the community centroids to their common
centroid (position), and the standard deviation among communities of FDis
(dispersion) and FRic (volume). A global reassigns individuals among
communities; B global applies one stratified trait permutation to all
communities. All layers are read from the upper tail. A: the communities
differ more than samples of one community would. B: the variation among
communities is organised by traits. The lower tail of B is reported for
description only. For position, B global uses the axis-standardised
statistic: the variance of the community centroids along each axis divided
by its mean under the null, summed over axes (with two communities it is
equivalent to the paired statistic); B with the mean distance (as in 0.5.0)
is kept in b_position_norm. The distance of each community to the
common centroid is returned as a descriptive contribution
(site_contribution).
Multiple testing
Each test (A, B, A by entities, and each global test) evaluates three
layers, so P_adj adjusts, within each contrast and test, the three
p-values used for interpretation: the upper tail for position (and for all
layers of the global test) and the two-tailed value for dispersion and
volume. The method is chosen with p_adjust (any method of
p.adjust; default Benjamini-Hochberg). Contrasts are
not adjusted against each other; to do so, apply
p.adjust to the column of p-values of interest in
null_models. The lower tail is not adjusted.
Two-tailed p-values
Dispersion and volume can change in either direction, so they are read with
a two-tailed p-value, P_two. Two conventions are available
(argument two_sided):
-
"centred"(default, as in 0.5.0): the proportion of null values at least as far from the null mean as the observed value. -
"doubled": twice the smaller tail,pmin(1, 2 * pmin(P_upper, P_lower)), which judges each direction against its own tail.
Both are valid; they coincide when the null distribution is symmetric and can differ when it is asymmetric, as is common for the volume (FRic). Both tails are always reported, so either convention can be computed from the table. Choose the convention before looking at the results.
References
Benjamini, Y., & Hochberg, Y. (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B, 57, 289-300.
Gower, J. C. (1971). A general coefficient of similarity and some of its properties. Biometrics, 27, 857-871.
Examples
# Paired contrasts (see ?birds_sim): five surveys per state at each site
res <- asc_paired(birds_sim$traits, birds_sim$counts,
sites = birds_sim$samples$site,
time = birds_sim$samples$time, ref_time = "Before")
res <- asc_null(res, n_perm = 199, seed = 1)
# The Reading column interprets each test. At "Logged", A (sampling) and
# B (traits) detect the shift in position: the change is real and directed
# by the species' traits. At "Control" there is no evidence of change.
summary(res)
# The full table (one row per contrast, test and layer)
res$null_models[res$null_models$Layer == "Position", ]
# Which trait moved most at each site (descriptive)
res$trait_shifts
# Matched samples: if the k-th survey of both states had been made in the
# same survey round, the rounds would be given as blocks. With only five
# matched pairs the smallest attainable p-value for position is 2/32, so
# asc_null() warns that A cannot reject at 0.05 (six pairs are the minimum)
round <- ave(seq_along(birds_sim$samples$site),
birds_sim$samples$site, birds_sim$samples$time, FUN = seq_along)
rb <- asc_paired(birds_sim$traits, birds_sim$counts,
sites = birds_sim$samples$site,
time = birds_sim$samples$time, ref_time = "Before",
blocks = round)
rb <- asc_null(rb, n_perm = 99, seed = 1)
rb$null_settings$permutation
# Many communities: one global test per layer instead of one p per pair
pw <- asc_pairwise(birds_sim$traits, birds_sim$landscape)
pw <- asc_null(pw, n_perm = 99, seed = 1)
summary(pw)
Paired Functional Restructuring (Reference vs Comparison State)
Description
Measures, at each site, the change between a reference state and a
comparison state (e.g. before and after an event) in three layers of the
functional space: position (shift of the abundance-weighted centroid,
\Delta C), dispersion (\DeltaFDis) and volume
(\DeltaFRic). Pass the result to asc_null to test each
layer, and to asc_transitions to see which species moved the
centroid.
Usage
asc_paired(
traits,
abund,
sites,
time,
ref_time,
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,
blocks = 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 sample and
one column per species (matched to |
sites |
A vector, one value per row of |
time |
A vector, one value per row of |
ref_time |
The value of |
dist_method |
Distance metric for the trait matrix. Default is "gower". |
dim_retention |
Character. How many PCoA axes to keep: |
var_tol |
Numeric. Proportion of cumulative variance to retain when
|
na.rm |
Logical. Remove missing values? Default is TRUE. |
correction |
Character. |
type, weights |
Optional; passed unchanged to |
blocks |
Optional vector, one value per row of |
Value
An S3 object of class ascent_paired (it also carries the
class ascfcd of ascent 0.5.0, which will be dropped in 0.6.0), a
list whose main elements are rDelta_C (centroid shift per contrast,
as a percentage of the largest distance between species in the functional
space), site_results (per contrast: abs_dist =
||\Delta C||, Delta_FDis, Delta_FRic,
Delta_FRic_rarefied, n_samples and the share of the shift
along each axis), F_space (species coordinates), k_retained
and dim_retention (number of axes and the rule used),
quality of the PCoA and the inputs needed by asc_null().
summary() gives a reading; plot() draws the shift.
Note
Normalization: Delta FDis and Delta FRic are absolute differences, not normalized by the regional pool. Values are not directly comparable across studies with different species pools or trait scales. Only rDelta_C (position) is normalized by Dmax_regional.
FRic = NA: When a community has fewer species than retained PCoA axes,
the convex hull is geometrically undefined and FRic is set to NA,
which propagates to Delta_FRic.
FRic and unequal replicates: with replicates, a species counts as
present in a state if it appears in any of its samples, so FRic grows with
the number of samples. When the two states of a contrast have different
numbers of samples, Delta_FRic_rarefied gives Delta FRic with the
same number of samples in both states: FRic of the state with more samples
is averaged over all subsets of the size of the other state (or over 200
random subsets, with a fixed internal seed, when there are more). Use it to
read the size of the volume change; the tests of asc_null
keep the numbers of samples and remain valid.
Replicates: When several rows share the same site and state (e.g. five
surveys before an event), their relative abundances are averaged (column
means) to describe the state, so the three layers compare the mean
community of each state. The variation among replicates is used by null
model A, which then permutes whole samples between the states (see
asc_null).
Examples
# birds_sim: two sites surveyed 5 times before and 5 times after an event.
# At "Logged" the bird community changes; at "Control" nothing changes.
# Check the functional space first (see ?assess_functional_space)
assess_functional_space(birds_sim$traits)
res <- asc_paired(birds_sim$traits, birds_sim$counts,
sites = birds_sim$samples$site,
time = birds_sim$samples$time, ref_time = "Before")
# Layer1_rDeltaC is the centroid shift (% of the functional space): it is
# large at "Logged" and small at "Control". The last section ("Top Functional
# Drivers") lists the species that moved the centroid most (see ?asc_transitions).
summary(res)
# Is each shift larger than sampling noise (A) and organised by traits (B)?
res <- asc_null(res, n_perm = 199, seed = 1)
summary(res)
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 |
dist_method |
Distance metric for the trait matrix. Default is "gower". |
dim_retention |
Character. How many PCoA axes to keep: |
var_tol |
Numeric. Proportion of cumulative variance to retain when
|
na.rm |
Logical. Remove missing values? Default is TRUE. |
correction |
Character. |
type, weights |
Optional; passed unchanged to |
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)
Functional Transitions: Species Leverage, Partition and Entities
Description
Describes who moved the functional centroid (no p-values; for tests
see asc_null):
-
Species leverage: contribution of each species to the centroid displacement (Layer 1). Leverages add up exactly to the displacement
||\Delta C||for any reference point. -
Partition: share of the displacement due to species shared by both states, gained (only in the comparison) and lost (only in the reference).
-
Entities (optional, exploratory): share of the displacement that occurs between functional entities (their total abundances change) and within entities (which species dominates inside each entity changes). The two parts add up exactly to the displacement. See
asc_entitiesfor its limits.
Usage
asc_transitions(
x,
ref = c("midpoint", "reference", "comparison"),
entities = NULL,
...
)
Arguments
x |
An object from |
ref |
Character. Reference point for the projections:
|
entities |
Optional. An object from |
... |
Further arguments passed to or from other methods. |
Details
Leverage of species i is \Delta p_i \, (F_i - r) \cdot u, where
u is the unit vector of the displacement and r the reference
point. The total does not depend on r, but how it is shared among
species (and among shared, gained and lost species) does. The default
ref = "midpoint" (half-way between the two centroids) is symmetric:
it gives the same partition whichever state is called the reference, which
matters for pairwise comparisons. The partition also reports its minimum
and maximum across the three reference points; a wide range means the
partition should be interpreted with caution.
Leverage keeps only the part of each species' contribution that lies along
the displacement. A species can change a lot in a direction perpendicular
to the displacement (and be compensated by other species) and still have a
small leverage. Orthogonal reports the size of that perpendicular
part, || \Delta p_i (F_i - r) - Leverage_i \, u ||, so that "small
leverage" is not read as "small change": a species with small leverage
and large Orthogonal changed in abundance, but along another
direction of the trait space.
In version 0.1.1 the reference point was the reference centroid
(ref = "reference"); per-species values differ from 0.1.1 unless
that option is used.
Value
An S3 object of class ascent_transitions (it also carries the
class ascfcd_transitions of ascent 0.5.0, which will be dropped in
0.6.0): a list with one
element per contrast (or pair), each containing species_leverage
(columns Species, Group, Delta_p, Projection,
Leverage, Orthogonal; species absent from both states are
omitted),
partition (columns Group, Fraction,
Min_across_refs, Max_across_refs), entities
(Shift, Between, Within, Within_fraction, or
NULL; descriptive: see asc_entities for its
limits), shift and ref.
Examples
res <- asc_paired(birds_sim$traits, birds_sim$counts,
sites = birds_sim$samples$site,
time = birds_sim$samples$time, ref_time = "Before")
tr <- asc_transitions(res)
# Species that moved the centroid at "Logged": positive leverage pushes it in
# the direction of the change, negative leverage resists it
head(tr$Logged$species_leverage)
# Leverages add up exactly to the shift
c(sum = sum(tr$Logged$species_leverage$Leverage), shift = tr$Logged$shift)
# Share of the shift due to species shared, gained or lost
tr$Logged$partition
Methods for objects created with ascent 0.5.0
Description
In ascent 0.5.0 the classes had other names (ascfcd,
ascfcd_pw, ascfcd_base, ascfcd_space,
ascfcd_entities and ascfcd_transitions). Since 0.5.1 they are
named after the function that creates each object (ascent_paired,
ascent_pairwise, ascent_baseline, ascent_space,
ascent_entities and ascent_transitions). These methods let
print(), summary() and plot() work with objects saved
with 0.5.0. They will be removed in 0.6.0: re-create old objects with the
current version.
Usage
## S3 method for class 'ascfcd'
print(x, ...)
## S3 method for class 'ascfcd'
summary(object, ...)
## S3 method for class 'ascfcd'
plot(x, ...)
## S3 method for class 'ascfcd_pw'
print(x, ...)
## S3 method for class 'ascfcd_pw'
summary(object, ...)
## S3 method for class 'ascfcd_pw'
plot(x, ...)
## S3 method for class 'ascfcd_base'
print(x, ...)
## S3 method for class 'ascfcd_base'
summary(object, ...)
## S3 method for class 'ascfcd_space'
print(x, ...)
## S3 method for class 'ascfcd_space'
summary(object, ...)
## S3 method for class 'ascfcd_entities'
print(x, ...)
## S3 method for class 'ascfcd_entities'
summary(object, ...)
## S3 method for class 'ascfcd_entities'
plot(x, ...)
## S3 method for class 'ascfcd_transitions'
print(x, ...)
## S3 method for class 'ascfcd_transitions'
summary(object, ...)
## S3 method for class 'ascfcd_transitions'
plot(x, ...)
Arguments
x, object |
An object created with ascent 0.5.0. |
... |
Passed to the method for the current class. |
Value
The same as the method for the current class.
Assess Functional Space Quality
Description
Diagnostic tool to evaluate the quality of the PCoA-based functional space
constructed from a trait matrix. Intended for use before running core
analyses (asc_paired, asc_pairwise, etc.) to identify
potential distortion from negative eigenvalues or excessive dimensionality
reduction.
Usage
assess_functional_space(
traits,
dist_method = "gower",
dim_retention = c("msd", "variance", "broken_stick"),
var_tol = 0.8,
correction = c("none", "sqrt"),
type = NULL,
weights = NULL
)
Arguments
traits |
A data frame or matrix of functional traits. |
dist_method |
Distance metric for the trait matrix. Default is |
dim_retention |
Character. Method for choosing the number of axes:
|
var_tol |
Numeric. Proportion of cumulative variance to retain (used
when |
correction |
Character. |
type, weights |
Optional; passed unchanged to |
Details
All functions of the package build the same functional space: a PCoA of
the distances between species traits (Gower by default), keeping the
number of axes given by dim_retention. This function shows that
space before any analysis, with two diagnostics:
-
Number of axes. By default (
"msd") the number of axes, from 2 to 10, whose Euclidean distances best reproduce the trait distances (lowest mSD, Maire et al. 2015). The tablemsdshows the fidelity for each number of axes. More axes describe the traits better, but FRic can only be computed in communities with more species than axes. -
Quality. The Gower distance is not strictly Euclidean, so the PCoA can give negative eigenvalues. The quality index is the share of positive eigenvalues; below 0.80, negative eigenvalues represent more than 20\ (traits with many missing values, redundant or badly coded traits).
correction = "sqrt"(square root of the Gower dissimilarity, Euclidean for complete data with constant weights, Gower 1971) removes the negative eigenvalues, but it changes the distances between species, so results with and without it are not comparable, and its effect on the null-model tests has not been evaluated by simulation.
Value
A list of class ascent_space (it also carries the class
ascfcd_space of ascent 0.5.0, which will be dropped in 0.6.0) with:
- quality
Numeric. PCoA quality index (
sum(positive_eig) / sum(abs(all_eig))). Values above 0.80 are generally acceptable.- n_species
Integer. Number of species in the trait matrix.
- n_traits
Integer. Number of traits.
- k_retained
Integer. Number of PCoA axes retained.
- dim_retention
Character. Rule used to choose them.
- var_retained
Numeric. Cumulative variance explained by retained axes.
- axis_var
Numeric vector. Relative variance per retained axis.
- n_neg_eigenvalues
Integer. Count of negative eigenvalues.
- neg_eigenvalue_pct
Numeric. Percentage of total absolute eigenvalue represented by negative eigenvalues.
- eigenvalues
Numeric vector. All raw eigenvalues from PCoA.
- msd
Data frame. For k = 1 to 10 axes, the mean squared deviation (mSD) between the trait distances and the Euclidean distances in the first k axes (both scaled to a maximum of 1) and their Pearson correlation (Maire et al. 2015). Lower mSD = more faithful space.
References
Maire, E., Grenouillet, G., Brosse, S., & Villeger, S. (2015). How many dimensions are needed to accurately assess functional diversity? A pragmatic approach for assessing the quality of functional spaces. Global Ecology and Biogeography, 24, 728-740.
Examples
# Check the functional space before any analysis
q <- assess_functional_space(birds_sim$traits)
# Number of axes kept (rule: mSD) and quality (>= 0.8 is adequate). FRic can
# only be computed in samples with more species than retained axes.
q
# Fidelity of the space for 1 to 10 axes (lower mSD = more faithful)
summary(q)
Simulated Bird Communities
Description
Simulated data used in the vignette and examples: functional traits of 24
bird species and counts of individuals in a paired design (with replicate
surveys) and along a landscape gradient. Generated by
data-raw/birds_sim.R.
Usage
birds_sim
Format
A list with four elements:
- traits
Data frame, 24 species (row names) x 4 traits:
Body_Mass(g),Beak_Length(mm),Diet(factor: insects, fruit, seeds) andForest_Dep(factor: no, yes).- counts
Integer matrix, 20 surveys x 24 species. Two sites ("Logged", "Control"), each surveyed 5 times before and 5 times after an event. At "Logged", forest-dependent and fruit-eating species decline and small open-habitat species increase; at "Control" nothing changes.
- samples
Data frame describing the rows of
counts:id,siteandtime("Before", "After").- landscape
Integer matrix, 5 communities (primary forest to farmland) x 24 species, one survey each.
Source
Simulated; see data-raw/birds_sim.R in the package sources.
Examples
str(birds_sim, max.level = 1)
Plot Functional Entities Dendrogram
Description
Plots the hierarchical clustering dendrogram of the functional entities.
Usage
## S3 method for class 'ascent_entities'
plot(x, ...)
Arguments
x |
An object of class |
... |
Additional graphical arguments passed to |
Value
No return value, called for side effects (plots a dendrogram).
Plot Multidimensional Functional Restructuring
Description
Visualizes the functional trajectory (Centroid shift) and volume shift (Convex Hull) of a specific site/contrast in the PCoA space, alongside the species leverage.
Usage
## S3 method for class 'ascent_paired'
plot(x, contrast, type = c("both", "pcoa", "leverage"), n_sp = 10, ...)
Arguments
x |
An object of class |
contrast |
Character. The exact name of the site/contrast to plot. |
type |
Character. What to plot? |
n_sp |
Integer. Number of top species to display in the leverage plot. Default is 10. |
... |
Additional graphical arguments. |
Value
A ggplot object (or patchwork object if type = "both").
Plot Pairwise Functional Spatial Divergence
Description
Visualizes spatial functional restructuring (Centroid & Hull) between two communities.
Usage
## S3 method for class 'ascent_pairwise'
plot(x, contrast, type = c("both", "pcoa", "leverage"), n_sp = 10, ...)
Arguments
x |
An object of class |
contrast |
Character. The contrast to plot (e.g., "SiteA_vs_SiteB"). |
type |
Character. What to plot? |
n_sp |
Integer. Number of top species to display. Default is 10. |
... |
Additional graphical arguments. |
Value
A ggplot object.
Plot Functional Leverage
Description
Visualizes the top species driving functional centroid displacement.
Usage
## S3 method for class 'ascent_transitions'
plot(x, contrast, n_sp = 10, ...)
Arguments
x |
An object of class |
contrast |
Character. The contrast to plot. |
n_sp |
Integer. Number of top species to display. Default is 10. |
... |
Additional graphical arguments. |
Value
A ggplot object.
Summary for Baseline Functional Entities
Description
Provides an overview of the baseline functional topology of the evaluated entities.
Usage
## S3 method for class 'ascent_baseline'
summary(object, ...)
Arguments
object |
An object of class |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns the entities results data frame.
Summary for Functional Entities Classification
Description
Provides an overview of the species clustering into functional entities.
Usage
## S3 method for class 'ascent_entities'
summary(object, ...)
Arguments
object |
An object of class |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns the classification data frame.
Summary for Paired Functional Centroid Displacement
Description
Provides a concise, multi-layer overview of the paired ASC-CFD analysis, including null models and top functional drivers.
Usage
## S3 method for class 'ascent_paired'
summary(object, ...)
Arguments
object |
An object of class |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns a data frame with the displacement metrics.
Summary for Pairwise Functional Spatial Divergence
Description
Provides a comprehensive overview of the spatial network ASC-CFD analysis.
Usage
## S3 method for class 'ascent_pairwise'
summary(object, ...)
Arguments
object |
An object of class |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns the pairwise results data frame.
Summary for Functional Transitions
Description
For each contrast, shows the species with the largest leverage, the partition of the centroid displacement among shared, gained and lost species (with its range across reference points) and, if entities were given, the split between and within entities.
Usage
## S3 method for class 'ascent_transitions'
summary(object, n_sp = 5, ...)
Arguments
object |
An object of class |
n_sp |
Integer. Number of top species to display per contrast. Default is 5. |
... |
Further arguments passed to or from other methods. |
Value
Invisibly returns the object.