This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to plot the heat map of a subset of cell types using plotHeatmap from scater package

Hi

I'm using plotHeatmap (library(scater)) to visualize the accuracy of cell type annotation output from SingleR. In total I got 28 labels, but as you can see on the top of the plot, the color different is hard to distinguish due to too many labels. I wonder whether there is a simple way to show only 5 to 7 labels in this plot, this is because I only care some specific cell types only, not all of them. For example "AT1 cells, AT2 cells and B cells" are the three cells I'm interested. How to only plot for only three labels?

 Library(scater)  
 plotHeatmap(sce.data.combined.sct, order_columns_by = "labels", features=feature)

heatmap output

scrnaseq scrna singler plotheatmap scater

One of the potential solution is to subset from the sce object based on the ColData = "AT1 Cells, AT2 Cells, B Cells", then use plotHeatmap function. But how to subset the columns that are associated with those three cell types?

1 answer

Gonna cheat and just recommend dittoSeq. To do what you want will be something like:

dittoHeatmap(sce.data.combined.sct, genes = feature, order.by = "labels", annot.by = "labels", 
  cells.use = sce.data.combined.sct$labels %in% c("AT1 cells", "AT2 cells", "B cells"), scale = "none")

You may also be interested in setting scaled.to.max = TRUE, which is useful for single-cell data given their enrichment for 0s. Setting scale = "row" will plots z-scores instead. I also usually pass complex = TRUE and use_raster = TRUE with single cell data, as it makes the resulting image much easier to edit in Illustrator or such.

Thank you for the great answer! It works really well and what a powerful package it is, thank you.

Log in to answer this question.