Open utterances-bot opened 3 years ago
Amazing, Zuguang! There are so many gems in this blog.
Thank you Tommy!
Hi @jokergoo, I may be missing something simple, but is there a way to generate the same plots as above without having the labels "b", "a", and "c" printed above the dendrogram?
@crazyhottommy and @jokergoo, is there any possibility ordering from left to right (a,b,c)?
Hi @jokergoo Thanks for the wonderful package. Was wondering how can I make anno_block annotations responsive to the column cluster reordering in this example and in general?
library(ComplexHeatmap) set.seed(372) m = matrix(rnorm(120), nc = 12) colnames(m) = 1:12 fa = rep(c("a", "b", "c"), times = c(2, 4, 6)) fa_col = c("a" = 2, "b" = 3, "c" = 4) dend1 = cluster_between_groups(m, fa) Heatmap(m, cluster_columns = dend1, column_split = 3, top_annotation = c(HeatmapAnnotation(foo = fa, col = list(foo = fa_col)), HeatmapAnnotation(bar = anno_block(gp = gpar(fill = 2:4), labels = c("a", "b", "c")))))
Nevermind figured it out using the align_to and panel_fun arguments.
In case anyone else has the same question:
Heatmap(m, cluster_columns = dend1, column_split = 3, top_annotation = c(HeatmapAnnotation(foo = fa, col = list(foo = fa_col)), HeatmapAnnotation(bar = anno_block(align_to = list(a = 1:2, b = 3:6, c = 7:12), panel_fun = function(index, levels) { grid.rect(gp = gpar(fill = fa_col[levels])) grid.text(levels, 0.5, 0.5) }))))
Cluster groups in ComplexHeatmap - A Bioinformagician
https://jokergoo.github.io/2021/03/05/cluster-groups-in-complexheatmap/