This is a test version of Biostars. For the public version, visit https://www.biostars.org.
pheatmap lengends are being cutoff

I'm trying to removed annotations for the heat map legend. Originally this what the heatmap looks like using the following code:
pheatmap(M.adj, annotation_col = conds, #dropData set border_color = NA, filename = "QC/QCheatmap.pdf", color = colorRampPalette(rev(brewer.pal(n=11, name="RdBu")))(100), cluster_cols = TRUE, show_rownames = FALSE, main=paste("Gene Expression (VST) of Top 1000 Variable Genes") )

heat map1

when I drop my "dataset" colm using the following piece of code, my legends is cutoff.

pheatmap(M.adj, annotation_col = conds[2,drop=F], #dropData set border_color = NA, filename = "QC/QCheatmap.pdf", color = colorRampPalette(rev(brewer.pal(n=11, name="RdBu")))(100), cluster_cols = TRUE, show_rownames = FALSE, main=paste("Gene Expression (VST) of Top 1000 Variable Genes") )

heatmap 2

anyone know how I can make it so that my legend is not cut off in the second heat map?

pheatmap legends rstudio heatmaps

2 answers

Save the pheatmap output and then change the viewport using gridExtra.

p <- pheatmap(M.adj, ..)
gridExtra::grid.arrange(p$gtable, vp=viewport(width=0.9, height=1))

Hi!

You can scale the plotting text with cex. In this case the default value is cex = 1, 1.5 would correspond to 50% larger and 0.5 50% smaller. So, use different values less than 1 until you see the whole text legend.

Best regards

Hi rodolfo! Thank you!! I'll try what you suggested. I got around it by making the naming conventions of my conditions shorter. I'll try what you suggested and to see if I can keep the length of my conditions.

Thank you for you time:)

Log in to answer this question.