junjunlab / scRNAtoolVis

Useful functions to make your scRNA-seq plot more cool!
Other
258 stars 27 forks source link

AverageHeatmap() function in Seurat v5 #43

Open ziyuan-ma opened 4 months ago

ziyuan-ma commented 4 months ago

Hello, thanks for developing this wonderful visualization package! I have encountered some issues passing the Seurat v5 object to AverageHeatmap() function. Could you please advise how should I pull data from the data layer instead of from slot? Thank you!

> AverageHeatmap(object = pbmc,
+                markerGene = markers$gene)
As of Seurat v5, we recommend using AggregateExpression to perform pseudo-bulk analysis.
This message is displayed once per session.
Warning: No layers found matching search pattern provided
[1] "Your cluster annotation color is:" "#B969E5FF"                         "#BD94EDFF"                        
[4] "#E6C0FBFF"                         "#E477F5FF"                         "#FFC8CEFF"                        
[7] "#B8FD8AFF"                         "#7CF8E1FF"                        
Warning message:
The `slot` argument of `AverageExpression()` is deprecated as of Seurat 5.0.0.
ℹ Please use the `layer` argument instead.
ℹ The deprecated feature was likely used in the Seurat package.
  Please report the issue at <https://github.com/satijalab/seurat/issues>.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 
pacmandoh commented 4 months ago

hi @ziyuan-ma , A new layer has been added to Seurat V5, and the slot slot used to extract gene expression data in previous versions seems to no longer work in V5. The old version of slot is used in the author's parameters and does not apply to V5. If the author doesn't have time to follow up, I will submit a PR to fix this problem. If this warning ⚠️ does not affect your results, you don't have to care. If there is an impact, you can copy the source code and put it in:

  # get cells mean gene expression
  mean_gene_exp <- as.matrix(
    data.frame(
      Seurat::AverageExpression(object,
        features = markerGene,
        group.by = group.by,
        assays = assays,
        slot = slot
      )
    )
  )

Modify to:

  # get cells mean gene expression
  mean_gene_exp <- as.matrix(
    data.frame(
      Seurat::AverageExpression(object,
        features = markerGene,
        group.by = group.by,
        assays = assays,
        layer = "yourSeuratObjLayerName" || "data"
      )
    )
  )
junjunlab commented 3 months ago

Thanks, I will fix this.

junjunlab commented 3 months ago

Now you can re-install scRNAtoolVis and try averageHeatmap on Seruat V5.