Adjust width of annotations in pheatmap
Is there a way to adjust the width of row annotations in pheatmap? or are there heatmap programs that will allow for this?
• 6,140 views
•
link
1 answer
Hi Divya,
In pheatmap, there's no direct parameter to adjust the width of row annotation tracks, as they're sized automatically based on content and font. However, you can minimise the space indirectly by reducing the font size or hiding the annotation labels entirely.
Try this in your pheatmap call:
pheatmap(mat, annotation_row = ann_row,
fontsize = 8, # Smaller font reduces annotation width
annotation_names_row = FALSE) # Hides row annotation labels
For more precise control over annotation widths, alternatives like ComplexHeatmap from Bioconductor do allow explicit sizing (e.g., via width = unit(1.5, "cm") in rowAnnotation).
Kevin
• 0 views
•
link
Log in to answer this question.
Heatmap functions have a ton of parameters in their readme. Have you read the manual thoroughly? Please show us you have invested some effort.
I went over the entire help section and also looked through the forums to see if this had been done with pheatmap and couldnt find anything. I spent quite some time (I am new to this) trying to figure out a heatmap function to draw multiple annotations. I was initially using heatmap.2 which allows for adjusting the size of the annotation but doesnt allow for multiple annotations. I currently have an image like this (https://i.postimg.cc/Y9Kh0RK3/Sample-Chip.png) when ideally i would like something around this size (made with heatmap.2) https://i.postimg.cc/7PTrm4zf/Sample-Image-2.png
See How to add images to a Biostars post to add your images properly.
Thanks. I ended up using ComplexHeatmap. It had more options that I needed.
That looks like a
themesetting foraxis.text.yandaxis.ticks.yin ggplot context. Does pheatmap not have relevant settings?EDIT: I see at least 2-3 options addressing this issue. Have you tried tweaking
show_colnamesorfontsize_col? What options have you tried?I agree with you
I faced a similar problem with pheatmap, and have switched to ComplexHeatmap, although the options are plenty, I couldn't quite figure out, how exactly to match the rownames of the matrix to its corresponding enrichment term as done in pheatmap annotations. Could you share how you solved this issue ? Thanks !!!