Change fontsize/remove name of annotation ComplexHeatmap package
1
0
Entering edit mode
camillab. ▴ 10
@camillab-23642
Last seen 13 months ago
London

Hi,

How do I remove the label that is next to the annotation box in the heatmap with ComplexHeatmap ideally I would like to create a block annotation with the name of the sample in it but so far I wasn't able to do it. Also which RGB color is the best to have blue and red and not purple-bluish color in the heatmap? I have 3 samples (ctrl) and 3 treatments. I want the samples in columns and the genes in rows. here my code:

#load libraries 
library(grid) 
library("ComplexHeatmap")
library(circlize)

#set color heatmap 
colr = colorRamp2(
        seq(min(mydata), max(mydata), length = 3),
        c("#000099", "#EEEEEE", "#FF0000"),
        space = "RGB")

# annotation 
df = data.frame(sample = c(rep("CTRL", 3), rep("GENT", 3))) 
ha = HeatmapAnnotation(
            df = df, 
            col = list(sample = c("CTRL" ="black", "TREAT" = "yellow")),
            simple_anno_size = unit(2, "mm")
            )

a <- Heatmap(t(mydata),
             name = "z score", #title of legend
             width = unit(8, "cm"), height = unit(8, "cm"),
             show_column_names = FALSE,
             column_title = " ", 
             row_title = "Genes",
             col= colr,
             border = TRUE,
             column_names_gp = grid::gpar(fontsize = 9),
             column_title_gp = gpar(fontsize = 11),
             row_title_gp = gpar(fontsize = 11),
             clustering_distance_rows= "euclidean",
             clustering_distance_columns=  "euclidean",
             clustering_method_rows = "ward.D2" ,
             clustering_method_columns="ward.D2",
             row_dend_side = "left",
             top_annotation = ha)

        draw(a, merge_legend = TRUE) # join the two legends

thank you!

r rnaseq complexHeatmap annotation • 11k views
ADD COMMENT
0
Entering edit mode

Was originally posted on Biostars: https://www.biostars.org/p/443858/

ADD REPLY
1
Entering edit mode
Zuguang Gu ▴ 290
@zuguang-gu-7797
Last seen 28 days ago
Germany / Heidelberg / DKFZ
  1. set showannotationname to FALSE

  2. You don't need to use block annotation. You can first set showcolumnnames =FALSE and then add a column annotation with annotext() with setting background colors. See the last plot in https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html#text-annotation The gpar in annotext() maybe can also be set with columnnamesgp argument in Heatmap(), but I haven't tried.

  3. Can you just use blue-white-red colors? This is the default color pattern in ComplexHeatmap.

?? Outlook Mobilehttps://aka.ms/blhgte ??

ADD COMMENT
0
Entering edit mode

thank you!! I have another problem now, I cannot export in tiff/png (high resolution) the heatmap generate! I don't understand why! i have no problem with the pdf version but when I try with png or tiff I have problem!

ADD REPLY
0
Entering edit mode

Can you elaborate on what is the problem?; and also provide any status, warning, or error messages? - thank you.

ADD REPLY
0
Entering edit mode

I sorted it out! it was setting up the wrong dimension size for the image to be exported (width/height)!

ADD REPLY
0
Entering edit mode

Wonderful - thanks.

ADD REPLY

Login before adding your answer.

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