knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE, fig.width = 10, fig.height = 5.5 )
The ascent package implements the ASC-CFD (Assemblage Shift Characterization — Community Functional Dynamics) framework. Communities can show the same amount of functional turnover while following very different trajectories: one moves to another region of trait space, another redistributes abundance internally, a third gains or loses extreme phenotypes. ascent separates these processes into three layers measured in a functional space (PCoA of Gower distances between species traits):
Table 1. The three layers of ASC-CFD.
| Layer | Metric | Ecological question | | ---------- | ------ | -------------------------------------------------- | | Position | ΔC | Where is the community moving? | | Dispersion | ΔFDis | How is abundance being redistributed? | | Volume | ΔFRic | Are functional boundaries expanding or collapsing? |
Each layer is tested against two null models that ask different questions:
blocks, Part III).summary() also names the trait whose abundance-weighted mean moved most; this is descriptive, not a test.Table 2. Reading A and B together.
| A | B | Reading | | --- | ---------- | -------------------------------------------------------------- | | no | — | no evidence of change beyond sampling | | yes | upper tail | change beyond sampling, directed by traits | | yes | no | change beyond sampling without detectable trait structure |
The lower tail of B (less change than expected from the traits) had little power to detect compensation in the validation, so it is shown for description only, in paired contrasts and in the global test; functional entities (Part V) allow an exploratory look at replacement among similar species.
assess_functional_space() (Part II).asc_paired() (a reference and a comparison state at each site, Part III) or asc_pairwise() (many communities, Part VI). Give replicate samples if you have them, and blocks if both states were sampled in matched units.asc_null() and read summary().asc_transitions() and plot() (Part IV).asc_entities() (Part V).The package includes birds_sim, a simulated data set: 24 bird species with four traits (two continuous, two categorical) and counts of individuals. Two sites were surveyed five times before and five times after an event. At Logged, forest-dependent and fruit-eating species decline and small open-habitat species increase; at Control nothing changes, so any difference there is sampling noise. A second matrix holds five communities along a landscape gradient.
library(ascent) # birds_sim is loaded with the package traits <- birds_sim$traits # species x traits (categorical traits as factors) counts <- birds_sim$counts # surveys x species, counts of individuals samples <- birds_sim$samples # site and time of each survey head(traits) table(samples$site, samples$time)
Abundances must be counts of individuals (whole numbers): null model A needs them. Species are matched to traits by name, so the column order does not matter.
All functions build the same functional space: a PCoA of the Gower distances between species traits. Check it before any analysis:
q <- assess_functional_space(traits) q summary(q)
Number of axes. By default (dim_retention = "msd") the package keeps the number of axes, from 2 to 10, whose distances best reproduce the trait distances: the lowest mSD in the table (Maire et al. 2015). print() and summary() of every result say how many axes were kept and with which rule. More axes describe the traits better, but FRic can only be computed in samples with more species than retained axes. Versions up to 0.5.0 kept the axes needed to reach 80 % of the variance; dim_retention = "variance" reproduces them.
Quality. The share of positive eigenvalues. Below 0.8 the package warns: review the traits first (many missing values, redundant or badly coded traits). correction = "sqrt" (Gower 1971) makes the space Euclidean, but it changes the distances between species, so results with and without it are not comparable, and its effect on the tests has not been evaluated.
asc_paired() compares a reference state with a later state at each site. Here each site is surveyed five times in each state, so the surveys act as replicates and null model A permutes whole surveys between states (accounting for variation between surveys).
res <- asc_paired(traits, counts, sites = samples$site, time = samples$time, ref_time = "Before") res <- asc_null(res, n_perm = 199, seed = 1) summary(res)
n_perm = 199 keeps the vignette fast; use 999 for research. A by samples can only produce as many distinct results as there are ways of splitting the surveys between the two states: with 5 surveys per state there are choose(10, 5) = 252; with 4 there would be only 70 (all of them are enumerated when they are fewer than n_perm), and because swapping the two groups gives the same distance, the smallest possible P for position would be 2/70 ≈ 0.03. With few replicates, A has a floor on its p-values.
How to read summary(). The first table gives the size of each change (Layer1_rDeltaC: centroid shift as % of the functional space; Layer2_DeltaFDis; Layer3_DeltaFRic). The table of null models gives one row per test and layer, with a Reading in words. For B, the row of position refers to the axis-standardised statistic: the shift along each axis divided by its standard deviation under the null, squared and summed over axes (about the number of axes when nothing changes), so its Observed value is not ‖ΔC‖ (which is in the row of A). It detects changes along minor axes as well as along the first one. B with ‖ΔC‖, the statistic up to 0.5.0, is kept in res$b_position_norm. Below the table, summary() names the trait whose abundance-weighted mean moved most, in null standard deviations (all traits in res$trait_shifts). Each level of a categorical trait counts as one trait ("Diet = fruit"), and its change is the change in the share of abundance of species with that level. About 1 null SD or less is chance level; it is a description, not a test, and correlated traits move together.
res$trait_shifts
summary() shows, for each test, both one-tailed p-values (P_upper, P_lower), the two-tailed value for dispersion and volume (P_two, centred on the null mean) and the p-value used for interpretation adjusted across the three layers of each test (P_BH, Benjamini-Hochberg by default; argument p_adjust). The other usual two-tailed convention, twice the smaller tail, can be computed from the table as pmin(1, 2 * pmin(P_upper, P_lower)).
A by samples assumes that surveys can be exchanged freely between the two states. That is not true when both states were surveyed in matched units, such as the same months, plots or survey rounds: surveys of the same month share its weather, and free permutation then underestimates the variation between months. Give that unit as blocks in asc_paired(); A then exchanges surveys between the two states only within each block. summary() reports which permutation was used. Blocks remove effects shared by the surveys of a block; they do not remove the temporal autocorrelation of consecutive surveys of the same state, which makes A (like PERMANOVA) liberal whatever the permutation: consecutive surveys are pseudoreplicates.
# Suppose the k-th survey before and after the event was made in the same survey round round <- ave(seq_len(nrow(samples)), samples$site, samples$time, FUN = seq_along) res_b <- asc_paired(traits, counts, sites = samples$site, time = samples$time, ref_time = "Before", blocks = round) res_b <- asc_null(res_b, n_perm = 199, seed = 1) res_b$null_settings$permutation
With one survey of each state per block there are 2^B allocations for B blocks (here 2^5 = 32, all enumerated). Because swapping the two states in every block gives the same distance, the smallest attainable p-value for position is 2/32 = 0.0625: with five matched pairs, A can never reject at 0.05, and asc_null() warns about it. Six matched pairs are the minimum (2/64 = 0.031); with eleven, as in a year of monthly surveys, there are 2048 allocations (use n_perm = 2048 to enumerate them all). Free permutation does not have this floor, but it is not valid for matched surveys.
| Your design | What to use |
| --- | --- |
| One sample per state | A by individuals: it tests multinomial sampling error only |
| Replicates taken in matched units (same months, plots, rounds) | blocks = that unit |
| Independent replicates (spaced, not matched) | free permutation (no blocks) |
| Consecutive replicates (pseudoreplicates), matched or not | no permutation removes this dependence: A is liberal; space the samples or treat p-values as indicative |
nm <- res$null_models pos <- nm[nm$Layer == "Position", c("Contrast", "Test", "SES", "P_upper", "P_lower")]
Reading. At Logged, A gives P = r signif(pos$P_upper[pos$Contrast == "Logged" & grepl("^A", pos$Test)], 2) for the centroid shift and B gives P = r signif(pos$P_upper[pos$Contrast == "Logged" & grepl("^B", pos$Test)], 2). At Control, where nothing changed in the simulation, A gives P = r signif(pos$P_upper[pos$Contrast == "Control" & grepl("^A", pos$Test)], 2): r if (pos$P_upper[pos$Contrast == "Control" & grepl("^A", pos$Test)] > 0.05) "no evidence of change beyond sampling, as expected" else "a false alarm; under no change about one site in twenty gives P < 0.05 by chance". Read B only where A detects a change: its upper tail tells whether the change is organised by the species' traits.
At Logged, the volume shrank more than expected from sampling: some species at the edge of the functional space disappeared. At Control, the Volume rows show NA: the convex hull (set by the extreme species) did not change, so ΔFRic is 0 in the data and in every permutation. FRic only responds when species at the edges of the functional space appear or disappear.
asc_transitions() describes the change without p-values. The leverage of a species is its contribution to the centroid shift; leverages add up exactly to the shift. The partition says how much of the shift comes from species shared by both states, gained or lost; its range across reference points shows how robust that split is.
tr <- asc_transitions(res) summary(tr, n_sp = 5) plot(res, contrast = "Logged", type = "both", n_sp = 5)
Positive leverage: the species pushes the centroid in the direction of the change (it increased in the direction of the shift, or declined on the opposite side). Negative leverage: the species resists the shift. Leverage keeps only the part of each contribution that lies along the shift; the column Orthogonal gives the perpendicular part, so a species with small leverage and large Orthogonal did change, but along another direction of the trait space.
Functional entities are groups of species with similar traits. They separate a change that reorganises the functional groups (shift between entities) from the replacement of species by functionally similar ones (shift within entities). This use is exploratory: only replacement within an entity is seen (similar species placed in different entities look like a change between entities), and in the validation the signal was weak except for strong compensation.
ent <- asc_entities(traits, k_max = 10, B = 50, seed = 1) summary(ent) plot(ent)
If k is not given, the number of entities with the highest mean silhouette is used. Mean silhouette below 0.25 means no clear groups; a gap statistic of 1 means the entities divide a continuum (still useful, but check that conclusions hold for neighbouring values of k).
Entities are used in the null models (A on counts summed by entity) and in the transitions (split between and within entities):
res_e <- asc_null(res, n_perm = 199, seed = 1, entities = ent) res_e$null_models[res_e$null_models$Layer == "Position", c("Contrast", "Test", "SES", "P_upper")] asc_transitions(res, entities = ent)$Logged$entities
Reading. If A is significant for species but not for entities, and most of the shift is within entities, the change is consistent with replacement by functionally similar species. The converse does not hold: a small within fraction does not rule out redundancy. Here r wf <- asc_transitions(res, entities = ent)$Logged$entities[["Within_fraction"]]; round(100 * (1 - wf)) % of the shift at Logged occurs between entities: r if (wf < 0.5) "the change reorganised the functional groups" else "most of the change is replacement among similar species".
asc_pairwise() describes all pairs of communities. With many communities, one p-value per pair would multiply false alarms, so asc_null() runs one global test per layer: the mean distance of the community centroids to their common centroid, and the standard deviation of FDis and FRic among communities. It also reports how far each community lies from the common centroid.
pw <- asc_pairwise(traits, birds_sim$landscape) pw <- asc_null(pw, n_perm = 199, seed = 1) summary(pw) plot(pw, contrast = "Primary_vs_Farmland", type = "both", n_sp = 5)
All layers of the global test 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; for position it uses the axis-standardised statistic (the variance of the community centroids along each axis divided by its value under the null, summed over axes). The lower tail of B is shown for description only. summary() also names the trait whose weighted mean varies most among communities.
asc_baseline() reports the absolute metrics (CWM, FDis, FRic) of each community, without contrasts.
summary(asc_baseline(traits, birds_sim$landscape))
Table 3. Functions of ascent.
| Objective | Function |
| ---------------------------------- | --------------------------- |
| Quality of the functional space | assess_functional_space() |
| Paired (temporal) contrasts | asc_paired() |
| All pairs of communities | asc_pairwise() |
| Null models A and B, global test | asc_null() |
| Species leverage and partition | asc_transitions() |
| Functional entities | asc_entities() |
| Absolute metrics per community | asc_baseline() |
stratum_sizeNull model B shuffles traits among groups of stratum_size species of similar abundance (default 5). In the validation, groups of 5 and of 10 species behaved almost identically, whereas shuffling among all species of the contrast (stratum_size = Inf) was biased in a real trait space (up to 12 % false positives for FRic, and too conservative for position); it is not recommended. Stratification calibrates B; it does not make it more powerful. Rerunning with neighbouring values (e.g. 3 or 10) checks that conclusions do not depend on it. As a rule of thumb (not evaluated by simulation), use 3 when samples have fewer than 10 species and 5 to 10 when they have more than 60.
blocks remove effects shared by a block, not this dependence.P_adj (shown as P_BH in summary()) adjusts the three layers of each test within each contrast. Contrasts are not adjusted against each other; to do so, apply p.adjust() to the p-values of interest in null_models.P_two is centred on the null mean. With asymmetric null distributions it can differ from twice the smaller tail; both tails are always reported so that either convention can be used.FRic is the volume of the convex hull in the retained axes. It depends only on extreme species and is not abundance-weighted: interpret ΔFRic as a descriptor of the functional boundary, complementary to ΔFDis. When a community has no more species than retained axes, FRic is NA.
Only the positional shift (rΔC %) is normalised by the regional functional diameter and comparable across studies. ΔFDis and ΔFRic are absolute differences in the retained space.
$$\sum_{i=1}^{S} \text{Leverage}_i = \|\Delta C\|, \qquad \text{Leverage}_i = \Delta p_i \, (\mathbf{f}_i - \mathbf{r}) \cdot \hat{v}$$
where $\Delta p_i$ is the change in relative abundance, $\mathbf{f}_i$ the species' coordinates, $\hat{v}$ the unit vector of the shift and $\mathbf{r}$ the reference point (by default the midpoint between the two centroids). The total does not depend on $\mathbf{r}$; how it is shared among species does.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.