1
$\begingroup$

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)

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.

Also show_annotation_name = TRUE,show_legend = TRUE did not work

$\endgroup$
0

1 Answer 1

1
$\begingroup$

Answer from @ram-rs, converted from comment:

For the Group, try using it without the anno_simple. Just Top_ha = HeatmapAnnotation(Group=top$Group, "Total Mutation Burden" = ...), nothing else for Group. See if that generates a legend at all. We can customize later.hing else for Group. See if that generates a legend at all. We can customize later.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.