Skip to main content
1 of 4
Zizogolu
  • 2.2k
  • 1
  • 14
  • 46

Adding legend to Botton and top annotation in complexheatmap

I have a heat map but top and bottom annotation don't have legend

Top_ha = HeatmapAnnotation(Group = anno_simple(top$Group, 
                                               col =structure(hue_pal()(length(unique(top$Group))), 
                                                              names = unique(top$Group)),
                                           border = TRUE, 
                                           height = unit(5, "mm")),
                       "Total Mutation Burden"=anno_barplot(clin$TMB, height = unit(15, "mm"), width=unit(30, "mm"),gp = gpar(fill = structure(hue_pal()(length(unique(clin$TMB))), 
                                                                                                                                               names = unique(clin$TMB)))))



Bottom_ha = HeatmapAnnotation(Response = anno_simple(clin$Response, 
                                                 border = T, 
                                                 col = structure(c("purple4", "grey"), names = c("Responders", "NonResponders")),
                                                 height = unit(5, "mm"),show_),
                          "TP53 Status" = anno_simple(clin$TP53_status, 
                                                          border = TRUE, 
                                                          col = structure(c("firebrick", "grey"), names = c("Mutant","Wild type")),
                                                          height = unit(5, "mm")))


Right_Anno <- HeatmapAnnotation(Signature = anno_text(right$Signature), which = "row")

Heatmap(mat,
        bottom_annotation = Bottom_ha,
        top_annotation = Top_ha,
        name = "Exposure",
        right_annotation = Right_Anno,
        show_row_dend = FALSE,
        show_parent_dend_line = FALSE,
        column_split = c(top$Group),
        column_title = c("Mutagenic", "DDR Impaired", "C>A/T Dominant"),
        col = colorRamp2(c( 0, 0.5), c("white", "red")),
        show_column_names = FALSE)

Rplot05

As you are seeing Response, group and total mutation burden don't have any legend and annotation

Please can you help me to put legend for annotation?

I have tried annotation_lable but says Error: either provide levelsor provide namedcolors.

Zizogolu
  • 2.2k
  • 1
  • 14
  • 46