This is a test version of Biostars. For the public version, visit https://www.biostars.org.
dittoHeatmap; adding column labels on the heatmap

I have a seurat object and I am subsetting it to make a heatmap using dittoHeatmap function.

Here is my code:

my_colors <- seq(-4,4,by=0.01)
dittoHeatmap(subset(obj, subset = condition_cluster %in% c("Pre", "Post")), assay = 'ADT',
             genes = rownames(obj[['ADT']]),
             annot.by = 'condition_cluster',
             use_raster = TRUE,
             complex = TRUE,
             breaks = my_colors,
             cluster_cols = FALSE,
             heatmap.colors = colorRampPalette(c("blue", "white", "red"))(801),
             )

I want to display the column labels Pre and Post as column labels on the heatmap apart from those being displayed on the legend. How can I do this, since I am also subsetting my seurat obj?

pheatmap complexheatmap dittoheatmap

1 answer

What will annot.by = c("Pre", "Post") do instead of using annot.by = 'condition_cluster'?

That'll do exactly what they want.

Another note is that you can use the cells.use parameter if you want to limit the cells used in the plot without actually subsetting your input object. It also tends to be smarter about dropping unused levels in annotations and such if you do it that way.

I like the cells.use parameter to limit the cells. But I am still unable to display the Pre and Post labels on the top of the heatmap. They are displayed on the right as a legend. When I use annot.by = c("Pre","Post") I get this error

Error in .var_OR_get_meta_or_gene(x, object, assay, slot) : 
  Pre is not a gene of the targeted assay(s), a metadata, nor equal in length to ncol('object')

Oh, right, it should be annot.by = "condition_cluster" rather than the levels thereof.

any idea, how can I display the labels Pre and POst on the top of the heatmap? I am looking at complexheatmap package as to how they display the label names. Also, do you know which row clustering method dittoHeatmap uses by default? I will use the same one with ComplexHeatmap.

I'd consider making a block annotation and then vertically concatenating it to your dittoHeatmap output. Or just slap them on in Illustrator or such after the fact.

It uses whatever ComplexHeatmap is using, so no need to change the clustering.

Log in to answer this question.