Ordination in R for community data
A site-by-species table is too wide to look at. Fifty sites and two hundred species is ten thousand numbers, most of them zero, and no amount of staring turns that into a result. Ordination compresses it into a map: sites that support similar assemblages sit close together, and the axes of the map are the directions along which composition actually changes.
The compression is where the work is. An ordination is not a picture of your data, it is a picture of your data after a specific set of decisions, and the decisions are made early, quietly, and usually by default.
This page collects every ordination and multivariate tutorial on this site, in an order that follows the workflow rather than the history of the methods.
The choice you make before you start
The first decision is the dissimilarity index, and it is made before any ordination code runs. Euclidean distance treats two sites sharing no species as more similar when both lack the same absentees, which is the double-zero problem, and it is the reason raw Euclidean distance on community counts is almost always wrong. Bray-Curtis, Jaccard and Hellinger each answer a different question about what “different” means. Change the index and the map changes; nothing downstream can undo it.
Unconstrained, then constrained
An unconstrained ordination asks what the main gradients in composition are, without reference to anything you measured. NMDS is the standard choice for community data because it only uses the rank order of the dissimilarities, PCA is for the environmental table rather than the species table, and hierarchical clustering answers the same question with groups instead of axes.
A constrained ordination asks a different question: how much of the compositional variation can the variables you measured explain, and is that more than chance. The gradient length in the data decides whether a linear or a unimodal method is appropriate, distance-based RDA carries the dissimilarity choice into the constrained world, and variation partitioning splits the explained part between overlapping predictor sets instead of double-counting the shared fraction.
Testing, and the trap in the test
PERMANOVA tests whether groups differ, and it is the natural companion to an NMDS. It also has a well-known failure that is still in print constantly: a significant result can mean the groups differ in location, or it can mean they differ in spread, and the test does not say which. Checking dispersion first is not an optional extra, it is what makes the p-value readable. After that, a significant omnibus test still says nothing about which pairs differ, or which species drive the difference.
The model-based alternative
Distance-based methods have one structural weakness: the mean-variance relationship of count data leaks into the distances. Abundant species vary more in absolute terms, so they dominate the dissimilarity whether or not they carry the ecological signal, and an ordination axis can end up tracking sampling intensity rather than composition. Modelling each species with its own GLM and testing the community by resampling takes that apart. It is not a drop-in replacement, it changes what the test assumes, but on count data where the variance climbs with the mean it answers the question you meant to ask.
The tutorials
The choice underneath everything
- Choosing a dissimilarity index - Euclidean, Bray-Curtis, Jaccard or Hellinger, and why double zeros decide it.
Unconstrained ordination
- NMDS ordination - the standard community ordination, with stress read honestly.
- PCA on environmental data - standardisation, axis selection, and the two scalings.
- Hierarchical clustering and dendrograms - groups from the same dissimilarity, checked against the ordination.
Constrained ordination
- RDA vs CCA and gradient length - linear or unimodal, decided by the data rather than by habit.
- Constrained ordination with dbRDA - building the ordination from predictors and testing what they explain.
- capscale vs dbRDA - two functions, the same axes, a different test, and the negative eigenvalues behind it.
- Variation partitioning - environment, space, and the fraction that belongs to both.
- ordisurf vs envfit - a smooth surface where a straight arrow points nowhere.
Testing what the ordination shows
- envfit and PERMANOVA - fitting variables onto the map, testing groups, and keeping the test honest with betadisper.
- Pairwise PERMANOVA - which pairs differ after a significant omnibus test.
- Four common PERMANOVA mistakes - dispersion read as location, the wrong dissimilarity, and the design the permutations ignore.
Which species, and are they associated
- Indicator species analysis - which species characterise which group, with specificity and fidelity kept apart.
- Species co-occurrence null models - the C-score, and the null model that decides whether the pattern is a pattern.
Distance matrices on their own
- Mantel tests - correlating two distance matrices, what that really tests, and when geography looks important and is not.
The model-based alternative
- Model-based multivariate abundance - a GLM per species instead of a distance matrix, and why the mean-variance link matters.
- Model-based unconstrained ordination - a latent-variable ordination that respects the count distribution.
- Fourth-corner trait-environment analysis - traits to environment through abundance, and the permutation null that has to be done in pairs.
- Checking a model-based multivariate model - the two assumptions the community test rests on, and what breaks when they fail.
Traits inside the ordination
- RLQ analysis - the exact co-inertia decomposition, and what a redundant environmental proxy does to it.
- Double constrained correspondence analysis - the correlation-maximising partner of RLQ, and the symmetric trap it brings.
Where this connects
- Community weighted means, intraspecific trait variability and checking a trait environment analysis work the same cross-table without the ordination.
- Beta diversity partitioning asks how much composition changes, where an ordination asks in which direction.
- Modelling nonlinear species responses with GAMs is what a single species does along the gradient the ordination found.
- Species diversity in R is the one-number-per-site view of the same table.