EcoMetriQReference Book

5. Rarefaction and accumulation curves (Rarefaction)

Tab: 📈 Rarefaction · Code: ui/main_dialog.py:542-796 (interface), modules/alpha_beta_indices.py:574-691 (expectation and variance), modules/rarefaction_plotter.py (plots)

5.1 What this tab does

The number of species increases with sample size. If two sites were sampled with different numbers of records, their raw S values cannot be compared: the site with many records shows more species even if it is not actually richer. Rarefaction solves this problem by "scaling down" every site to the same number of individuals (records): if n individuals were drawn at random from a sample of N individuals, what would the expected number of species be?

The tab produces three plots and a numeric table:

  1. Rarefaction curve (Plot Rarefaction Curve): E(S_n) for one or more communities, with a 95% interval.
  2. Species accumulation curve (Species Accumulation Curve): how the number of species accumulates when the records are put in random order.
  3. Beta heat map (Beta Heat Map): Jaccard similarity between sites.

5.2 Screen and parameters

Figure 5.1. The Rarefaction tab. Source, curve settings, the multi-site comparison box (here filled with the records of five sub-watersheds), three plot buttons and the numeric table.
Figure 5.1. The Rarefaction tab. Source, curve settings, the multi-site comparison box (here filled with the records of five sub-watersheds), three plot buttons and the numeric table.
Name in the interface What it does Default Range Code
Source: Data for the main curve CSV (point count per species — recommended) CSV / Manual Table ui/main_dialog.py:555-563
Step Count: Number of points on the curve 30 5 - 200 ui/main_dialog.py:567-568
Site / Label: Legend name of the main curve and plot title Study Site text ui/main_dialog.py:569
Save (PNG/SVG): File to save the plot to; if empty, the plot opens in a separate window empty path ui/main_dialog.py:570-579
Multi-Site Comparison (optional) Additional communities: each line SiteName: species1, species2, … empty text ui/main_dialog.py:582-595
📈 Plot Rarefaction Curve (QGIS) Rarefaction plot + numeric table - - ui/main_dialog.py:639-707
📉 Species Accumulation Curve Accumulation curve - - ui/main_dialog.py:729-748
🟥 Beta Heat Map Jaccard heat map (from the multi-site box) - - ui/main_dialog.py:750-775
💾 Export Table (CSV) Writes the numeric table to a file - - ui/main_dialog.py:777-796

5.2.1 The multi-site comparison box

Write one site per line in the box. After the colon, write the species name for each record at that site, separated by commas. If the same species is written more than once, its count equals the number of times it appears: the line Site_A: Pinus nigra, Pinus nigra, Quercus cerris means n_{\text{Pinus}} = 2, n_{\text{Quercus}} = 1 (ui/main_dialog.py:664-679). Lines with fewer than two species names are skipped.

The program does not fill this box by itself from the site column of the CSV. To compare sites, you must prepare the lines by hand or with a spreadsheet program. For the figures in this book, all records of the five sub-watersheds were written into the box in this format.

The Export Table (CSV) button writes the most recently drawn curves in comma-separated, UTF-8 "long" format: one row for each curve and each sample size, with the columns label, n, expected_s, sd, ci_lower_95, ci_upper_95 (ui/main_dialog.py:777-795). At points where the variance is not computed (S > 400), the last three cells are left empty. If no curve has been drawn yet, the message "Compute the curve first." appears. The file opens with read.csv() in R and directly in spreadsheet programs, and the curves can be redrawn in another graphics program.

5.3 Rarefaction: formulas

5.3.1 Expected number of species

The expected number of species when n individuals are drawn at random without replacement from a sample of N individuals and S species:

E(S_n) = \sum_{i=1}^{S} \left[ 1 - \frac{\binom{N - n_i}{n}}{\binom{N}{n}} \right]

The term in square brackets is the probability that species i occurs at least once in a subsample of n individuals. Source: Hurlbert (1971). The binomial coefficients are computed with the log-gamma function to avoid overflow; if N - n_i < n, the probability that the species is absent is zero ("so abundant that it must occur in the subsample"). For n \ge N, E(S_n) = S (modules/alpha_beta_indices.py:574-592).

5.3.2 Variance and 95% limits

With a_i = \binom{N-n_i}{n}/\binom{N}{n} (probability that species i is absent) and a_{ij} = \binom{N-n_i-n_j}{n}/\binom{N}{n} (probability that i and j are both absent):

\mathrm{Var}(S_n) = \sum_i a_i (1 - a_i) + 2 \sum_{i<j} \left( a_{ij} - a_i a_j \right)
E(S_n) \pm 1.96 \sqrt{\mathrm{Var}(S_n)} \quad \text{(lower limit clipped to 0, upper limit to } S\text{)}

Source: Heck, van Belle and Simberloff (1975). Code: modules/alpha_beta_indices.py:594-665. These limits show how much the number of species would vary if smaller subsamples were drawn from this sample; they do not show what would happen if a new sample were taken from the community. If S > 400, the variance is not computed and no band is drawn for that curve on the plot.

5.4 Running

  1. While Source points to the CSV, type the name of the main curve in the Site / Label box (e.g. "Antalya (5 sub-watersheds)").
  2. If you are comparing sites, fill in the Multi-Site Comparison box (§5.2.1).
  3. Type a file path in the Save (PNG/SVG) box (if you do not, the plot opens in a separate window).
  4. Press the 📈 Plot Rarefaction Curve (QGIS) button.
Figure 5.2. Rarefaction plot with the sample data: all records (green, 694 species) and five sub-watersheds. Upper panel: E(S_n) and 95% bands (only for curves with S <= 400); the star marks the observed (N, S) point; top left, the "last 10% segment" note. Lower panel: slope of the curve and the 0.01 reference line.
Figure 5.2. Rarefaction plot with the sample data: all records (green, 694 species) and five sub-watersheds. Upper panel: E(S_n) and 95% bands (only for curves with S <= 400); the star marks the observed (N, S) point; top left, the "last 10% segment" note. Lower panel: slope of the curve and the 0.01 reference line.

5.5 Reading the output

5.5.1 Upper panel

Each curve starts at (0, 0) and ends at the observed point (star). Curves are compared vertically at the same value of n. In the sample data, at n = 100, a value close to the smallest record count shared by all sub-watersheds:

Sub-watershed Records (N) Observed S E(S_{100}) SD Coverage C
Aksu 970 416 85.5 3.3 0.79
Boğaçay 152 125 87.3 2.3 0.31
Köprüçay 181 152 90.6 2.3 0.30
Kırkgöz-Düden 236 171 83.4 3.1 0.42
Manavgat 279 181 83.7 3.1 0.57

Interpretation. In observed richness, Aksu (416 species) is two to three times the others. However, at 100 records the expected richness of the five watersheds is 83-91, and at the smallest common sample size (152 records) 117-131. Aksu's high S largely reflects the 970 records collected there. The SD values are Heck et al. (1975) variances, conditional on the present sample (§5.3.2); their overlap does not show that the watersheds' richness is statistically the same. At low n the comparison reflects the evenness of common species more than richness, and sample coverage differs widely (0.30-0.79). Conclusions about asymptotic richness require coverage-based comparison and extrapolation (Chao and Jost 2012; iNEXT).

5.5.2 The "last 10% segment" note

The note at the top left of the plot computes exactly how many species are added over the last 10% of the curve (in the sample data, from n = 1,636 to 1,818) and states the terminal slope of the curve (f_1/N, new species per record). If the addition is less than 5% of the total number of species and the terminal slope is below 0.01, it says "curve near-flat"; otherwise "curve still rising" (modules/rarefaction_plotter.py:154-198). In the sample data, the last 10% for all records adds 31.98 species (4.6%). Although the addition stays below 5%, the terminal slope is 0.167 species per record, so the note says "curve still rising". In the sub-watersheds, the last 10% adds between 5.2% (Aksu) and 8.4% (Boğaçay, Köprüçay) of the total number of species, and the terminal slopes lie between 0.212 and 0.702; all five curves are still rising.

The "near-flat" note does not mean saturation

The note is a reading aid, not a test; the program itself writes "(descriptive heuristic, not a test)" underneath. The terminal slope of the curve does not vanish by itself: the expected contribution of the last record is exactly E(S_N) - E(S_{N-1}) = f_1/N = 1 - C, i.e. 0.17 new species per record in the sample data, 17 times the 0.01 reference line in the lower panel. A rule that looks only at the addition over the last 10% can say "near-flat" even when the share of singletons is high (44% in the sample data): in the sample data the addition is 4.6% and stays below the 5% limit. The note therefore also checks the terminal slope. Even when the note says "near-flat", this does not mean saturation. In the sample data, sample coverage is only 0.83 and Chao1 predicts about 300 unseen species. Decide on the adequacy of sampling with sample coverage and Chao1 (Chapter 4).

5.5.3 Lower panel: slope

The lower panel shows the slope between successive curve points (\Delta S / \Delta n, new species per record). The red dashed line is 0.01: "one new species per 100 new records". This line is also a rule of thumb, not a threshold (modules/rarefaction_plotter.py:112-120).

5.5.4 Numeric table

The Numeric Rarefaction Table box lists the n and E(S_n) values of each curve. Because the steps of different curves fall on different n values, only one column is filled in most rows (ui/main_dialog.py:709-727). To read the values of a curve, look at the filled rows of its column.

5.6 Species accumulation curve

Figure 5.3. Species accumulation curve (sample data). Blue: mean of 200 random orderings and the 5th-95th percentile band; red dashed: accumulation in the order of the records in the file.
Figure 5.3. Species accumulation curve (sample data). Blue: mean of 200 random orderings and the 5th-95th percentile band; red dashed: accumulation in the order of the records in the file.

The 📉 Species Accumulation Curve button plots how the number of species accumulates as the loaded records are added one by one (modules/rarefaction_plotter.py:201-284):

Interpretation. The band shows the variability caused by the order in which the records were collected; it is not a confidence interval. The mean of the random orderings is very close to the individual-based rarefaction curve. If the file-order curve goes outside the band, the order of the records is not random. In the sample data the file is sorted alphabetically by species name: because records of the same species come one after another, new species are added more slowly and the red line stays below the band. In a file kept in field order, this line shows how sampling progressed over time. This plot always uses all records; it is not affected by Source or by the multi-site box.

5.7 Beta heat map

Figure 5.4. Jaccard similarity heat map for five sub-watersheds. The diagonal is 1; values between sites are 0.11 - 0.16.
Figure 5.4. Jaccard similarity heat map for five sub-watersheds. The diagonal is 1; values between sites are 0.11 - 0.16.

🟥 Beta Heat Map draws the pairwise Jaccard similarity (J = a/(a+b+c), §6.3) of the sites in the multi-site box as a colored matrix (modules/rarefaction_plotter.py:286-…). It is based on presence/absence; species counts are not used. The box must contain at least two sites. For numeric values and partitioning, use Chapter 6.

5.8 Common mistakes

5.9 Expert questions

Q1. Is this individual-based or sample-based (plot-based) rarefaction? It is individual-based (Hurlbert 1971). In record data, each record counts as an "individual". Sample-based rarefaction requires a species × sample presence/absence table; EcoMetriQ does not do this (Gotelli and Colwell 2001; Colwell et al. 2012).

Q2. Does it give the same result as vegan::rarefy? Yes. vegan::rarefy(x, sample = n, se = TRUE) gives the same Hurlbert expectation and the same Heck et al. standard error. In the cleaned Antalya data, E(S_{100}) and the standard errors of the five sub-watersheds matched vegan to four decimal places (the cleaned file is not distributed with this book).

Q3. Why is no band drawn for more than 400 species? The Heck variance contains a term for every pair of species; with 694 species this means about 240,000 pairs, and that many binomial computations for each n step. In this case the program does not draw the band and states the reason in the table.

Q4. Can I compare at equal sample coverage? No; EcoMetriQ compares only at equal sample size. For coverage-based rarefaction (Chao and Jost 2012), use iNEXT.