1

I have 3 heatmap plots generated using CRAN package heatmap. I want to put these three images in one slide then I used the following command

cowplot::plot_grid(mfs, mfs_ma, mfs_fe,ncol= 3, labels=LETTERS[1:3])

but it return me

Warning messages: In as_grob.default(plot) :Cannot convert object of class pheatmap into a grob

Therefore,how I can put these three images in one slide.

adR
  • 173
  • 1
  • 10

1 Answers1

1

Your heatmaps mfs, mfs_ma, mfs_fe are pheatmap objects.
Consider the following simple example:

library(pheatmap)
test <- matrix(rnorm(200), 20, 10)
mfs <- mfs_ma <- mfs_fe <- pheatmap(test)

You can arrange the 3 heatmaps into a single plot using:

cowplot::plot_grid(mfs$gtable, mfs_ma$gtable, mfs_fe$gtable,
                   ncol= 3, labels=LETTERS[1:3])

or

gridExtra::grid.arrange(grobs=list(mfs$gtable, mfs_ma$gtable, mfs_fe$gtable), 
                        ncol= 3, labels=LETTERS[1:3])

enter image description here

Marco Sandri
  • 21,986
  • 7
  • 43
  • 51