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
- Scaling: Relative abundances scaled per gene basis (vs global scaling)
- 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:
- Calculate mean (example: 16.5)
- Subtract mean from each value (centers data around zero)
- High transcription → positive values
- Low transcription → negative values
- Calculate standard deviation (example: 6.28)
- 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:
- Find most similar gene to gene 1
- Find most similar gene to each remaining gene
- Merge two most similar genes into cluster
- 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:
- Compare to cluster average
- Compare to closest point in cluster
- 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:
- Scale data (per gene or globally)
- 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
