Dear useRs,
Below a small chunk of code to illustrate an issue with generating heatmaps using the Heatmap function within the ComplexHeatmap package.
# this works fine, a pdf file gets generated and can be opened:
dat <- matrix(rnorm(200), 10)
pdf("heatmap.pdf", width = 15, height = 5)
Heatmap(dat)
dev.off()
# a for loop around also generates files (from the code below just 1)
for (i in 1){
dat <- matrix(rnorm(200), 10)
pdf(paste0("heatmap", i, ".pdf"), width = 15, height = 5)
Heatmap(dat)
dev.off()
}
# However, trying to open the file results in this error message in Acrobar reader (Version 10.1.8): “The file cannot be opened because it has no pages”
# a for loop around the heatmap.2 function from the gplots library works fine (but adjusting the plot is less flexible)
library(gplots)
for (i in 1)
dat <- matrix(rnorm(200), 10)
pdf(paste0("heatmap", i, ".pdf"), width = 15, height = 5)
heatmap.2(dat)
dev.off()
}
It would be very nice if someone knows a work around.
Thanks a lot in advance!
Best regards,
An
>sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] gplots_2.17.0 ComplexHeatmap_1.6.0 rj_2.0.4-2
loaded via a namespace (and not attached):
[1] rj.gd_2.0.0-1 circlize_0.3.4 dendextend_1.1.8
[4] gtools_3.5.0 bitops_1.0-6 magrittr_1.5
[7] KernSmooth_2.23-15 GlobalOptions_0.0.8 gdata_2.17.0
[10] whisker_0.3-2 GetoptLong_0.1.1 RColorBrewer_1.1-2
[13] rjson_0.2.15 tools_3.2.2 colorspace_1.2-6
[16] caTools_1.17.1 shape_1.4.2
Great, thanks a lot, that works indeed!
Best regards,
An
I'm trying to save list of heatmaps after doing this
The to save I tried something like this
The error is this
Although the hm_list class is list bt still im not able to save it. Any suggestion what Im doing grossly wrong
What is
hm_list
? I would not useggsave()
to save the heatmaps. Can you directly use:yes it worked