This works. Thank you so so much!
• 0 views
•
link
I am trying to work get the fontsize of a heatmap rowannotation customized. How can I achieve this endeavor?
Here is my code:
mark_at = which(rownames(mat_ht) %in% gene_names_interesting_in_clusters) # look up label names which should be displayed
ha = rowAnnotation(text = anno_mark(at = mark_at, labels = gene_names_interesting_in_clusters),annotation_name_gp = gpar(fontsize = 2)) # set rowAnnotations and change fontsize
if (save_plots=='yes') {
tiff(file="heatmap_genes_of_upreg_upon_aRinp100test.tiff",width = 6, height = 6, units = 'in',res = 600)
}
Heatmap(mat_ht, name = "Z-score", cluster_rows = TRUE, cluster_columns = FALSE, right_annotation = ha,
show_row_names = FALSE, show_column_names = FALSE,row_names_gp = gpar(fontsize = 4), km=16,row_title_gp = gpar(fontsize = 4))
if (save_plots=='yes') {
dev.off()
} # create heatmap
Many thanks in advance!
set.seed(1)
m = matrix(rnorm(100), nrow = 10)
rownames(m) = 1:10
# normal
ha = rowAnnotation(foo = anno_mark(at=1:nrow(m), labels=rownames(m)))
Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha, show_row_names = FALSE)
# bigger labels
ha = rowAnnotation(foo = anno_mark(at=1:nrow(m), labels=rownames(m), labels_gp = gpar(fontsize=20)))
Heatmap(m, name = "mat", cluster_rows = FALSE, right_annotation = ha, show_row_names = FALSE)
The labels_gp within anno_block is the key.
This works. Thank you so so much!
A small educational note: if an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they work. This will help future users that might find this post find the right answer.

Log in to answer this question.
Try tweaking the
gpof the rowAnnotation instead of tweaking theannotation_name_gp- that might do the trick.Thank you. What exactly do you mean? Changing
ha = rowAnnotation(text = anno_mark(at = mark_at, labels = gene_names_interesting_in_clusters),annotation_name_gp = gpar(fontsize = 2))toha = rowAnnotation(text = anno_mark(at = mark_at, labels = gene_names_interesting_in_clusters),gp = gpar(fontsize = 2))?Yes. The solution to most things with ComplexHeatmap is to play around with parameters.
It doesn't work. The annotation labels are still in a default fontsize. I cant find a way to set the fontsize.
Please check out in this link.
Thanks for the input. Unfortunately, that didn't help either. I appreciate any other tips.
Thank you
I still cannot find a way. It seems to be an easy to solve issue and I was trying any possible combination with the aforementioned gp=gpar(fontsize=...) solutions. However, I wasnt able to resolve it. Can please someone help? Thank you
Please do not add answers unless you're actually answering the question. I've moved your post to a comment.