jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.31k stars 228 forks source link

ComplexHeatmap with specific rownames #1174

Open ManarRashad opened 7 months ago

ManarRashad commented 7 months ago

Dears, I am trying to draw a heatmap using ComplexHeatmap package and don't want to show the rownames except row number 283.

I wrote the following code:

desired_row_index <- 283

Heatmap(scoresPathway, name = "Z-score", show_column_names = FALSE, column_title = "Cluster.1scorespathway", column_title_side = "top", column_title_gp = gpar(fontsize = 20), cluster_columns = TRUE, clustering_distance_columns = "euclidean", clustering_method_columns = "ward.D2", cluster_rows = TRUE, show_row_names = gpar(ifelse(1:nrow(scoresPathway) == desired_row_index, TRUE, FALSE)), row_names_gp = gpar(col = "red"), clustering_distance_rows = "euclidean", clustering_method_rows = "ward.D2", column_dend_height = unit(1.5, "cm"), row_dend_width = unit(1.5, "cm"))

but I don't know where is the problem with using if condition in show_row_names.

As I always get this error:

Error in if (show_row_names) { : argument is not interpretable as logical

Could you help me with this? or even how I make this row with red and others with black?

Thanks,

Yunuuuu commented 5 months ago

You can set the labels with Heatmap

library(ComplexHeatmap)
m <- matrix(rnorm(100), 10)
rownames(m) <- paste0("Gene", seq_len(nrow(m)))
colnames(m) <- paste0("Cell", seq_len(ncol(m)))
Heatmap(m, row_labels = c("a", rep_len("", 9)))

image