Beta diversity

Differences between samples, and how to see them

Beta diversity

  • Similarity between samples
  • Dissimilarity/distance between samples, clustering, ordination…
  • Identify patterns of community variation across conditions or treatments

Ordination

  • Reduces high-dimensional data to a few informative axes
  • Projects samples into lower-dimensional space while preserving distances or variance
  • Helps identify patterns, clusters, and gradients across samples

From many dimensions to a few

Keeping the essential shape

Hand shadow illustrating projection from 3D to 2D

Ordination methods

  • PCA, PCoA/MDS, RDA, …
  • Euclidean vs non-Euclidean
  • Unsupervised vs supervised

Two points A and B in a plane joined by a straight line, with dashed horizontal and vertical legs showing the Euclidean distance between them.

Principal component analysis (PCA)

  • Unsupervised ordination method
  • Euclidean distance
  • Aitchison distance: CLR + Euclidean distance

PCA plot of samples, coloured by patient status (ADHD or control).

Principal coordinate analysis (PCoA)

  • Multidimensional scaling (MDS)
  • Unsupervised ordination method
  • Any dissimilarity metric (e.g., Bray-Curtis dissimilarity)

PCoA (MDS) plot of samples based on UniFrac distance, coloured by patient status.

Different methods, different views

PCoA with Bray-Curtis versus PCA with Aitchison distance on gut microbiota data

Redundancy analysis (RDA)

  • Supervised ordination method
  • Find variance explained by sample metadata

Distance-based RDA plot of samples with arrows for the cohort and patient status variables.

Matrix decomposition

  • Conceptual basis of ordination: decompose sample × taxa matrix

\[ X = U \Sigma V^T \]

  • UΣ: sample coordinates in reduced space
  • Σ: importance of each axis
  • V: taxa contributions

Left: PCA plot of samples coloured by patient status. Right: lollipop plots of the taxa with the largest loadings on the first two principal components.

Demonstration

library(mia)
library(scater)

# Apply transformation
tse <- transformAssay(tse, method = "rclr")

library(mia)
library(scater)

# Apply transformation
tse <- transformAssay(tse, method = "rclr")
# Apply PCA
tse <- runPCA(tse, assay.type = "rclr")

library(mia)
library(scater)

# Apply transformation
tse <- transformAssay(tse, method = "rclr")
# Apply PCA
tse <- runPCA(tse, assay.type = "rclr")
# Visualize
plotReducedDim(tse, "PCA", colour_by = "patient_status")
PCA plot of samples coloured by patient status.

Exercises

OMA online book, Chapter 15: Community similarity