This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DoHeatmap Seurat Edit Legend

Hi Community

I am wondering how I can edit the Legend in a DoHeatmap which is a feature in Seurat. I want to get rid of the identity Legend but not the expression scale.

Is there a way of doing this?

Best Regards

seurat single-cell-sequencing r

1 answer

Hi,

Seurat visualization is based (if not solely) in ggplot2 R package. Thus, in order to address your question you need to look into ggplot2 documentation and syntax.

Since you didn't provide any code sample neither figure, I provide below a minimal reproducible code attempting to generate the figure that you're looking for.

# Packages 
library("dplyr")
library("Seurat")
#library("SeuratData")

# Install, load data & run Seurat upstream workflow
SeuratData::InstallData("ifnb")
ifnb <- SeuratData::LoadData("ifnb")
ifnb <- ifnb %>% 
  NormalizeData(.) %>% 
  FindVariableFeatures(., selection.method = "vst", nfeatures = 2000) %>% 
  ScaleData(.)

# Plot heatmap
set.seed(123)
DoHeatmap(ifnb, features = VariableFeatures(ifnb)[1:100], 
          cells = sample(1:ncol(ifnb), 500), size = 4,
          angle = 90) + guides(color="none")

The trick is done with guides(color="none"). The result is the following plot:

enter image description here

I hope this helps,

António

Log in to answer this question.