AI summary by TwinMind
Principal Component Analysis (PCA) clearly explained (2015)
StatQuest with Josh Starmer
20m 16s
Introduction to PCA Example
- Example PCA plot from single cell RNA sequencing data
- Shows clusters of different cell types (blood cells, pluripotent cells, neuronal cells, dermal/epidermal cells)
- Original data: ~10,000 transcribed genes per cell
- Each dot represents single cell and its transcription profile
- Big question: How does transcription from 10,000 genes get compressed into single dot on graph?
- Answer: PCA compresses lots of data while capturing essence of original data
Background: Introduction to Dimensions
- One dimension: Number line (first/second grade concept)
- Example: RNA seq data for single cell with genes A, B, C having read counts 10, 0, 14
- Plot values on number line: Gene A at 10, Gene B at 0, Gene C at 14
- Can show uniform or non-uniform distribution of transcript counts
- Two dimensions: XY graph (fifth/sixth grade concept)
- Can plot data from two different cells
- Gene A: go over 10 for cell 1, up 8 for cell 2
- Gene B: go over 0 for cell 1, up 2 for cell 2
- Gene C: go over 14 for cell 1, up 10 for cell 2
- Expression can be correlated or uncorrelated between cells
- Three dimensions: 3D graph with depth (calculus level)
- Can plot data from three separate cells
- Example: Gene A at coordinates (10, 8, 8)
- Lines perpendicular to each axis determine intersection point
Dimensional Scaling Problem
- Four cells: Need 4-dimensional graph (can't draw on paper)
- 200 cells: Need 200-dimensional graph (impossible to visualize)
- Key question: Are all dimensions equally important or some more important than others?
Importance of Dimensions
- Example 1: Two-cell data with most variation left-to-right
- Cell 1: genes with low and high transcription
- Cell 2: all genes transcribed at same level
- Can flatten data (remove up-down variation) without much information loss
- Can display 2D data on 1D graph
- Example 2: TV and movies analogy
- Usually shown on 2D flat screens despite 3D subjects
- Third dimension doesn't add much to story
- 3D movies often disappointing
- Movie camera flattens 3D to 2D without significant information loss
PCA Core Concept
- Takes dataset with many dimensions (cells) and flattens to 2-3 dimensions for visualization
- Finds meaningful way to flatten data by focusing on differences between cells
- Similar to flattening z-stack microscope images for publication
PCA Step-by-Step Example (Two Cells)
- Data setup: Imaginary genes A through I with read counts for two cells
- 2D plot: Dots spread along diagonal line
- Maximum variation: Between endpoints of diagonal line
- Second variation: Above and below first line (perpendicular)
- Graph rotation: Two lines become new X and Y axes
- Makes variation easier to see
- Data varies lot left-right, little up-down
- All points describable with two rotated axes
Principal Components Definition
- Principal Component 1 (PC1): Axis spanning most variation in data
- Principal Component 2 (PC2): Axis spanning second most variation
- Three cells: Need PC1, PC2, PC3 (third most variation)
- Four cells: Need PC1, PC2, PC3, PC4 (fourth most variation)
- General rule: One principal component per dimension/cell
- 200 cells: Would have 200 principal components (PC200 = 200th most variation)
From Genes to Cells Plotting
- Gene influence on PC1: Determined by genes at endpoints (extreme genes)
- Scoring system:
- Qualitative: High scores for genes at line ends (A, F), low scores for middle genes (B, C)
- Quantitative: Values close to 0 for little influence, further from 0 for more influence
- Opposite ends get large numbers with different signs (A: +10, F: -14)
- Two tables: Gene influences on PC1 and PC2 separately
Cell Scoring Calculation
- Formula: Multiply read count by gene influence, sum across all genes
- PC1 score for Cell 1:
- Gene A: 10 reads × 10 influence = 100
- Gene B: 0 reads × 0.5 influence = 0
- Continue for all genes → final score (example: 12)
- PC2 score for Cell 1:
- Gene A: 10 reads × 3 influence = 30
- Gene B: 0 reads × 10 influence = 0
- Continue for all genes → final score (example: 6)
- Plotting: Cell 1 at coordinates (12, 6) on PC1-PC2 graph
Cell Similarity and Clustering
- Cell 2 example: Might score (2, 8) on PC1-PC2 graph
- Cell 3: If similar to Cell 1, gets similar scores and plots closer to Cell 1
- Result: Cells with similar transcription patterns cluster together
Key Applications and Insights
- Gene identification:
- PC1 influences help identify genes distinguishing left-right cell separation
- PC2 influences help identify genes distinguishing up-down cell separation
- Example: Dermal cells (left) vs neural cells (right) → examine PC1 influence scores
- Example: Blood cells vs neural/dermal cells → examine PC2 influence scores
Diagnostic Tools
- Scree plot: Shows how much variation each principal component accounts for
- Desired result: Most variation accounted for by first two principal components
Technical Terminology
- Weights/Influence: Technically called "loadings" in PCA terminology
- Array of loadings: Called "eigenvector"
- Loadings: Numbers describing importance/weights for each gene to principal components
