carmonalab / UCell

Gene set scoring for single-cell data
GNU General Public License v3.0
132 stars 16 forks source link

SingleCellExperiment support? #11

Closed enricoferrero closed 2 years ago

enricoferrero commented 2 years ago

Thanks for developing a really useful package!

Are you considering openly supporting SingleCellExperiment (on top of Seurat)? I'm sure this would be very appreciated by the Bioconductor community.

For reference, given a SingleCellExperiment object sce, and a list of signatures signatures this is how I've been using UCell:

# get Uscores
uscores <- ScoreSignatures_UCell(logcounts(sce), features = signatures)

# add to SCE as altExp
uscores <- uscores %>% 
    t() %>% 
    SummarizedExperiment(assays = list(uscores = .))
altExp(sce, "UCell") <- uscores
mass-a commented 2 years ago

Hello Enrico, that's a very good suggestion.

As you have shown with your piece of code, it's quite straightforward to make UCell interact with sce objects. But I agree that we could implement a wrapper function to explicitly support SingleCellExperiment in our package. I'm adding this to the to-do list for the next release.

Cheers! -m

mass-a commented 2 years ago

Hey again, support for SingleCellExperiment objects has now been added to the development version of UCell (to be installed using remotes::install_github("carmonalab/UCell", ref="dev"))

Following your suggestion, the new function ScoreSignatures_UCell_sce() takes as input a sce object and returns UCell scores in its altExp:

 sce <- ScoreSignatures_UCell_sce(sce, assay = "counts", features, ...)

Would be great to have feedback!

PS: Seurat was removed from Imports, so you do not need to have it installed if you run UCell on a matrix or sce object.

enricoferrero commented 2 years ago

Thanks @mass-a! I get this warning when running ScoreSignatures_UCell on a SingleCellExperiment object:

Warning message:
In .check_altexp_columns(x, value, withDimnames = withDimnames,  :
  'colnames(value)' are not the same as 'colnames(x)' for 'altExp<-'. This will be an error in
the next release of Bioconductor.
mass-a commented 2 years ago

Hello @enricoferrero, thanks for the heads up.

Which version of SingleCellExperiment are you using? UCell seems to play fine with the development version of Bioconductor: https://bioconductor.org/packages/3.15/bioc/html/UCell.html