Please provide example datasets and the code you use. It will help me to understand your problem and help you!
I have made a HeatmapAnnotation with the following code, that I show below:
hm<- HeatmapAnnotation(Patient= anno_simple(info_tbl$PATIENT, pch=info_tbl$SLICE_TYPE_SYMBOL, col = patient_cols), Location= info_tbl$LOCATION_SIMPLE, Tissue= info_tbl$TYPE_OF_TISSUE, BRCAstatus= anno_simple(info_tbl$BRCA_STATUS_SIMPLE, pch= info_tbl$HRD_TEST_SYMBOL, col= brca_col), Timepoint= anno_simple(info_tbl$CLINICAL_TIMEPOINT_SPEC, pch = info_tbl$FIRST_PT_STATUS_SYMBOL, col= tmpt_col), col= list(Location= loc_cols, Tissue = tiss_cols) )
Because I have three anno_simple with symbols, I need to add those legends manually, both for the colors and the meanings of the symbols itself (similar to the reference 3.2 with the p value colors & pch legend). However, it seems because this is a HeatmapAnnotation, and not a heatmap, I cannot manually add the legend for some reason. For example, if I make a legend just for Patient colors:
I also tried to add the legend to the HeatmapAnnotation function itself, with annotation_legend_param, but I get an error for that as well, though the names clearly match:
hm<- HeatmapAnnotation(Patient= anno_simple(info_tbl$PATIENT,
pch=info_tbl$SLICE_TYPE_SYMBOL, col = patient_cols),
Location= info_tbl$LOCATION_SIMPLE,
Tissue= info_tbl$TYPE_OF_TISSUE,
BRCAstatus= anno_simple(info_tbl$BRCA_STATUS_SIMPLE,
pch= info_tbl$HRD_TEST_SYMBOL, col= brca_col),
Timepoint= anno_simple(info_tbl$CLINICAL_TIMEPOINT_SPEC,
pch = info_tbl$FIRST_PT_STATUS_SYMBOL, col= tmpt_col),
col= list(Location= loc_cols, Tissue = tiss_cols),
annotation_legend_param = list(Patient= list(
title= "Patient", legend_gp = gpar(fill =patient_cols), at= names(patient_cols)
)
)
)
Error: Some names in 'annotation_legend_param' are not in names of simple annotations.
How might I be able to add manual legends to the HeatmapAnnotation in this case? I haven't seen anything in the documentation about this being done.
I have made a HeatmapAnnotation with the following code, that I show below:
hm<- HeatmapAnnotation(Patient= anno_simple(info_tbl$PATIENT, pch=info_tbl$SLICE_TYPE_SYMBOL, col = patient_cols), Location= info_tbl$LOCATION_SIMPLE, Tissue= info_tbl$TYPE_OF_TISSUE, BRCAstatus= anno_simple(info_tbl$BRCA_STATUS_SIMPLE, pch= info_tbl$HRD_TEST_SYMBOL, col= brca_col), Timepoint= anno_simple(info_tbl$CLINICAL_TIMEPOINT_SPEC, pch = info_tbl$FIRST_PT_STATUS_SYMBOL, col= tmpt_col), col= list(Location= loc_cols, Tissue = tiss_cols) )
Because I have three anno_simple with symbols, I need to add those legends manually, both for the colors and the meanings of the symbols itself (similar to the reference 3.2 with the p value colors & pch legend). However, it seems because this is a HeatmapAnnotation, and not a heatmap, I cannot manually add the legend for some reason. For example, if I make a legend just for Patient colors:
It looks fine using
draw(pat_leg)
, but I am unable to do the following:I also tried to add the legend to the HeatmapAnnotation function itself, with
annotation_legend_param
, but I get an error for that as well, though the names clearly match:How might I be able to add manual legends to the HeatmapAnnotation in this case? I haven't seen anything in the documentation about this being done.