How to save the heatmap into a directory or as pdf

Hello,

I am including my script below. I am creating a heatmap here and this code will draw the image within the console. Is there a way that I can save these images directly to a directory or save as pdf?

h_map = Heatmap(as.matrix(cormat), #dat_row_scaled,
name = "sample",
col = colorRamp2(c(0,0.5,1), c(colors[2], "white", colors[1])),
cluster_columns=TRUE,
cluster_rows=TRUE,
show_column_dend=FALSE,
show_row_dend=FALSE,
show_column_names = TRUE,
show_row_names = TRUE,
column_names_gp = gpar(fontsize = font_size * 0.8),
row_names_gp = gpar(fontsize = font_size * 0.8),
row_names_side = "left",

            column_title = "", 
            column_title_gp = gpar(fontsize = font_size * 0.9),
            heatmap_legend_param = list(direction = "vertical"))

ht_list = h_map

draw(ht_list, heatmap_legend_side = "right", annotation_legend_side = "bottom")

Here are several ways.

I would probably just do

png("mymap")
draw(ht_list, heatmap_legend_side = "right", annotation_legend_side = "bottom")
devoff()

It worked! Thank you!

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.