0
$\begingroup$

I have 2 dataframe with same genes both different data sets

like

> head(heat1[1:3,1:4])
             A10         A11        A12        A2
ATP5F1 2.1163092  0.32044094 -0.5661269 0.7978236
DDX5   0.6277182 -1.67055853 -0.0123082 0.8895472
EEF1G  1.6459212  0.02923401 -1.2737676 0.5842162
> 

> head(heat2[1:3,1:4])
              A10        A12          A3          A4
A2M    -0.6031969  0.6378864 0.000573381 -0.07769313
ABCB11  0.5600164  0.3087120 0.171636836  1.25681512
ABCC2   0.2093133 -0.5608016 0.782278709  0.16618683
>

I want to plot them side by side with the same order of genes

I tried

> ht1 = Heatmap(heat1)
> ht2 = Heatmap(heat2)
> ht_list = ht1 + ht2
> draw(ht_list, ht_gap = unit(1, "cm"))
Warning message:
Row names of heatmap 2 is not consistent as the main
heatmap (1) 

But I getting not the same order of genes

enter image description here

Can you help me with this?

$\endgroup$

1 Answer 1

3
$\begingroup$

Please read through the ComplexHeatmap manual, especially the section on row and column orders: https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#get-orders-and-dendrograms-from-heatmap

You can use row_order and column_order following a draw() (which you can nest between a pdf(null) and dev.off() to disable drawing it on any device). That way, you'll be sure to get the right order from the first heatmap to use with the second.

By nesting, I mean like so:

h1 <- Heatmap(...)
pdf(NULL)
h1d <- draw(h1)
dev.off()
ro1 <- row_order(h1d)
co1 <- column_order(h1d)

Use whichever (row/column) order is appropriate to gene order.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.