plger / scDblFinder

Methods for detecting doublets in single-cell sequencing data
https://plger.github.io/scDblFinder/
GNU General Public License v3.0
153 stars 18 forks source link

Error in as(counts(sce), "CsparseMatrix") #83

Closed akhst7 closed 1 year ago

akhst7 commented 1 year ago

Describe the bug I run a following and got an error;

dblets<-scDblFinder(sce)
Error in as(counts(sce), "CsparseMatrix") : 
no method or default for coercing "Assay" to "CsparseMatrix"

MRE -- Minimal example to reproduce the bug A sce obj was created from 10x's data set (https://www.10xgenomics.com/resources/datasets/pbmc-from-a-healthy-donor-granulocytes-removed-through-cell-sorting-3-k-1-standard-2-0-0).

A filtered bc matrix was fed into Seurat ("4.9.9.9058") to create a Seurat obj and count data was used to create the following sce obj;

count<-GetAssay(pbmc3ksorted.arc202, assay = "RNA")
sce<-SingleCellExperiment(list(counts=RNA))

> sce
class: SingleCellExperiment 
dim: 36601 2707 
metadata(0):
assays(1): counts
rownames(36601): MIR1302-2HG FAM138A ... AC007325.4 AC007325.2
rowData names(0):
colnames(2707): AAACAGCCAAATATCC-1 AAACAGCCAGGAACTG-1 ... TTTGTGTTCCGTGACA-1 TTTGTTGGTAGGTTTG-1
colData names(0):
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):

Traceback

traceback() 4: stop(gettextf("no method or default for coercing %s to %s", dQuote(thisClass), dQuote(Class)), domain = NA) 3: as(counts(sce), "CsparseMatrix") 2: .checkSCE(sce) 1: scDblFinder(sce)

Session info


> package.version('scDBlFinder')
[1] "1.14.0"

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

Random number generation:
 RNG:     L'Ecuyer-CMRG 
 Normal:  Inversion 
 Sample:  Rejection 

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Indiana/Indianapolis
tzcode source: internal

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] BiocParallel_1.34.2         TENxIO_1.2.0                scDblFinder_1.14.0          SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2
 [6] MatrixGenerics_1.12.3       matrixStats_1.0.0           Seurat_4.9.9.9058           data.table_1.14.9           Signac_1.10.0              
[11] ensembldb_2.24.0            AnnotationFilter_1.24.0     GenomicFeatures_1.52.1      AnnotationDbi_1.62.2        Biobase_2.60.0             
[16] SeuratObject_4.9.9.9091     sp_2.0-0                    GenomicRanges_1.52.0        GenomeInfoDb_1.36.1         IRanges_2.34.1             
[21] S4Vectors_0.38.1            AnnotationHub_3.8.0         BiocFileCache_2.8.0         dbplyr_2.3.3                BiocGenerics_0.46.0        
[26] future_1.33.0               magrittr_2.0.3.9000        

loaded via a namespace (and not attached):
  [1] ProtGenerics_1.32.0           spatstat.sparse_3.0-2         bitops_1.0-7                  httr_1.4.6                    RColorBrewer_1.1-3           
  [6] tools_4.3.1                   sctransform_0.3.5             utf8_1.2.3                    R6_2.5.1                      lazyeval_0.2.2               
 [11] uwot_0.1.16                   prettyunits_1.1.1             gridExtra_2.3                 drcData_1.1-3                 progressr_0.14.0             
 [16] cli_3.6.1                     spatstat.explore_3.2-1        fastDummies_1.7.3             sandwich_3.0-2                mvtnorm_1.2-2                
 [21] spatstat.data_3.0-1           readr_2.1.4                   ggridges_0.5.4                pbapply_1.7-2                 Rsamtools_2.16.0             
 [26] scater_1.28.0                 parallelly_1.36.0             plotrix_3.8-2                 limma_3.56.2                  rstudioapi_0.15.0            
 [31] RSQLite_2.3.1                 generics_0.1.3                BiocIO_1.10.0                 gtools_3.9.4                  ica_1.0-3                    
 [36] spatstat.random_3.1-5         car_3.1-2                     dplyr_1.1.2                   Matrix_1.6-1                  ggbeeswarm_0.7.2             
 [41] fansi_1.0.4                   abind_1.4-5                   lifecycle_1.0.3               multcomp_1.4-25               yaml_2.3.7                   
 [46] edgeR_3.42.4                  carData_3.0-5                 Rtsne_0.16                    grid_4.3.1                    blob_1.2.4                   
 [51] promises_1.2.1                dqrng_0.3.0                   crayon_1.5.2                  miniUI_0.1.1.1                lattice_0.21-8               
 [56] beachmat_2.16.0               cowplot_1.1.1                 KEGGREST_1.40.0               pillar_1.9.0                  metapod_1.8.0                
 [61] rjson_0.2.21                  xgboost_1.7.5.1               future.apply_1.11.0           codetools_0.2-19              fastmatch_1.1-3              
 [66] leiden_0.4.3                  glue_1.6.2                    remotes_2.4.2.1               vctrs_0.6.3                   png_0.1-8                    
 [71] spam_2.9-1                    gtable_0.3.3                  cachem_1.0.8                  S4Arrays_1.0.5                mime_0.12                    
 [76] survival_3.5-7                RcppRoll_0.3.0                statmod_1.5.0                 bluster_1.10.0                TH.data_1.1-2                
 [81] interactiveDisplayBase_1.38.0 ellipsis_0.3.2                fitdistrplus_1.1-11           ROCR_1.0-11                   nlme_3.1-163                 
 [86] bit64_4.0.5                   progress_1.2.2                filelock_1.0.2                RcppAnnoy_0.0.21              job_0.3.0                    
 [91] irlba_2.3.5.1                 vipor_0.4.5                   KernSmooth_2.23-22            colorspace_2.1-0              DBI_1.1.3                    
 [96] tidyselect_1.2.0              bit_4.0.5                     compiler_4.3.1                curl_5.0.2                    BiocNeighbors_1.18.0         
[101] xml2_1.3.5                    DelayedArray_0.26.7           plotly_4.10.2                 rtracklayer_1.60.0            scales_1.2.1                 
[106] lmtest_0.9-40                 rappdirs_0.3.3                stringr_1.5.0                 digest_0.6.33                 goftest_1.2-3                
[111] spatstat.utils_3.0-3          XVector_0.40.0                htmltools_0.5.6               pkgconfig_2.0.3               sparseMatrixStats_1.12.2     
[116] fastmap_1.1.1                 rlang_1.1.1                   htmlwidgets_1.6.2             shiny_1.7.5                   DelayedMatrixStats_1.22.5    
[121] zoo_1.8-12                    jsonlite_1.8.7                BiocSingular_1.16.0           RCurl_1.98-1.12               scuttle_1.10.2               
[126] GenomeInfoDbData_1.2.10       dotCall64_1.0-2               sceasy_0.0.7                  patchwork_1.1.3               munsell_0.5.0                
[131] Rcpp_1.0.11                   viridis_0.6.4                 reticulate_1.31               stringi_1.7.12                zlibbioc_1.46.0              
[136] MASS_7.3-60                   plyr_1.8.8                    parallel_4.3.1                listenv_0.9.0                 ggrepel_0.9.3                
[141] deldir_1.0-9                  Biostrings_2.68.1             splines_4.3.1                 tensor_1.5                    hms_1.1.3                    
[146] locfit_1.5-9.8                igraph_1.5.1                  spatstat.geom_3.2-4           RcppHNSW_0.4.1                reshape2_1.4.4               
[151] biomaRt_2.56.1                ScaledMatrix_1.8.1            BiocVersion_3.17.1            XML_3.99-0.14                 drc_3.2-0                    
[156] scran_1.28.2                  BiocManager_1.30.22           tzdb_0.4.0                    httpuv_1.6.11                 RANN_2.6.1                   
[161] tidyr_1.3.0                   purrr_1.0.2                   polyclip_1.10-4               scattermore_1.2               ggplot2_3.4.3                
[166] BiocBaseUtils_1.2.0           rsvd_1.0.5                    xtable_1.8-4                  restfulr_0.0.15               RSpectra_0.16-1              
[171] later_1.3.1                   viridisLite_0.4.2             tibble_3.2.1                  memoise_2.0.1                 beeswarm_0.4.0               
[176] GenomicAlignments_1.36.0      cluster_2.1.4                 globals_0.16.2  
plger commented 1 year ago

Hi, your code is wrong. You're extracting the assay as count but aren't passing that to SingleCellExperiment(). Even if you were using it, that's a Seurat object and the SCE won't be working with anything downstream. Extract your assay with GetAssayData instead.