omics.co.in

10: Advanced Omics Heatmaps & Clustering

๐Ÿ“Š Downloadable Lesson R Script 4.1 KB

r10_complexheatmaps_clustering.R

Row-wise Z-score normalization, hierarchical clustering (Pearson/Ward.D2), multi-track clinical column annotations (Subtypes, Stages), and publication-ready export.

$ Rscript r10_complexheatmaps_clustering.R

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"
)
← Return to Home Hub Scroll to Top ↑