# Supplementary Method S7: Prevalence class relative abundance and core MAG co-absence analysis

---

## 1. Overview

This supplementary method describes two complementary analyses of the MAG prevalence structure across samples:

1. **Prevalence class relative abundance** (Fig. S6): For each sample, the fraction of total mapped read coverage attributable to core, variable, and rare MAGs respectively, showing how the three classes partition the community signal across individuals.

2. **Core MAG co-absence analysis** (Fig. S7): A characterisation of absence patterns among the 18 core MAGs, identifying subsets of core MAGs whose rare absences are correlated and may reflect coordinated ecological responses.

Both analyses use the standard presence thresholds (Q2Q3 mean coverage ≥ 0.5× AND detection ≥ 0.2) and the same four excluded samples as the main analysis (see §4.2 of main Methods).

---

## 2. Prevalence class relative abundance (Fig. S6)

### 2.1 Rationale

The three prevalence classes — core (≥ 85% of samples), variable (> 10% to < 85%), and rare (≤ 10%) — were defined at the MAG level. To understand their quantitative contribution to the community in each sample, we calculated the fraction of total mapped read coverage attributable to each class per sample. This addresses the question of whether core MAGs, despite their small number (n = 18), account for a disproportionately large share of sequencing depth, and how consistently the relative contributions of the three classes hold across the 116 retained samples.

### 2.2 Coverage-based relative abundance

For each sample, relative abundance of each prevalence class was computed from raw Q2Q3 mean coverage values (not filtered by the presence threshold). This ensures that every sample's relative abundances sum to 100%, and that MAGs contributing low but non-zero coverage are included in the denominator. For each sample *s* and class *c*:

```
relative_abundance[s, c] = sum(coverage[MAG_i, s]  for all MAG_i in class c)
                           ─────────────────────────────────────────────────
                           sum(coverage[MAG_j, s]  for all MAG_j in catalogue)
```

All 1,374 MAGs in the catalogue contribute to the denominator.

### 2.3 Visualisation

Samples were ranked on the x-axis in ascending order of rare-class relative abundance, so that samples dominated by variable MAGs appear on the left and those with the highest rare-class signal appear on the right. Each bar is divided into three colour-coded segments (core: teal, variable: orange, rare: purple). This ordering makes visible both the overall dominance of variable MAGs and the modest but variable contribution of the rare class.

### 2.4 Implementation

Analysis is implemented in `09_analysis/Supplementary_genus_prevalence/Supplementary_prevalence_class_relabund.Rmd`. Per-sample relative abundances are saved to `supplementary/Supplementary_Table_prevalence_class_relabund_per_sample.csv`.

---

## 3. Core MAG co-absence analysis (Fig. S7)

### 3.1 Rationale

Core MAGs are defined as present in ≥ 85% of samples. However, "near-universal" does not mean identical absence patterns: a core MAG absent from 15% of samples (≤ 17 samples) may still show non-random co-absence with other core MAGs. If two core MAGs share the same rare absences, this may reflect a biological dependency (e.g., shared ecological niche, syntrophic relationship, or susceptibility to a common perturbation). Conversely, if their absences are uncorrelated, their occasional non-detection likely reflects independent stochastic processes.

We applied Ward hierarchical clustering to the pairwise co-absence correlation matrix to identify subgroups of core MAGs with coordinated absence behaviour.

### 3.2 Presence/absence matrix

For each of the 18 core MAGs and each of the 116 retained samples, a binary presence indicator was computed using the standard thresholds (Q2Q3 coverage ≥ 0.5× AND detection ≥ 0.2). This produced an 18 × 116 binary matrix *P*, where *P*[i, s] = 1 if core MAG *i* was present in sample *s*, and 0 otherwise.

### 3.3 Pairwise co-absence correlation

To quantify the degree to which pairs of core MAGs are absent from the same samples, we computed pairwise Pearson correlations on the row vectors of the **absence** matrix (1 − *P*). A correlation of 1 between two MAGs indicates they are absent from exactly the same samples; a correlation of 0 indicates their absences are independent; negative correlations would indicate one tends to be absent when the other is present (not observed in these data).

The 18 × 18 correlation matrix is displayed in Fig. S7 (Supplementary correlation matrix, available in `09_analysis/Supplementary_genus_prevalence/FigS_core_MAG_coabsence_correlation.png`).

### 3.4 Ward hierarchical clustering

Hierarchical clustering was applied to the 18 core MAGs using the complement of the Pearson co-absence correlation as the dissimilarity measure (distance = 1 − *r*). Ward's minimum variance linkage (Ward.D2) was used, which minimises the total within-cluster variance and tends to produce compact, well-separated clusters. The resulting dendrogram was cut at *k* = 3 clusters, selected by visual inspection of the dendrogram structure.

The three clusters are:

- **Cluster A** (red): Core MAGs showing the most variable presence — they have the highest number of absences relative to other core MAGs, and their absences are correlated with each other. These MAGs are at the lower end of the core prevalence range (85–90%).

- **Cluster B** (blue): Core MAGs with intermediate and moderately correlated absence patterns.

- **Cluster C** (green): Core MAGs that are absent from very few samples (< 5); their rare absences are not strongly correlated with each other, consistent with independent stochastic non-detection rather than shared ecological loss.

### 3.5 Presence/absence heatmap (Fig. S7, Panel A)

The binary presence/absence matrix was visualised as a heatmap using the R package **pheatmap**. Both rows (MAGs) and columns (samples) were ordered by the Ward clustering dendrogram. Rows are annotated with cluster membership and with a flag indicating whether the MAG passed the original 90% core threshold (the threshold used in earlier analyses) or was added when the threshold was revised to 85%. Columns are annotated with the total number of core MAGs present in each sample (*n_core_present*).

### 3.6 UpSet plot (Fig. S7, Panel B)

To characterise the frequency and composition of co-absence combinations across samples, an UpSet plot was generated using the R package **UpSetR**. In this plot:

- The horizontal bars on the left show, for each core MAG, the total number of samples in which it is present (set size).
- The vertical bars show the count of samples sharing each particular combination of absences (intersection size).
- The filled dots and connecting lines indicate which MAGs are absent in each combination.
- Combinations are ordered from most to least frequent.

The dominant intersection (n = 66 samples) has no filled dots, indicating that 66 of 116 samples (57%) had all 18 core MAGs present simultaneously. Subsequent intersections show the absence of one or a small number of core MAGs in isolated samples, confirming that coordinated multi-MAG absences are rare.

Set bars in the UpSet plot are colour-coded by cluster membership (Cluster A: red, Cluster B: blue, Cluster C: green) to link the intersection patterns back to the clustering structure.

### 3.7 Implementation

The full co-absence analysis is implemented in `09_analysis/Supplementary_genus_prevalence/run_core_coabsence.R`. Output figures are saved to:

- `09_analysis/Supplementary_genus_prevalence/FigS_core_MAG_presence_heatmap.png` (Panel A)
- `09_analysis/Supplementary_genus_prevalence/FigS_core_MAG_coabsence_upset.png` (Panel B)
- `09_analysis/Supplementary_genus_prevalence/FigS_core_MAG_coabsence_correlation.png` (correlation matrix)

---

## References

- Kolde, R. (2019). pheatmap: Pretty Heatmaps. R package version 1.0.12. https://CRAN.R-project.org/package=pheatmap
- Conway, J. R., Lex, A. & Gehlenborg, N. (2017). UpSetR: an R package for the visualisation of intersecting sets and their properties. *Bioinformatics*, 33(18), 2938–2940. https://doi.org/10.1093/bioinformatics/btx364
- Ward, J. H. (1963). Hierarchical grouping to optimise an objective function. *Journal of the American Statistical Association*, 58(301), 236–244.
