I am using Seurat v2 for professional reasons (I am aware of the availablity of Seurat v3). I am clustering and analysing single cell RNA seq data. How do I add a coloured annotation bar to the heatmap generated by the DoHeatmap function from Seurat v2? I want to be able to demarcate my cluster numbers on the heatmap over a coloured annotation bar. I want to have the an image like this:
(taken from Satija V3 tutorial).
My original code:
library(Seurat)
DoHeatmap(object = object, genes.use = top20_pos$gene)
produces the following image which is not what I want:
I am aware that DoHeatmap function returns a ggplot2 object but after searching the internet for a long time, I have not been able to find which geom layer I can add to achive my objective.
On the other hand, I have tried to generate a separate coloured annotation bar from another package called ComplexHeatmap with the intention of cropping it to fit the cluster demarcations on my heatmap generated with DoHeatmap but this has proven to be very time-consuming and inaccurrate:
library(ComplexHeatmap)
df = data.frame(type = c(rep("a", 18), rep("b", 3), rep("c", 2), rep("d", 1), rep("e", 1)))
ha = HeatmapAnnotation(df = df, col = list(type = c("a" = "blue", "b" = "red", "c" = "green", "d" = "cyan", "e" = "magenta")))
draw(ha, 1:25)
I will be very grateful for any hint on how to achieve my goal automatically and accurately.
Thank you in advance for your help.
heatmap.2
function, and pass a vector of colors through it to get this representation.. It would be something likeheatmap.2(exrs.mat, ColSideColors = color_array)
$\endgroup$UpdateSeuratObject
. $\endgroup$