Multiple plots with pheatmap

I have a problem plotting these on the same page. I used the "pheatmap" function to generate four heatmaps and want to place them side-by-side. I used the grid. arrange function to generate the map but did not work. Any help will greatly appreciated

##Era-interim
THIera <- read.csv("F:/DISSERTATION FOLDER/Grids/mydata/HI_DI/era/THI/era_seasTHI.csv", row.names = 1)

THI_interim <- pheatmap(THIera, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "Era-interim: Temperature-Humidity Index",
       display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45")



## GFDL-ESM2M
THIgfd <- read.csv("F:/DISSERTATION FOLDER/Grids/mydata/HI_DI/gfd_ref/THI/gfd_seasTHI.csv", row.names = 1)

THI_gfdl <- pheatmap(THIgfd, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "GFDL-ESM2M: Temperature-Humidity Index",
         display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45")

## HadGEM2-ES
THIhad <- read.csv("F:/DISSERTATION FOLDER/Grids/mydata/HI_DI/had_ref/THI/had_seasTHI.csv", row.names = 1)

THI_hadgem <- pheatmap(THIhad, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "HadGEM2-ES: Temperature-Humidity Index",
        display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45")


## MPI-ESM MR
THImpi <- read.csv("F:/DISSERTATION FOLDER/Grids/mydata/HI_DI/mpi_ref/THI/mpi_seasTHI.csv", row.names = 1)

THI_mpiesm <- pheatmap(THImpi, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "MPI-ESM MR: Temperature-Humidity Index",
         display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45")



grid.arrange(THI_interim,THI_gfdl,THI_hadgem, THI_mpiesm, ncol=2)



<sup>Created on 2019-08-24 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)</sup>

Could you share sample data on a copy/paste friendly format? we don't have access to your local files so we can't reproduce your issue (also you are not including library calls).

After a quick internet search I found this related thread how to plot multi pheatmap into one figure but I couldn't test the solution since I don't have access to sample data.

Yeah, read up on that but could not make meaning of what the person did.

Sure but the sample data is in .csv . this is the link to the file.

Kindly let me know if you are able to access it.

Thanks

First of all, that is just one file, in your example you are using multiple files, also, it would help if you could provide a proper self-contained reproducible example, including library calls, sufficient sample data and relevant code.

the folder link below contains all the files I used

The package I used is install.packeges("pheatmap")

https://drive.google.com/drive/folders/1hZNH8Y_rql4lDIi3Ke53YIISYB3ST8Nk?usp=sharing

For future reference this is what I meant by a self-contained reproducible example, it is an example of the solution described in the link I gave you, although I don't know how to fix the grid layout.

library(pheatmap)
library(purrr)
library(gridExtra)

THIera <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download",
                       "1CtB_5jqmah5DUtu2S5FpTTaSFvkA7tUH"), row.names = 1)
THIgfd <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download",
                           "1TF-h97HJqCjbLc-vYTf9_GR8H7OcFpXC"), row.names = 1)
THIhad <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download",
                           "1c3Cmkg3jimUGucNnlhKAmKL-1p113xL3"), row.names = 1)
THImpi <- read.csv(sprintf("https://docs.google.com/uc?id=%s&export=download",
                           "1EziU-s_kDpOD2Yyhqj0M9HVJkWmD-64M"), row.names = 1)

THI_interim <- pheatmap(THIera, cluster_rows = FALSE, cluster_cols = FALSE, fontsize = 10, main = "Era-interim: Temperature-Humidity Index",
                        display_numbers = FALSE, cellwidth = 25, cellheight = 12, angle_col = "45", silent = TRUE)

THI_gfdl <- pheatmap(THIgfd, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "GFDL-ESM2M: Temperature-Humidity Index",
                     display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45", silent = TRUE)

THI_hadgem <- pheatmap(THIhad, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "HadGEM2-ES: Temperature-Humidity Index",
                       display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45", silent = TRUE)

THI_mpiesm <- pheatmap(THImpi, cluster_rows = FALSE, cluster_cols = FALSE,fontsize = 10, main = "MPI-ESM MR: Temperature-Humidity Index",
                       display_numbers = FALSE, cellwidth = 25,cellheight = 12, angle_col = "45", silent = TRUE)

plot_list <- ls(pattern = "THI_") %>% 
  map(~eval(as.name(.))[[4]])

grid.arrange(arrangeGrob(grobs = plot_list, ncol=2))

Created on 2019-08-24 by the reprex package (v0.3.0)

Thank you Andresrcs. This is very helpful! also, thanks for the reproducible format. It is well-noted

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.