library(ComplexHeatmap) set.seed(123) mat = matrix(rnorm(100), 10) foo = sample(letters[1:2], 10, replace = TRUE) colnames(mat) = sapply(letters[1:10], function(x) paste(rep(x, 10), collapse = "")) cn = colnames(mat) ha2 = HeatmapAnnotation(foo = foo, cn = anno_text(cn, rot = 90, offset = unit(1, "npc") - unit(2, "mm"), just = "right"), annotation_height = unit.c(unit(5, "mm"), max_text_width(cn))) Heatmap(mat, show_column_names = FALSE, bottom_annotation = ha2)
This gave me a heat map like following:
Here you see in the bottom annotation both a and b are not clustered. I would like to know how can I do each group (color) get clustered. I mean all samples which come under "b" at one side and samples under "a" on one side.
Can anyone please tell me how to do this? Thanks !!