ComplexHeatmap - How to change fontsize of rowAnnotation
1
0
Entering edit mode
15 days ago

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!

r ComplexHeatmap • 846 views
ADD COMMENT
0
Entering edit mode

Try tweaking the gp of the rowAnnotation instead of tweaking the annotation_name_gp - that might do the trick.

ADD REPLY
0
Entering edit mode

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)) to ha = rowAnnotation(text = anno_mark(at = mark_at, labels = gene_names_interesting_in_clusters),gp = gpar(fontsize = 2))?

ADD REPLY
0
Entering edit mode

Yes. The solution to most things with ComplexHeatmap is to play around with parameters.

ADD REPLY
0
Entering edit mode

It doesn't work. The annotation labels are still in a default fontsize. I cant find a way to set the fontsize.

ADD REPLY
0
Entering edit mode

Please check out in this link.

ADD REPLY
0
Entering edit mode

Thanks for the input. Unfortunately, that didn't help either. I appreciate any other tips.

Thank you

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Please do not add answers unless you're actually answering the question. I've moved your post to a comment.

ADD REPLY
4
Entering edit mode
8 days ago
ATpoint 83k
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)

enter image description here

# 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)

enter image description here

The labels_gp within anno_block is the key.

ADD COMMENT
0
Entering edit mode

This works. Thank you so so much!

ADD REPLY
0
Entering edit mode

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.

upvote_bookmark_accept

ADD REPLY

Login before adding your answer.

Traffic: 1081 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