LTLA / scuttle

Clone of the Bioconductor repository for the scuttle package.
https://bioconductor.org/packages/devel/bioc/html/scuttle.html
9 stars 7 forks source link

empty heatmap (aggregateAcrossCells) #27

Closed Elena983 closed 5 months ago

Elena983 commented 5 months ago

Hi

`celltype_mean <- aggregateAcrossCells(as(spe, "SingleCellExperiment"),
ids = spe$cluster_celltype, statistics = "mean", use.assay.type = "exprs", subset.row = rownames(spe)[rowData(spe)$marker_class == "type"])

h_type <- Heatmap(t(assay(celltype_mean, "exprs")), column_title = "type_markers", col = col_exprs, name= "mean exprs", show_row_names = TRUE, show_column_names = TRUE)

draw(h_type)`

and resulting in the empty heatmap image

Where should there be a problem?

LTLA commented 5 months ago

I dunno what Heatmap is, but aggregateAcrossCells() seems fine to me.

library(SpatialExperiment)
example(read10xVisium, echo=FALSE)
spe$cluster_celltype <- sample(LETTERS, ncol(spe), replace=TRUE)
rowData(spe)$marker_class <- sample(c("type", "foo"), nrow(spe), replace=TRUE)

celltype_mean <- aggregateAcrossCells(as(spe, "SingleCellExperiment"),
    ids = spe$cluster_celltype,
    statistics = "mean",
    use.assay.type = "counts",
    subset.row = rownames(spe)[rowData(spe)$marker_class == "type"])

assay(celltype_mean) # lots of different values
Elena983 commented 5 months ago

could you please check my sce object spe.rds.zip

LTLA commented 5 months ago

Based on your object, the output of aggregateAcrossCells looks reasonable to me:

spe <- readRDS("spe.rds")

library(scuttle)
celltype_mean <- aggregateAcrossCells(as(spe, "SingleCellExperiment"),
  ids = spe$cluster_celltype,
  statistics = "mean",
  use.assay.type = "exprs",
  subset.row = rownames(spe)[rowData(spe)$marker_class == "type"])
## Loading required package: SpatialExperiment

assay(celltype_mean)
##            Treg    Tumor     Tcyt    Thelp   Stroma   MPtoDC Epithelial
## CD68   6.355038 6.297449 6.948537 6.983645 5.662222 7.497479   6.684087
## aSMA   5.640325 5.651184 5.698913 5.731827 6.703023 5.744259   5.851679
## CD31   5.041905 4.708416 5.621076 5.456579 4.577630 5.442956   6.759071
## CD11c  4.662563 4.556394 5.162483 5.276950 4.154083 5.506735   4.914062
## CD8    5.783993 5.876326 7.107333 6.039693 5.692236 5.713519   5.900223
## CD4    6.447647 5.688863 6.139768 6.982229 5.572868 6.103044   5.919215
## CK     5.051434 7.198829 5.748772 5.501591 5.120681 5.533018   5.225856
## CD3    6.612065 5.572035 7.186256 7.237892 5.419575 5.562048   5.799789
## CD20   4.654764 5.361947 5.149226 5.178370 4.808177 5.204738   5.005999
## HLA-DR 5.925168 6.092652 6.652381 6.732915 5.292334 7.225946   5.993730
## CD45   5.839893 5.709059 6.836708 6.711311 5.043161 6.122301   6.189704
##           Bcell
## CD68   6.925318
## aSMA   5.708187
## CD31   5.282558
## CD11c  5.300109
## CD8    6.202452
## CD4    6.472874
## CK     5.278928
## CD3    6.612589
## CD20   7.350783
## HLA-DR 7.252637
## CD45   7.432665

I have no idea where the Heatmap() function comes from, but pheatmap gives something nice:

library(pheatmap)
pheatmap(assay(celltype_mean))

Screenshot from 2024-02-10 00-54-17

Long story short, I don't think the problem is with scuttle. FWIW I'm running the latest version (1.12.0).

Elena983 commented 5 months ago

Thank you, I like pheatmap But if we have a look, the order of the rows will be different from the assay. It should have been started from Treg to Bcell; how can we fix it?

LTLA commented 5 months ago

Check out the options in ?pheatmap, specifically cluster_*.

In any case, this has nothing to do with scuttle, so I'm closing this. If you want help with pheatmap, I'd suggest posting some questions on a more appropriate forum like Biostars.