-
Notifications
You must be signed in to change notification settings - Fork 244
Open
Description
Bug Report: anno_mark() row annotations misalign when row_km is used
Description
When using ComplexHeatmap::anno_mark() to annotate specific rows, the labels are positioned correctly under default conditions. However, when applying row_km (row k-means clustering), the row order is altered after the annotation is constructed, causing labels to be misaligned or disappear.
There appears to be no supported way to delay or recompute at = positions after clustering, making gene labeling incompatible with row_km.
Minimal reproducible example
library(ComplexHeatmap)
library(circlize)
set.seed(42)
# Simulate data: 50 genes x 10 samples
mat <- matrix(rnorm(500), nrow = 50, ncol = 10)
rownames(mat) <- paste0("Gene", 1:50)
colnames(mat) <- paste0("Sample", 1:10)
# Define genes to annotate
genes.to.label <- c("Gene2", "Gene10", "Gene25", "Gene40", "Gene45")
label.positions <- match(genes.to.label, rownames(mat))
# Create annotation
row.anno <- rowAnnotation(
mark = anno_mark(
at = label.positions,
labels = genes.to.label
)
)
# Test 1 - no clustering (correct labels)
Heatmap(
mat,
name = "Expression",
right_annotation = row.anno,
cluster_rows = FALSE
)# Test 2 - with clustering (correct labels)
Heatmap(
mat,
name = "Expression",
right_annotation = row.anno,
cluster_rows = TRUE
)# Test 3 - k means (breaks labels)
Heatmap(
mat,
name = "Expression",
right_annotation = row.anno,
row_km = 2
)Metadata
Metadata
Assignees
Labels
No labels


