10: Advanced Omics Heatmaps & Clustering
Chapter 10: Advanced Omics Heatmaps & Clustering with ComplexHeatmap
Heatmaps are indispensable for visualizing multi-sample transcriptomic, epigenomic, and proteomic matrices. ComplexHeatmap enables publication-grade clustered heatmaps with multi-track clinical annotations, row splitting, and dendrogram pruning.
1. Row-wise Z-Score Standardization
Standardizing expression values ($Z = \frac{x - \mu}{\sigma}$) centers gene profiles around zero for direct pattern comparison:
mat_z <- t(scale(t(counts_matrix)))2. Multi-Track Clustered Heatmap
library(ComplexHeatmap)
library(circlize)
col_fun <- colorRamp2(c(-2, 0, 2), c("#2563EB", "#FFFFFF", "#DC2626"))
ha_top <- HeatmapAnnotation(
Subtype = sample_anno$Subtype,
Response = sample_anno$Response,
col = list(
Subtype = c("Basal-like" = "#E11D48", "Luminal A" = "#059669", "HER2+" = "#7C3AED"),
Response = c("Responder" = "#10B981", "Non-Responder" = "#64748B")
)
)
Heatmap(
mat_z,
name = "Z-Score",
col = col_fun,
top_annotation = ha_top,
clustering_distance_rows = "pearson",
clustering_method_rows = "ward.D2",
column_title = "Oncogenic Transcriptomic Profile"
)