omics.co.in

Chapter 5: Dimensionality Reduction: PCA, t-SNE & UMAP Geometry

Chapter 5: Dimensionality Reduction: PCA, t-SNE & UMAP Geometry

A single-cell dataset with 20,000 cells and 3,000 highly variable genes represents a 3,000-dimensional hypercube. Due to the "curse of dimensionality", Euclidean distance metrics lose discriminatory power in high dimensions. Dimensionality reduction compresses data into low-dimensional representations while retaining essential biological variance and topological structure.

Linear vs. Non-Linear Reduction
  • Principal Component Analysis (PCA): Linear orthogonal projection. Preserves global variance and distances. Essential as an intermediate step to filter high-frequency noise before non-linear visualization.
  • t-SNE & UMAP: Non-linear manifold learning. Compress high-dimensional manifolds down to 2D for human visualization, prioritizing local neighborhood preservation.

1. Principal Component Analysis (PCA)

PCA computes orthogonal linear combinations of highly variable genes that maximize captured variance across cells.

# Seurat PCA workflow
pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc), npcs = 50)

# Inspect top genes driving PC1 and PC2
VizDimLoadings(pbmc, dims = 1:2, reduction = "pca")

# Plot PCA scatter
DimPlot(pbmc, reduction = "pca", group.by = "orig.ident")

2. Determining the Number of Significant PCs

Choosing too few PCs discards subtle biological subpopulations (e.g. dendritic cells); choosing too many includes technical noise. Two standard methods help determine the cutoff:

  1. Elbow Plot: Plots the standard deviation of each PC. Look for the "elbow" point where the curve flattens out (typically around PC 20–30).
  2. JackStraw Resampling: Permutes a subset of data (1%) and recalculates PCA to assign empirical \(p\)-values to PC loadings.
# Generate Elbow Plot
ElbowPlot(pbmc, ndims = 40)

3. t-SNE vs. UMAP: Algorithmic Architecture

While both algorithms project high-dimensional data into 2D, their mathematical formulations differ substantially:

  • t-Distributed Stochastic Neighbor Embedding (t-SNE): Models pairwise Euclidean distances as probabilities under a Gaussian distribution in high dimensions and a Student-t distribution in low dimensions. It minimizes Kullback-Leibler (KL) divergence. t-SNE excels at preserving local neighborhoods but distorts global inter-cluster relationships and scales poorly to large cell numbers.
  • Uniform Manifold Approximation and Projection (UMAP): Grounded in Riemannian geometry and algebraic topology. UMAP assumes data lies on a local Riemannian manifold with a fuzzy simplicial set. It preserves both local neighborhoods and broader global continuity, executes significantly faster, and scales efficiently to millions of cells.

4. Executing UMAP and Hyperparameter Tuning

# Seurat UMAP execution
pbmc <- RunUMAP(
    pbmc, 
    dims = 1:30, 
    n.neighbors = 30,    # Number of nearest neighbors (controls local vs global focus)
    min.dist = 0.3,       # Minimum distance between points in low-dim space (controls compactness)
    metric = "cosine"     # Distance metric
)

DimPlot(pbmc, reduction = "umap", label = TRUE)
# Scanpy PCA and UMAP workflow in Python
sc.tl.pca(adata, svd_solver='arpack', n_comps=50)
sc.pl.pca_variance_ratio(adata, log=True)

# Build k-NN neighborhood graph in PC space
sc.pp.neighbors(adata, n_neighbors=25, n_pcs=30, metric='cosine')

# Compute UMAP embedding
sc.tl.umap(adata, min_dist=0.3, spread=1.0)
sc.pl.umap(adata, color=['CD3D', 'MS4A1', 'CD14', 'NKG7'])
← Return to Home Hub Scroll to Top ↑