Question: Combining ComplexHeatmap with other plot types
0
21 months ago by
my40
my40 wrote:

I have two plots that I want to place next to each other on a grid.  If they were both ggplot2 plots I'd just do something like this:

plot_grid(plot_a,plot_b,ncol=2)

using the cowplot package.

However, one of my plots I have created using the ComplexHeatmap package.  While the other is created with ggplot2.  That is:

> class(plot_a)
[1] "gg"     "ggplot"
> class(plot_b)
[1] "Heatmap"
attr(,"package")
[1] "ComplexHeatmap"

How can I combine these plots in a grid and more generally what is the recommended way of making a grid of plots of different types?

Thanks.

ggplot2 complexheatmap • 703 views
modified 21 months ago by Zuguang Gu100 • written 21 months ago by my40
Answer: Combining ComplexHeatmap with other plot types
2
21 months ago by
Zuguang Gu100
Germany
Zuguang Gu100 wrote:

You can use grid.grabExpr() to capture the output of ComplexHeatmap as a grob object and later you can arrange this grob object by other packages which do layout.

Note you need to explicitly use draw() on the heatmap object.

grob = grid.grabExpr(draw(Heatmap(...)))