MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
39 stars 23 forks source link

error using scaledColRanks #93

Closed doliv071 closed 3 years ago

doliv071 commented 3 years ago

I get the following error when attempting to use scaledColRanks

> counts(scObj)
33538 x 6274 sparse Matrix of class "dgTMatrix"
>
>     rankedCounts <- scaledColRanks(counts(scObj), subset.row = NULL, min.mean = 0.1,
+                                    transposed = FALSE,
+                                    withDimnames = TRUE, BPPARAM = BiocParallel::MulticoreParam(8)
+     )
Error in blockApply(x, FUN = FUN, ..., grid = grid, as.sparse = NA, BPPARAM = BPPARAM) : 
  formal argument "as.sparse" matched by multiple actual arguments
> traceback()
3: .blockApply2(x, FUN = FUN, ..., grid = grid, BPPARAM = BPPARAM, 
       beachmat_by_row = FALSE)
2: colBlockApply(x[subset.row, , drop = FALSE], FUN = .get_scaled_ranks, 
       transposed = transposed, as.sparse = as.sparse, BPPARAM = BPPARAM)
1: scaledColRanks(counts(scObj), subset.row = NULL, min.mean = 0.1, 
       transposed = FALSE, withDimnames = TRUE, BPPARAM = BiocParallel::MulticoreParam(8))

Would appreciate any assistance

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] AnnotationHub_2.22.0        BiocFileCache_1.14.0        dbplyr_2.1.1                sctransform_0.3.2          
 [5] scran_1.18.6                scater_1.18.6               patchwork_1.1.1             BiocParallel_1.24.1        
 [9] SingleCellExperiment_1.12.0 SummarizedExperiment_1.20.0 Biobase_2.50.0              GenomicRanges_1.42.0       
[13] GenomeInfoDb_1.26.7         IRanges_2.24.1              S4Vectors_0.28.1            BiocGenerics_0.36.0        
[17] MatrixGenerics_1.2.1        matrixStats_0.58.0          stringr_1.4.0               magrittr_2.0.1             
[21] ggplot2_3.3.3               ROGUE_1.0                   data.table_1.14.0           Matrix_1.3-2               

loaded via a namespace (and not attached):
 [1] ggbeeswarm_0.6.0              colorspace_2.0-0              ellipsis_0.3.1               
 [4] scuttle_1.0.4                 bluster_1.0.0                 XVector_0.30.0               
 [7] BiocNeighbors_1.8.2           listenv_0.8.0                 ggrepel_0.9.1                
[10] bit64_4.0.5                   AnnotationDbi_1.52.0          interactiveDisplayBase_1.28.0
[13] fansi_0.4.2                   R.methodsS3_1.8.1             codetools_0.2-18             
[16] sparseMatrixStats_1.2.1       cachem_1.0.4                  knitr_1.32                   
[19] jsonlite_1.7.2                R.oo_1.24.0                   shiny_1.6.0                  
[22] BiocManager_1.30.12           compiler_4.0.3                httr_1.4.2                   
[25] dqrng_0.2.1                   assertthat_0.2.1              fastmap_1.1.0                
[28] limma_3.46.0                  later_1.1.0.1                 BiocSingular_1.6.0           
[31] htmltools_0.5.1.1             tools_4.0.3                   rsvd_1.0.5                   
[34] igraph_1.2.6                  gtable_0.3.0                  glue_1.4.2                   
[37] GenomeInfoDbData_1.2.4        reshape2_1.4.4                dplyr_1.0.5                  
[40] rappdirs_0.3.3                Rcpp_1.0.6                    vctrs_0.3.7                  
[43] DelayedMatrixStats_1.12.3     xfun_0.22                     globals_0.14.0               
[46] beachmat_2.6.4                mime_0.10                     lifecycle_1.0.0              
[49] irlba_2.3.3                   statmod_1.4.35                future_1.21.0                
[52] edgeR_3.32.1                  zlibbioc_1.36.0               MASS_7.3-53.1                
[55] scales_1.1.1                  promises_1.2.0.1              yaml_2.2.1                   
[58] curl_4.3                      memoise_2.0.0                 reticulate_1.18              
[61] gridExtra_2.3                 stringi_1.5.3                 RSQLite_2.2.5                
[64] BiocVersion_3.12.0            rlang_0.4.10                  pkgconfig_2.0.3              
[67] bitops_1.0-6                  evaluate_0.14                 lattice_0.20-41              
[70] purrr_0.3.4                   bit_4.0.4                     tidyselect_1.1.0             
[73] parallelly_1.24.0             plyr_1.8.6                    R6_2.5.0                     
[76] generics_0.1.0                DelayedArray_0.16.3           DBI_1.1.1                    
[79] pillar_1.6.0                  withr_2.4.1                   RCurl_1.98-1.3               
[82] tibble_3.1.0                  future.apply_1.7.0            crayon_1.4.1                 
[85] utf8_1.2.1                    rmarkdown_2.7                 viridis_0.6.0                
[88] locfit_1.5-9.4                grid_4.0.3                    blob_1.2.1                   
[91] digest_0.6.27                 xtable_1.8-4                  tidyr_1.1.3                  
[94] httpuv_1.5.5                  R.utils_2.10.1                munsell_0.5.0                
[97] beeswarm_0.3.1                viridisLite_0.4.0             vipor_0.4.5
doliv071 commented 3 years ago

So I have worked around the issue and I think I can give you a little more context on the problem:

Normally I would calculate quickCluster using ranks

tmp <- scran::quickCluster(scObj, use.ranks = TRUE, d = 50, BPPARAM = BiocParallel::MulticoreParam(8)) 

which generated the original error message I posted, I tracked it as low as I could go in R which was the scaledColRanks function.

This function works when the input is a dense matrix object but not when it is sparse even if as.sparse is set to true as below.

rankedCounts <- scran::scaledColRanks(as.matrix(counts(scObj)), subset.row = NULL, min.mean = 0.1,
                                                      transposed = FALSE, as.sparse = TRUE,
                                                      withDimnames = TRUE, BPPARAM = BiocParallel::MulticoreParam(8))

tmp <- scran::quickCluster(rankedCounts, use.ranks = FALSE, d = 50, BPPARAM = BiocParallel::MulticoreParam(8)) 

I'm honestly not sure that setting use.ranks = FALSE within the quickCluster function and passing it pre-ranked values produces the intended output, but I suspect it is close.

also, for reference,

> scObj
class: SingleCellExperiment 
dim: 33538 6274 
metadata(3): RAW cellsToKeep genesToKeep
assays(1): counts
rownames(33538): MIR1302.2HG FAM138A ... AC213203.1 FAM231C
rowData names(7): gene_id gene_name ... detected mean_in_detected
colnames(6274): AAACCTGAGAAGATTC-SRR12113801 AAACCTGAGGCAAAGA-SRR12113801 ... TTTGTCATCGGTCCGA-SRR12113801
  TTTGTCATCTGAAAGA-SRR12113801
colData names(108): Cell_ID Barcode ... subsets_RP_percent total
reducedDimNames(0):
altExpNames(0):
LTLA commented 3 years ago

Whoops. This has already been fixed in the next release, but try converting the matrix to a dgCMatrix object for the time being.

doliv071 commented 3 years ago

Thanks Aaron, I actually updated BioC packages yesterday and scran was in the list so let me double check that my issue is resolved.

Edit: Just saw that you said it would be resolved in the next release. I will use the dgCMatrix workaround for now. Thanks