Species Diversity and Ordination Analysis
Operator: Abdulla Al Fahad. How tools are built and checked
A community survey leaves you with a table of how many individuals of each species turned up at each site, and two separate questions about it. How diverse is each site, and does a site with 160 individuals really have more species than one with 90? And which sites resemble each other, and do the habitats you sampled actually separate?
The page answers both from the same table. Within sites it reports richness, Shannon, Simpson, Pielou, Chao1, ACE and rarefaction curves; between sites it builds a dissimilarity matrix and draws it as a PCoA and a nonmetric MDS, then tests your grouping with PERMANOVA.
Key features
- Richness, Shannon H and exp(H), Simpson 1-D and inverse Simpson, Pielou evenness, Chao1 (bias-corrected), ACE with singleton and doubleton counts
- Hurlbert rarefaction curves for all sites, an approximate 95% band for one site, and expected richness at a common depth
- Bray-Curtis, Jaccard, Sorensen and Euclidean dissimilarities after no transformation, square root, fourth root, log(x + 1) or presence and absence
- PCoA with the share of variation per axis and a count of negative eigenvalues
- NMDS in two dimensions with up to 200 seeded random starts, Kruskal stress-1, and the spread of stress across starts
The community table, transformations and dissimilarities
One row per site: a site name column, one numeric column per species and, if you want colours and a test, a text column of groups such as habitat. Blank species cells count as 0; a text value in a species column is reported by site and column. Rarefaction, Chao1 and ACE need whole-number counts, so for cover or biomass the page shows only the indices that make sense. Up to 120 sites and 500 species columns, and site names must be unique.
How it works
Rarefaction is the expected number of species in a random subsample of m individuals without replacement, summed over species as one minus the chance that a species is missed; the band for one site uses Heck's variance. PCoA double-centres the matrix of squared dissimilarities and takes its leading eigenvectors, so distances between points in the plot approximate the dissimilarities; a measure such as Bray-Curtis that is not Euclidean produces some negative eigenvalues, which the page counts.
NMDS looks for coordinates whose distances have the same rank order as the dissimilarities. It repeatedly fits a monotone curve through the distances against the dissimilarities (pool-adjacent-violators) and moves the points to match it, after fixing the scale of the configuration so the points cannot collapse. The first start is the PCoA configuration and the others are random. Stress-1 is the square root of the summed squared departures from the curve over the summed squared distances.
Common use cases
- A student compares plots P01 (93 individuals) and P07 (189). Raw richness is 11 against 16, but rarefied to 93 individuals P07 has 14.75 expected species, so most of the apparent gap is sample size.
- A field team switches the transformation from square root to presence and absence. The share of dissimilarity explained by habitat falls from 0.701 to 0.583 because rare species now count as much as the dominant ones, while p stays at 0.0010, the smallest value 999 permutations can give.
- An analyst runs the log(x + 1) version with 1 start and again with 20. One start gives a stress of 0.0143 and 20 starts find 0.0131, so a single run settled in a worse arrangement than the best available.
How to use this tool
- Load the community table, or press Load 14-plot example.
- Set the site column, the optional group column, the transformation and the dissimilarity.
- Read the diversity table, the rarefaction curves and the PCoA.
- Press Run NMDS and PERMANOVA and wait for the progress to finish.
Example
Load 14-plot example (invented counts along a moisture gradient), square-root transform, Bray-Curtis, grouped by habitat
plot,habitat,sp01,sp02,sp03,...,sp16
P01,dry,19,15,18,12,9,10,3,1,4,1,0,1,0,0,0,0
P02,dry,15,18,22,22,18,13,7,2,2,3,3,2,0,0,1,0
... 14 plotsPlot P01 and the ordination
P01: 93 individuals, 11 species, Shannon 2.059 (exp 7.84), inverse Simpson 6.85, Pielou 0.859, Chao1 14 (3 singletons, no doubletons)
PCoA axes: 81.0% and 10.4%, 4 negative eigenvalues
NMDS (20 starts, seed 1): stress 0.0121, starts ranged from 0.0121 to 0.0246
PERMANOVA: pseudo-F 28.10 on 1 and 12 df, R squared 0.701, p = 0.0010 (999 permutations)Tips for best results
- Report the transformation and dissimilarity with every ordination figure; the same table gives a different picture under square root and presence and absence.
- If the stress range across starts is wide, as 0.0121 to 0.0246 here, raise the number of starts before reading anything into the layout.
- Rarefy to the smallest sample, not to a depth chosen after looking at the curves; the page offers the smallest sample, here 93 individuals, as the default.
Common pitfalls
Chao1 is a lower bound for the true richness, not an estimate of it, and it is unstable with few singletons. A site with no singletons has a Chao1 equal to its observed richness. A site whose counts are all zero has no diversity to measure, so its Shannon, Simpson and Pielou cells are left blank rather than shown as zero or one.
PERMANOVA also responds to differences in spread between groups, and this page has no separate test of spread. A significant p can mean groups differ in centre, in spread or both.
An NMDS stress below 0.05 says the 2-D picture reproduces the ranks well, not that the ecology is simple. A stress above 0.2 means a two-dimensional picture is misleading.
With few groups and sites the smallest possible PERMANOVA p value is 1 over the number of permutations plus 1, so 999 permutations cannot give p below 0.001.
Axes of an NMDS have no units and no order, and their orientation is arbitrary; only the distances between points carry information.
Common errors and how to fix them
- Site "P05", column "sp03": "n/a" is not a number. Put grouping labels in the factor column.
- Every non-site, non-group column is read as an abundance. Pick the group column, or delete a text column that is not part of the survey.
- Every group needs at least 2 sites; a group with one site has no within-group spread.
- Merge the singleton into a related group or leave it out before testing.
- Add at least 3 sites (rows).
- A dissimilarity analysis needs three or more sites; two points define a single distance.
- Site names have to be unique.
- Two rows share a name. Append a replicate number so each plot is distinguishable.
Best practices
- Write down the number of random starts and the seed beside the stress you report, so another person can repeat the same search.
- Sample sizes within a study should be comparable. When they are not, rarefy before comparing richness and use a dissimilarity that does not grow with the total count, such as Bray-Curtis on proportions or square-root counts.
- Keep the group column to the factor you planned to test; testing every column afterwards inflates the chance of a false finding.
Why rarefy
Larger samples find more species, so comparing raw richness across sites compares effort as much as ecology. Rarefaction answers a fair question instead: how many species would each site show if every site had been sampled with the same number of individuals? In the example, P07 has 16 species in 189 individuals but about 14.75 expected in 93, while P14 has 11 observed and 10.4 expected at 93. The ranking survives here, but the gap between the sites shrinks from 5 species to about 4.4.
Local optima in NMDS
The NMDS objective has many places where the search can stop that are not the best arrangement. Starting once gives one of them. Starting from the PCoA layout and from many random layouts and keeping the lowest stress is the usual remedy, and the spread of stress values across the starts, 0.0121 to 0.0246 for the example, tells you how often a start ends somewhere worse.
The page stops each start when stress changes by less than one in ten million or after 300 iterations. It warns only when the best start ran out of iterations while its stress was still changing by more than one in a million per iteration; a start that is still creeping down at the fourth decimal is reported as settled.
What the transformations do
Without a transformation a few abundant species decide the Bray-Curtis dissimilarity. Square root and fourth root pull the abundant species in so mid-range species contribute; log(x + 1) does so more strongly; presence and absence discards abundance altogether and is a different question, about species composition. The choice is part of the analysis and belongs next to the result.
Frequently asked questions
How do I know the diversity indices are computed the usual way?
They follow the standard formulas: Shannon H is minus the sum of p ln p, Simpson 1-D is one minus the sum of p squared, Pielou is H over ln richness, and Chao1 is S + F1(F1 - 1) / (2(F2 + 1)). For four equally common species the page gives H = ln 4 = 1.386 and Pielou 1, and PERMANOVA on one variable with Euclidean distance reproduces the ordinary ANOVA F ratio exactly.
Is the example data real?
No. The 14 plots are generated by a seeded program from bell-shaped species responses along a gradient and Poisson counts, so the numbers above are illustrative and are the same every time you load it.