jokergoo / jokergoo.github.io

Personal website
https://jokergoo.github.io
4 stars 0 forks source link

2021/03/05/cluster-groups-in-complexheatmap/ #6

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Cluster groups in ComplexHeatmap - A Bioinformagician

https://jokergoo.github.io/2021/03/05/cluster-groups-in-complexheatmap/

crazyhottommy commented 3 years ago

Amazing, Zuguang! There are so many gems in this blog.

jokergoo commented 3 years ago

Thank you Tommy!

raerose01 commented 1 year ago

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?

adesalegn commented 6 months ago

@crazyhottommy and @jokergoo, is there any possibility ordering from left to right (a,b,c)?

kbrulois commented 2 months ago

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")))))

kbrulois commented 2 months ago

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) }))))