Complex Heatmap - hide one legend, show 2 - out off three annotations
1
1
Entering edit mode
@annkatringoepfert-9610
Last seen 5.2 years ago

Hello everyone,

i create a plot with complexheatmap. It contains 3 different annotations, but I am interested in only two legends:


ha <- HeatmapAnnotation(df = df,gap = unit(c(1, 1), "mm"), 
                        col = list(status = statuslist,typePair= typePairlist,doubleEntry=entryList),
                        #get_color_mapping_param_list(entryList),
                        annotation_legend_param = list(status = list(title = "status",title_gp = gpar(fontsize = 10),
                                                                     labels_gp = gpar(fontsize = 8),
                                                                     lables= c("#FF0000" , "#0000FF"  ,"#A020F0" ), 
                                                                     at= c("normal","tumor","metastasis")),
                                                       typePair=list(title="typePair",title_gp = gpar(fontsize = 10),
                                                                     labels_gp = gpar(fontsize = 8),
                                                                     lables = c( "#FFFF00" , "#A020F0"), 
                                                                     at = c("Unpaired","NormalTumorPair")),
                                                       doubleEntry=list(title="",title_gp = gpar(fontsize = 10),
                                                                     labels_gp = gpar(fontsize = 3),
                                                                     at = c(names(entryList)),
                                                                     show_legend=FALSE,
                                                                     labels = c(entryList))))

heatmap= Heatmap(inputMatrix,na_col = "black", name="TCGA_complex heatmap - CANCER TYPE - GENE",
                   row_title = "CpG islands", row_title_side = "right",
                   column_title = "patients",column_title_side = "bottom",
                   row_dend_side = "left",
                   column_dend_side = "bottom",
                   column_dend_height = unit(2, "cm"),
                   row_dend_width = unit(2, "cm"),
                   bottom_annotation = ha,
                   column_names_gp = gpar(fontsize = 6),
                   row_names_gp = gpar(fontsize = 7),
                   column_title_gp = gpar(fontsize = 10),
                   row_title_gp = gpar(fontsize = 10),
                   heatmap_legend_param = list(title_gp = gpar(fontsize = 10),labels_gp = gpar(fontsize = 8)),
                   cluster_rows = FALSE,
                   cluster_columns = FALSE,
                   #clustering_distance_columns = ("euclidean"),
                   show_row_dend = FALSE,
                   show_heatmap_legend = TRUE,
                   #heatmap_legend_param = list(title = name, color_bar = "discrete",title_gp = gpar(fontsize = 10),labels_gp = gpar(fontsize = 8)),
                   #use_raster = TRUE
                 )

draw(heatmap, heatmap_legend_side = "top",annotation_legend_side = "left",show_heatmap_legend = FALSE)


Sadly I can't upload the resulting heatmap, but you can imagine, that I have 3 (status,typePair,doubleEntry) annotations at the bottom of the heatmap (those 3 are staying in relation together and shouldn't be separated) and I also have those corresponding legends. But I am not interested in legend doubleEntry, because it is too huge. I just wanna show the legend of status and typePair.

what settings can I use to show only 2 than 3 legends of the annotations?

 

Thanks a lot!!!!!!!!!!!

complexheatmap bioconductor annotation heatmap legend • 4.3k views
ADD COMMENT
1
Entering edit mode
jokergoo ▴ 130
@jokergoo-8506
Last seen 24 days ago
Germany

In `HeatmapAnnotation()` function, set `show_legend = c(TRUE, TRUE, FALSE)`, then it will only show legends for the first two.

ADD COMMENT
0
Entering edit mode

great!! Thanks so much!!! :)

ADD REPLY

Login before adding your answer.

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