This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Plotting heatmap of Marker genes in each celltypes in Seurat

Hi,

I am working on single-cell data, I have identified cell types in each cluster by using marker genes expression using Seurat. I want to Plot a Heatmap which shows gene scores for the marker genes (rows) in each expression module identified by clustering. Example figure is as follows. Please let me know how best i can plot this type of image using Seurat or any other pipeline.

Thanks a lot for your kind help,

Regards, Dave

HeatMap for marker genes in each cell type

seurat singlecell heatmap celltypes

Seurat has a function DoHeatmap that will make a heatmap based on the given features and clusters.

Thanks a lot for such a fast reply, I tried with DoHeatmap, but i couldn't add Tissue/Donor/Sample Info to the Heatmap. I couldn't produce heatmap wth all the cell type markers, my graph will become very cluttery and it's difficult to read.

If you want to add extra information like tissue and donor, you'll need to extract the metadata and UMI counts from the seurat object, and then construct the heatmap using the ComplexHeatmap library. You can get the counts using the GetAssayData function, and the metadata can be accessed with two opened and closed square brackets seurat_object[[]].

Can you please share any script for this, i am a biologist, my hold on R is very Limited.

ComplexHeatmap has a long but detailed vignette that you can go through.

Your can prepare your count matrix with this code. Put the genes you want to include the the genes vector.

library("Seurat")

counts <- GetAssyData(seurat_obj, assay="RNA", slot="data")
genes <- c(...)
counts <- as.matrix(counts[rownames(counts) %in% genes, ])

You can then prepare your metadata using this code.

metadata <- seurat_obj[[]]
metadata <- metadata[rownames(metadata) %in% colnames(counts), ]

These can then be used as input to ComplexHeatmap.

Thanks a lot for your kind help, i am trying this code.

1 answer

This can be done very simply with the dittoHeatmap command from dittoSeq. It will allow you to add any other annotations you'd like very simply via the annot.by parameter. It will work on your default Seurat object with no changes or conversions.

That's a really handy wrapper for pheatmap, thanks for sharing!

Thanks. We will probably change the underlying code to utilize ComplexHeatmap eventually, as it's an easy switch and will allow us to use some of the rasterization features that will really help reduce the plot file size and make plots easier to edit in Illustrator, etc.

I find that the scRNA-seq dim plots will sometimes melt illustrator as well. I found a handy library, ggraster, that will let you rasterize the points but keep the labels and such as vectors. I figured I would pass this along in case you haven't seen it.

To keep this up to date, dittoHeatmap supports rasterization now by using ComplexHeatmap.

Log in to answer this question.