ComplexHeatmap icon indicating copy to clipboard operation
ComplexHeatmap copied to clipboard

I want to remove the main body of heatmap

Open nolanjj opened this issue 2 years ago • 2 comments

Please provide example datasets and the code you use. It will help me to understand your problem and help you!

help! I want to remove the main body of heatmap.Keep the cluster tree and comments at the top.What should I do

nolanjj avatar May 31 '23 09:05 nolanjj

I guess you only want the dendrogram and the top annotation? Then you can do it in two steps:

  1. generate the clustering object:
set.seed(123)
m = matrix(rnorm(200), 20, 10)
hc = hclust(dist(t(m)))
  1. since you don't need the heatmap body but want to keep the dendrogram, you need to create a zero-row matrix:
m_zero = matrix(nrow = 0, ncol = 10)

Then creating the top annotation. Note here I move the annotation names to the left so that they will not overlap with the legend.

ha = HeatmapAnnotation(foo = 1:10, bar = anno_points(runif(10)),
    annotation_name_side = "left")

And finally put everything together:

Heatmap(m_zero, top_annotation = ha, cluster_columns = hc)
image

jokergoo avatar Jun 05 '23 13:06 jokergoo

Heatmap(m_zero, top_annotation = ha, cluster_columns = hc)

Thank you! ComplexHeatmap is too powerful!

nolanjj avatar Jun 06 '23 06:06 nolanjj