AI summary by TwinMind

Drawing and Interpreting Heatmaps

StatQuest with Josh Starmer

16m 48s

Heat Map Basics and Data Modifications

  • Heat maps display RNA-seq samples (columns) vs genes (rows)
  • Two key modifications enable insights:
    • Scaling: Relative abundances scaled per gene basis (vs global scaling)
      • Per-gene scaling: easy comparison within genes across samples
      • Cannot compare across genes (dark red doesn't mean higher than other genes)
    • Clustering: Genes grouped by similarity using computer programs
      • Groups genes with similar transcription patterns
      • Without clustering: "mish mash" harder to interpret
      • Without scaling + clustering: completely uninterpretable
  • Outlier genes highly transcribed compared to others create interpretation issues

Advanced Heat Map Example

  • Global scaling: Applied to all rows/genes simultaneously (not per gene)
    • Used when no outliers present
    • Enables comparison across genes
  • Bidirectional clustering: Both columns (samples) and rows (genes) clustered
    • Similar samples cluster together (similar transcription patterns)
    • Similar genes cluster together (similar expression across samples)
  • Outlier impact on global scaling: Skews scale, makes other genes invisible

Z-Score Scaling Method

  • Most common scaling method: Converts data to z-scores
  • Four-step process:
    1. Calculate mean (example: 16.5)
    2. Subtract mean from each value (centers data around zero)
    • High transcription → positive values
    • Low transcription → negative values
    1. Calculate standard deviation (example: 6.28)
    2. Divide each data point by standard deviation
  • Formula: (sample value - mean) / standard deviation
  • Purpose: Tightly groups data for better color discrimination
    • Wider ranges require more color shades
    • Tighter grouping uses fewer shades, easier interpretation
  • Outlier problem: Large standard deviation compresses values near zero

Hierarchical Clustering Process

  • Two main types: Hierarchical and K-means (focus on hierarchical)
  • Four conceptual steps:
    1. Find most similar gene to gene 1
    2. Find most similar gene to each remaining gene
    3. Merge two most similar genes into cluster
    4. Treat new cluster as single gene, repeat process
  • Dendrogram output: Shows similarity and cluster formation order
    • Earlier clusters = more similar genes
    • Later clusters = broader groupings

Distance Metrics for Similarity

  • Method selection: Arbitrarily chosen, common practices exist
  • Euclidean distance (most common):
    • Formula: √[(difference sample 1)² + (difference sample 2)² + ...]
    • Two samples/genes = Pythagorean theorem
  • Manhattan distance: Absolute value of differences (no squaring/square root)
  • Impact on clustering: Different metrics produce different results
    • Large clusters remain intact
    • Smaller clusters show more variation
    • No biological reason for preference

Cluster Comparison Methods

  • Multiple approaches for comparing points to clusters:
    1. Compare to cluster average
    2. Compare to closest point in cluster
    3. Compare to furthest point in cluster (R default)
  • Results: Major clustering blocks retained, details vary by method

Summary and Best Practices

  • Heat map creation process:
    1. Scale data (per gene or globally)
    2. Cluster data (genes, samples, or both)
  • Key decisions required:
    • Distance metric: Euclidean, Manhattan, others
    • Clustering method: Centroid, average, furthest/closest point
  • Practical advice: Most choices have default values in R
    • Run with defaults first
    • If results look good, proceed
  • Alternative: K-means clustering
    • Requires pre-deciding cluster number
    • Minimizes within-cluster variance
    • Separate topic for future discussion

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome