jokergoo / ComplexHeatmap

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

row order in `draw(ht1+ht2)` #824

Closed blueskypie closed 2 years ago

blueskypie commented 2 years ago

In the following code from docs

ht1 = Heatmap(mat1, name = "rnorm")
ht2 = Heatmap(mat2, name = "runif")
ht3 = Heatmap(le, name = "letters")

let mat0=cbind(mat1,mat2,le), is the row clustering of draw(ht1 + ht2 + ht3) computed on mat0?

How to make the row clustering be computed on mat1 only? mat2 and le just use the same row order from the row clustering of mat1.

jokergoo commented 2 years ago

For the following

ht1 = Heatmap(mat1, name = "rnorm")
ht2 = Heatmap(mat2, name = "runif")
ht3 = Heatmap(le, name = "letters")
draw(ht1 + ht2 + ht3)

The row order is determined by the first numeric matrix which is "rnorm".

If you want the row order from the combined matrix:

mat0=cbind(mat1,mat2,le)
row_order = hclust(dist(mat0))
ht1 = Heatmap(mat1, name = "rnorm", row_order = row_order)
ht2 = Heatmap(mat2, name = "runif")
ht3 = Heatmap(le, name = "letters")
draw(ht1 + ht2 + ht3)
blueskypie commented 2 years ago

So, if the row_order is set in Heatmap, draw won't hclust again?

jokergoo commented 2 years ago

Yes, Heatmap() is a constructor function, so all settings are there.