Summary by TwinMind · 8m 18s
Summary by TwinMind · 8m 18s

StatQuest: MDS and PCoA

StatQuest: MDS and PCoA

StatQuest with Josh Starmer

StatQuest with Josh Starmer

Introduction and Prerequisites

  • StatQuest episode by Josh Stormer on MDS and PCoA
  • Prerequisite: strong understanding of PCA required
  • Reference: "StatQuest PCA Main Ideas in Five Minutes"
  • Two types of MDS exist:
    • Classical/metric MDS (covered in this episode)
    • Non-metric MDS (not covered)
  • Classical MDS = Principal Coordinate Analysis (PCoA)

Example Setup: Cell Analysis

  • Sample data: normal cells (could be people, cars, cities)
  • Cells appear identical but suspected to be different types
  • Three potential cell types identified
  • Analysis method: sequence messenger RNA to identify active genes
  • Alternative for people: measure height, blood pressure, reading level
  • Data structure: columns show gene transcription levels per cell

Key Difference: PCA vs MDS/PCoA

  • PCA: converts correlations among samples into 2D plot
    • Highly correlated samples form clusters
  • MDS/PCoA: converts distances among samples into 2D plot
    • Closer samples cluster more tightly

Distance Calculation Methods

Euclidean Distance

  • Most common distance calculation method
  • With 2 genes: uses Pythagorean theorem (hypotenuse)
  • With multiple genes: square root of sum of squared differences
  • Formula includes differences for gene 1, gene 2, gene 3, etc.
  • Note: Euclidean distance in MDS produces identical results to PCA
    • Minimizing linear distances = maximizing linear correlations

Alternative Distance Measures

  • Log fold change method:
    • Calculate log fold changes between cells for each gene
    • Example: gene 1 = log(3/0.25), gene 2 = log(2.9/0.8)
    • Gene 8 example = log(1/2.0)
    • Log base 2 values: 3.58, 1.86, ..., -1.43
    • Take absolute values (prevents negative canceling positive)
    • Calculate average of all absolute log fold changes
  • Other distance options:
    • Manhattan distance
    • Hamming distance
    • Great Circle distance
    • Many others available

Distance Selection Strategy

  • Biologists often choose log fold change distance
  • Reason: frequently interested in log fold changes among genes
  • Selecting best distance = part of data science art
  • Different distances produce different-looking graphs

Process Comparison: PCA vs MDS/PCoA

PCA Process

  1. Calculate correlations among samples
  2. Apply eigen decomposition (fancy math)
  3. Output:
    • Graph coordinates
    • Percent variation each axis accounts for
    • Loading scores (determine which variables have largest effect)

MDS/PCoA Process

  1. Calculate distances among samples (only difference from PCA)
  2. Apply same eigen decomposition math
  3. Same output format:
    • Graph coordinates
    • Percent variation per axis
    • Loading scores for variable effects