Entering edit mode
2.5 years ago
swbarnes2
14k
Is it possible to get the legend in a pheatmap to output a Genotype with a superscript in the name?
I've tried using expression(p^n)
, but it gets flattened to text in the annotation data frame
annotation <- data.frame(row.names= rownames(anno))
annotation$Genotype <- anno$Genotype
annotation$Day_factor <- anno$Day_factor
ann_colors <- list(Genotype = c("Control" = "skyblue", "not_control" = "pink"),
Day_factor = c("0" = "#EDF8FB", "7" = "#BEE6E7", "14" = "#83CEBC", "21" = "#4DB486", "28" = "#2CA25F"))
pheatmap(first_heatmap, main = "First Heatmap", annotation_colors = ann_colors,
color = heatmap_colors, show_rownames=T, scale = "row", cluster_col = F , cluster_rows = T, show_colnames = F,
annotation= annotation, treeheight_row = 0)
Can you switch to ComplexHeatmap? It supports complex formatting with
grid.text
.Yeah, that works, even without grid.text,
It's because ComplexHeatmap can be given an expression vector which will overwrite the default legend labels (so can ggplot2), while as far as I can tell, pheatmap can't.
I don't even bother with pheatmap/heatmap.n when ComplexHeatmap has basically everything. I'd switch if that's an option, you'll never have to switch to a different heatmap software ever.
Have you tried something like this?
plot.new() text(0.5, 0.7, labels = quote("Interface area " * (Å ^ 2)))
I don't think that would work; I've got two different characteristics in the annotation data, plus the heatmap color scheme itself; how would it know what text to replace? I'm also not sure that quoting like that is sufficient to get the supercripts to look like supercripts. Expression seemed to be the way to do that.