adding margins around pheatmap plots
1
1
Entering edit mode
@stephaneplaisance-11262
Last seen 5.5 years ago

when I generate pheatmap to file using do.call the bottom of the legend is not printed (but visible when not using the file output)

How can I add margins when plotting to file? I tried par() but it does not influence the plotting to file apparently...

Here is my code working for the first live plot but cutting the second in the legend.

# prepare output
filename <- pastesig.name,"-signature-heatmap.pdf",sep="")
outfile <- paste(basedir, filename, sep="/")

main.title <- pastesig.name,"signature", sep=" ")

# color pallet
col.pal <- brewer.pal(9,"Blues")

# define metrics for clustering
drows <- "euclidean"
dcols <- "euclidean"
clustmet <- "average"

# create heatmap
# type "?pheatmap()" for more help
hm.data <- log(selection[,2:length(selection)], 2)
hm.parameters <- list(hm.data, 
                      color = col.pal,
                      fontsize = 8,
                      cellwidth = 12, cellheight = 12, scale = "none",
                      treeheight_row = 200,
                      kmeans_k = NA,
                      show_rownames = T, 
                      show_colnames = T,
                      main = main.title,
                      clustering_method = clustmet,
                      cluster_rows = TRUE, 
                      cluster_cols = TRUE,
                      clustering_distance_rows = drows, 
                      clustering_distance_cols = dcols)

# To draw the heatmap on screen (comment-out if you run the script from terminal)
do.call("pheatmap", hm.parameters)

# To draw to file 
do.call("pheatmap", c(hm.parameters, filename=outfile))

 

 

 

pheatmap • 5.8k views
ADD COMMENT
0
Entering edit mode
@wolfgang-huber-3550
Last seen 10 weeks ago
EMBL European Molecular Biology Laborat…

Stephane

Have you tried with specifying the width and height arguments to the function (output file width and height). Alternatively, open (and later close) the pdf device yourself (with call to the function pdf) and specify the width and height arguments.

Wolfgang

ADD COMMENT

Login before adding your answer.

Traffic: 794 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6