This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to display all top markers in the heatmap by DoHeatmap (Seurat) when there are duplicates of top marker genes for several cell clusters

Dear genius,

Is there a way to display all the top markers in the heatmap by DoHeatmap (Seurat) when there are duplicates for several cell clusters?

Followed the tutorial from Seurat to integrate the treat and control Seurat object: https://satijalab.org/seurat/articles/integration_introduction.html, DoHeatmap(combined, features = top5$gene, group.by = "seurat_clusters") while the heatmap for the top markers is not all displayed, although I checked the top5$gene, it is indeed 35 genes for the 7 cell clusters, and class(top5$gene) are character, not factor

enter image description here

doheatmap seurat

1 answer

You can create a new assay with the splitted genes expression for all your top genes including duplicates (label duplicates with cluster id), ScaleData and run DoHeatmap as follows-

seurat_object
# make a new assay with the splited genes expression for all your top genes
MS4A1.cl1 <- seurat_object[['RNA']]$data["MS4A1",] * (seurat_object$seurat_clusters == "1")
MS4A1.cl2 <- seurat_object[['RNA']]$data["MS4A1",] * (seurat_object$seurat_clusters == "2")

#Store these gene expressions in "NEW" assay 
seurat_object[['NEW']] <- CreateAssayObject(seurat_object = rbind(MS4A1.t1, MS4A1.t2))
DefaultAssay(temp) <- "NEW"
seurat_object <- ScaleData(seurat_object) ##DoHeatmap used scaled data
DoHeatmap(seurat_object, features = c("MS4A1.cl1", "MS4A1.cl2"))

enter image description here

Great guidance! Thank you very much!

Log in to answer this question.