SingleR-inc / SingleR

Clone of the Bioconductor repository for the SingleR package.
https://bioconductor.org/packages/devel/bioc/html/SingleR.html
GNU General Public License v3.0
177 stars 19 forks source link

"object of type 'S4' is not subsettable" error #263

Closed ycl6 closed 9 months ago

ycl6 commented 9 months ago

Hi,

My scRNA-seq workflow is working fine in R 4.1.2 but I want to upgrade and run the analysis in R 4.3. While running the analysis in R 4.3.2 using SingleR 2.4.1, I encountered the following error:

immg <- celldex::ImmGenData()
pred <- SingleR(test = sce, ref = list(IMMG = immg), labels = list(immg$label.main))

Error in .Primitive("[")(new("TENxMatrixSeed", filepath = "/proj/sample_filtered_feature_bc_matrix.h5",  : 
  object of type 'S4' is not subsettable

I created the SingleCellExperiment using the HDF5 file from Cell Ranger. Any idea how I can make it work with my R object?

traceback ```r 10: do.call(`[`, c(list(x), subscripts, list(drop = drop))) 9: do.call(`[`, c(list(x), subscripts, list(drop = drop))) 8: S4Arrays:::subset_by_Nindex(x, index) 7: (new("nonstandardGenericFunction", .Data = function (x, index) { x_dim <- dim(x) if (is.null(x_dim)) stop(wmsg("first argument to extract_sparse_array() ", "must be an array-like object")) ans <- standardGeneric("extract_sparse_array") expected_dim <- S4Arrays:::get_Nindex_lengths(index, x_dim) check_returned_SparseArray(ans, expected_dim, "extract_sparse_array", class(x)) }, generic = structure("extract_sparse_array", package = "SparseArray"), package = "SparseArray", group = list(), valueClass = character(0), signature = c("x", "index"), default = NULL, skeleton = (function (x, index) stop(gettextf("invalid call in method dispatch to '%s' (no default method)", "extract_sparse_array"), domain = NA))(x, index)))(new("TENxMatrixSeed", filepath = "/proj/sample_filtered_feature_bc_matrix.h5", group = "/matrix", subdata = NULL, dim = c(32285L, 5956L), indptr_ranges = structure(list(start = c(1, 2367, 6886, 8532, 10304, 12030, 13438, 17944, 19131, 22570, 24178, 27044, 28067, 28793, 30373, 33126, 36476, 38289, 39652, 42297, 46016, 48437, 49302, 51430, 53637, 55808, 57023, 58640, 61814, 67173, 67965, 68926, 70145, 72694, 75586, 78218, 79392, 81164, 83211, 86033, 86618, 87676, 88488, 90113, 92013, 92288, 94473, 96028, 98140, 101469, 104322, 105682, 107417, 107838, 109645, 111274, 113035, ... 6: (new("nonstandardGenericFunction", .Data = function (x, index) { x_dim <- dim(x) if (is.null(x_dim)) stop(wmsg("first argument to extract_sparse_array() ", "must be an array-like object")) ans <- standardGeneric("extract_sparse_array") expected_dim <- S4Arrays:::get_Nindex_lengths(index, x_dim) check_returned_SparseArray(ans, expected_dim, "extract_sparse_array", class(x)) }, generic = structure("extract_sparse_array", package = "SparseArray"), package = "SparseArray", group = list(), valueClass = character(0), signature = c("x", "index"), default = NULL, skeleton = (function (x, index) stop(gettextf("invalid call in method dispatch to '%s' (no default method)", "extract_sparse_array"), domain = NA))(x, index)))(new("TENxMatrixSeed", filepath = "/proj/sample_filtered_feature_bc_matrix.h5", group = "/matrix", subdata = NULL, dim = c(32285L, 5956L), indptr_ranges = structure(list(start = c(1, 2367, 6886, 8532, 10304, 12030, 13438, 17944, 19131, 22570, 24178, 27044, 28067, 28793, 30373, 33126, 36476, 38289, 39652, 42297, 46016, 48437, 49302, 51430, 53637, 55808, 57023, 58640, 61814, 67173, 67965, 68926, 70145, 72694, 75586, 78218, 79392, 81164, 83211, 86033, 86618, 87676, 88488, 90113, 92013, 92288, 94473, 96028, 98140, 101469, 104322, 105682, 107417, 107838, 109645, 111274, 113035, ... 5: run(parsed, m - 1L, trained$built, quantile = quantile, use_fine_tune = fine.tune, fine_tune_threshold = tune.thresh, nthreads = num.threads) 4: FUN(X[[i]], ...) 3: lapply(trained, FUN = .classify_internals, test = test, quantile = quantile, fine.tune = fine.tune, tune.thresh = tune.thresh, prune = prune, num.threads = num.threads) 2: classifySingleR(test, trained, quantile = quantile, fine.tune = fine.tune, tune.thresh = tune.thresh, prune = prune, check.missing = FALSE, num.threads = num.threads, BPPARAM = BPPARAM) 1: SingleR(test = sce, ref = list(IMMG = immg), labels = list(immg$label.main)) ```
sessionInfo ```r R version 4.3.2 (2023-10-31) Platform: x86_64-conda-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS Matrix products: default BLAS/LAPACK: /home/ihsuan/miniconda3/envs/r4.3/lib/libopenblasp-r0.3.26.so; LAPACK version 3.12.0 locale: [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 [4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C time zone: Europe/London tzcode source: system (glibc) attached base packages: [1] stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] celldex_1.12.0 SingleR_2.4.1 scran_1.30.2 [4] scater_1.30.1 ggplot2_3.4.4 scuttle_1.12.0 [7] DropletUtils_1.22.0 SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0 [10] Biobase_2.62.0 GenomicRanges_1.54.1 GenomeInfoDb_1.38.6 [13] IRanges_2.36.0 S4Vectors_0.40.2 BiocGenerics_0.48.1 [16] MatrixGenerics_1.14.0 matrixStats_1.2.0 loaded via a namespace (and not attached): [1] DBI_1.2.1 bitops_1.0-7 gridExtra_2.3 [4] rlang_1.1.3 magrittr_2.0.3 compiler_4.3.2 [7] RSQLite_2.3.5 DelayedMatrixStats_1.24.0 png_0.1-8 [10] vctrs_0.6.5 pkgconfig_2.0.3 crayon_1.5.2 [13] fastmap_1.1.1 ellipsis_0.3.2 dbplyr_2.4.0 [16] XVector_0.42.0 utf8_1.2.4 promises_1.2.1 [19] ggbeeswarm_0.7.2 purrr_1.0.2 bit_4.0.5 [22] bluster_1.12.0 zlibbioc_1.48.0 cachem_1.0.8 [25] beachmat_2.18.0 blob_1.2.4 later_1.3.2 [28] rhdf5filters_1.14.1 DelayedArray_0.28.0 interactiveDisplayBase_1.40.0 [31] Rhdf5lib_1.24.2 BiocParallel_1.36.0 irlba_2.3.5.1 [34] parallel_4.3.2 cluster_2.1.6 R6_2.5.1 [37] limma_3.58.1 Rcpp_1.0.12 R.utils_2.12.3 [40] httpuv_1.6.14 Matrix_1.6-5 igraph_1.6.0 [43] tidyselect_1.2.0 yaml_2.3.8 abind_1.4-5 [46] viridis_0.6.5 codetools_0.2-19 curl_5.2.0 [49] lattice_0.22-5 tibble_3.2.1 shiny_1.8.0 [52] withr_3.0.0 KEGGREST_1.42.0 BiocFileCache_2.10.1 [55] ExperimentHub_2.10.0 Biostrings_2.70.2 filelock_1.0.3 [58] BiocManager_1.30.22 pillar_1.9.0 generics_0.1.3 [61] RCurl_1.98-1.14 BiocVersion_3.18.1 sparseMatrixStats_1.14.0 [64] munsell_0.5.0 scales_1.3.0 xtable_1.8-4 [67] glue_1.7.0 metapod_1.10.1 tools_4.3.2 [70] AnnotationHub_3.10.0 BiocNeighbors_1.20.2 ScaledMatrix_1.10.0 [73] locfit_1.5-9.8 rhdf5_2.46.1 grid_4.3.2 [76] AnnotationDbi_1.64.1 edgeR_4.0.15 colorspace_2.1-0 [79] GenomeInfoDbData_1.2.11 beeswarm_0.4.0 BiocSingular_1.18.0 [82] HDF5Array_1.30.0 vipor_0.4.7 cli_3.6.2 [85] rsvd_1.0.5 rappdirs_0.3.3 fansi_1.0.6 [88] S4Arrays_1.2.0 viridisLite_0.4.2 dplyr_1.1.4 [91] gtable_0.3.4 R.methodsS3_1.8.2 digest_0.6.34 [94] SparseArray_1.2.4 ggrepel_0.9.5 dqrng_0.3.2 [97] htmltools_0.5.7 memoise_2.0.1 R.oo_1.26.0 [100] lifecycle_1.0.4 httr_1.4.7 mime_0.12 [103] statmod_1.5.0 bit64_4.0.5 ```
LTLA commented 9 months ago

This is a minor bug in beachmat that got fixed in BioC-devel but I forgot to propagate it to BioC-release. I've just made the push, but if you don't want to wait, you can do one of the following:

Any one of these should do the job.

ycl6 commented 9 months ago

Hi @LTLA

Thanks for the suggestions, I re-install beachmat from RELEASE_3_18 and can confirm SingleR works as before.

remove.packages("beachmat")
devtools::install_github("tatami-inc/beachmat@RELEASE_3_18")