Bioconductor / DelayedArray

A unified framework for working transparently with on-disk and in-memory array-like datasets
https://bioconductor.org/packages/DelayedArray
24 stars 9 forks source link

Unable to find an inherited method for function ‘OLD_extract_sparse_array’ for signature ‘"CSR_H5SparseMatrixSeed"’ #109

Closed GabrielHoffman closed 10 months ago

GabrielHoffman commented 10 months ago

Thanks for the package.

I have an error that I encountered for the first time today. The real code I am interested is more complicated, but here is a minimal reproducible example that 1) reads an h5ad from disk using zellkonverter with DelayedArray to use on-disk memory, and 2) computes the row sums.

With the new set of Bioconductor packages, the code fails (see session info below). But with a previous set of packages (see further below) it succeeds. None of this is a problem when use_hdf5=FALSE.

Code:

library(ExperimentHub)
library(zellkonverter)

# Download data, specifying EH2259 for the Kang, et al study
eh <- ExperimentHub()
sce <- eh[["EH2259"]]

# Write to disk
file = "~/EH2259.h5ad"
writeH5AD(sce, file )

# read from disk
sce2 = readH5AD(file, use_hdf5=TRUE)

# Evaluate row sums
res = DelayedArray::rowSums(assay(sce2, 1))

# Error
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘OLD_extract_sparse_array’ for signature ‘"CSR_H5SparseMatrixSeed"’

Session Info for failure:

```r > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) Matrix products: default BLAS/LAPACK: /hpc/packages/minerva-centos7/intel/parallel_studio_xe_2019/compilers_and_libraries_2019.0.117/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so; LAPACK version 3.7.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] 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 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: America/New_York tzcode source: system (glibc) attached base packages: [1] stats4 stats graphics grDevices datasets utils methods [8] base other attached packages: [1] muscData_1.15.0 SingleCellExperiment_1.24.0 [3] SummarizedExperiment_1.32.0 Biobase_2.62.0 [5] GenomicRanges_1.54.1 GenomeInfoDb_1.38.0 [7] IRanges_2.36.0 S4Vectors_0.40.1 [9] MatrixGenerics_1.14.0 matrixStats_1.0.0 [11] zellkonverter_1.10.1 ExperimentHub_2.8.1 [13] AnnotationHub_3.8.0 BiocFileCache_2.10.1 [15] dbplyr_2.4.0 BiocGenerics_0.48.1 loaded via a namespace (and not attached): [1] tidyselect_1.2.0 dplyr_1.1.3 [3] blob_1.2.4 filelock_1.0.2 [5] Biostrings_2.70.1 bitops_1.0-7 [7] fastmap_1.1.1 RCurl_1.98-1.13 [9] promises_1.2.1 digest_0.6.33 [11] mime_0.12 lifecycle_1.0.3 [13] ellipsis_0.3.2 KEGGREST_1.42.0 [15] interactiveDisplayBase_1.38.0 RSQLite_2.3.3 [17] magrittr_2.0.3 compiler_4.3.0 [19] rlang_1.1.2 tools_4.3.0 [21] utf8_1.2.4 yaml_2.3.7 [23] S4Arrays_1.2.0 bit_4.0.5 [25] curl_5.1.0 reticulate_1.30 [27] here_1.0.1 DelayedArray_0.28.0 [29] abind_1.4-5 HDF5Array_1.28.1 [31] withr_2.5.2 purrr_1.0.2 [33] grid_4.3.0 fansi_1.0.5 [35] xtable_1.8-4 Rhdf5lib_1.22.0 [37] cli_3.6.1 crayon_1.5.2 [39] generics_0.1.3 httr_1.4.7 [41] DBI_1.1.3 cachem_1.0.8 [43] rhdf5_2.44.0 zlibbioc_1.48.0 [45] parallel_4.3.0 AnnotationDbi_1.64.1 [47] BiocManager_1.30.22 XVector_0.42.0 [49] basilisk_1.12.0 vctrs_0.6.4 [51] Matrix_1.6-1 jsonlite_1.8.7 [53] dir.expiry_1.8.0 bit64_4.0.5 [55] glue_1.6.2 BiocVersion_3.18.0 [57] later_1.3.1 tibble_3.2.1 [59] pillar_1.9.0 rhdf5filters_1.12.1 [61] basilisk.utils_1.12.0 rappdirs_0.3.3 [63] htmltools_0.5.6 GenomeInfoDbData_1.2.11 [65] R6_2.5.1 rprojroot_2.0.3 [67] shiny_1.7.5 lattice_0.21-8 [69] png_0.1-8 memoise_2.0.1 [71] httpuv_1.6.11 Rcpp_1.0.11 [73] SparseArray_1.2.0 pkgconfig_2.0.3 ```

Session Info for success:

```r > sessionInfo() R version 4.3.0 (2023-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) Matrix products: default BLAS/LAPACK: /hpc/packages/minerva-centos7/intel/parallel_studio_xe_2019/compilers_and_libraries_2019.0.117/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so; LAPACK version 3.7.0 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] 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 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C time zone: America/New_York tzcode source: system (glibc) attached base packages: [1] stats4 stats graphics grDevices datasets utils methods [8] base other attached packages: [1] muscData_1.14.0 SingleCellExperiment_1.22.0 [3] SummarizedExperiment_1.30.1 Biobase_2.60.0 [5] GenomicRanges_1.52.0 GenomeInfoDb_1.36.0 [7] IRanges_2.34.0 S4Vectors_0.38.1 [9] MatrixGenerics_1.12.0 matrixStats_1.0.0 [11] zellkonverter_1.10.1 ExperimentHub_2.8.1 [13] AnnotationHub_3.8.0 BiocFileCache_2.8.0 [15] dbplyr_2.3.2 BiocGenerics_0.46.0 loaded via a namespace (and not attached): [1] tidyselect_1.2.0 dplyr_1.1.2 [3] blob_1.2.4 filelock_1.0.2 [5] Biostrings_2.68.0 bitops_1.0-7 [7] fastmap_1.1.1 RCurl_1.98-1.12 [9] promises_1.2.0.1 digest_0.6.33 [11] mime_0.12 lifecycle_1.0.3 [13] ellipsis_0.3.2 KEGGREST_1.40.0 [15] interactiveDisplayBase_1.38.0 RSQLite_2.3.1 [17] magrittr_2.0.3 compiler_4.3.0 [19] rlang_1.1.1 tools_4.3.0 [21] utf8_1.2.3 yaml_2.3.7 [23] S4Arrays_1.0.1 bit_4.0.5 [25] curl_5.0.0 reticulate_1.28 [27] here_1.0.1 DelayedArray_0.26.2 [29] HDF5Array_1.28.1 withr_2.5.0 [31] purrr_1.0.1 grid_4.3.0 [33] fansi_1.0.4 xtable_1.8-4 [35] Rhdf5lib_1.22.0 cli_3.6.1 [37] crayon_1.5.2 generics_0.1.3 [39] httr_1.4.6 DBI_1.1.3 [41] cachem_1.0.8 rhdf5_2.44.0 [43] zlibbioc_1.46.0 parallel_4.3.0 [45] AnnotationDbi_1.62.2 BiocManager_1.30.20 [47] XVector_0.40.0 basilisk_1.12.0 [49] vctrs_0.6.3 Matrix_1.5-4 [51] jsonlite_1.8.7 dir.expiry_1.8.0 [53] bit64_4.0.5 glue_1.6.2 [55] BiocVersion_3.17.1 later_1.3.1 [57] tibble_3.2.1 pillar_1.9.0 [59] basilisk.utils_1.12.0 rappdirs_0.3.3 [61] htmltools_0.5.5 rhdf5filters_1.12.1 [63] GenomeInfoDbData_1.2.10 R6_2.5.1 [65] rprojroot_2.0.3 shiny_1.7.4 [67] lattice_0.21-8 png_0.1-8 [69] memoise_2.0.1 httpuv_1.6.11 [71] Rcpp_1.0.11 pkgconfig_2.0.3 ```
hpages commented 10 months ago

Hi,

It looks like some of your packages are out-of-sync (e.g. DelayedArray 0.28.0 belongs to BioC 3.18 but HDF5Array 1.28.1 belongs to BioC 3.17). Please run BiocManager::valid() and make sure to fix all the reported problems.

Then restart R, load HDF5Array, and check the output of selectMethod("OLD_extract_sparse_array", "CSR_H5SparseMatrixSeed"). Here's what you should see:

library(HDF5Array)

selectMethod("OLD_extract_sparse_array", "CSR_H5SparseMatrixSeed")
# Method Definition:
# 
# function (x, index) 
# {
#     sas <- .load_sparse_data(x, index)
#     OLD_extract_sparse_array(sas, index)
# }
# <bytecode: 0x563fb74a2760>
# <environment: namespace:HDF5Array>
# 
# Signatures:
#         x                       
# target  "CSR_H5SparseMatrixSeed"

Best, H.

sessionInfo():

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.10

Matrix products: default
BLAS:   /home/hpages/R/R-4.3.0/lib/libRblas.so 
LAPACK: /home/hpages/R/R-4.3.0/lib/libRlapack.so;  LAPACK version 3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] 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   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

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

other attached packages:
 [1] HDF5Array_1.30.0      rhdf5_2.46.0          DelayedArray_0.28.0  
 [4] SparseArray_1.2.0     S4Arrays_1.2.0        abind_1.4-5          
 [7] IRanges_2.36.0        S4Vectors_0.40.1      MatrixGenerics_1.14.0
[10] matrixStats_1.0.0     BiocGenerics_0.48.1   Matrix_1.6-1.1       

loaded via a namespace (and not attached):
[1] zlibbioc_1.48.0     lattice_0.22-5      rhdf5filters_1.14.0
[4] XVector_0.42.0      Rhdf5lib_1.24.0     grid_4.3.0         
[7] compiler_4.3.0      tools_4.3.0         crayon_1.5.2       
GabrielHoffman commented 10 months ago

That fixed the issue, thanks!