Skip to content

Error while using LoadH5Seurat : "Error in sparseMatrix(i = x[["indices"]][] + 1, p = x[["indptr"]][], x = x[["data"]][], : 'p' must be a nondecreasing vector" #185

@ellenbouchard

Description

@ellenbouchard

Hello,

I am trying to use the SeuratDisk tools to read in a .h5ad file and convert it into a Seurat object.

When I use 'Convert' to generate a .h5seurat file, it works, with the following warnings:

Warning message:
“Unknown file type: h5ad”
Warning message:
“'assay' not set, setting to 'RNA'”
Creating h5Seurat file for version 3.1.5.9900

When I then use 'LoadH5Seurat' function on the resulting .h5seurat file, however, I get the following warning and error:

Warning message in sparseMatrix(i = x[["indices"]][] + 1, p = x[["indptr"]][], x = x[["data"]][], :
“NAs introduced by coercion to integer range”
Error in sparseMatrix(i = x[["indices"]][] + 1, p = x[["indptr"]][], x = x[["data"]][], : 'p' must be a nondecreasing vector c(0, ...)
Traceback:

1. LoadH5Seurat("./human_cortex_restricted.h5seurat")
2. LoadH5Seurat.character("./human_cortex_restricted.h5seurat")
3. LoadH5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
4. LoadH5Seurat.h5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
5. as.Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
6. as.Seurat.h5Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, neighbors = neighbors, images = images, 
 .     meta.data = meta.data, commands = commands, misc = misc, 
 .     tools = tools, verbose = verbose, ...)
7. AssembleAssay(assay = assay, file = x, slots = assays[[assay]], 
 .     verbose = verbose)
8. as.matrix(x = assay.group[["data"]])
9. as.matrix.H5Group(x = assay.group[["data"]])
10. as.sparse(x = x, ...)
11. as.sparse.H5Group(x = x, ...)
12. sparseMatrix(i = x[["indices"]][] + 1, p = x[["indptr"]][], x = x[["data"]][], 
  .     dims = h5attr(x = x, which = "dims"))
13. stop("'p' must be a nondecreasing vector c(0, ...)")

The code I'm using is:

Convert("./human_cortex_restricted.h5ad", dest="h5seurat", overwrite=TRUE)
file_seurat<- LoadH5Seurat("./human_cortex_restricted.h5seurat")

Please note that I'm using Seurat V5 but have also tried with the following modifier that did not work:
options(Seurat.object.assay.version = "v3")

The data file I'm using is open source from here:
https://cloud.hiz-saarland.de/s/PirTrKafxwbeQz7

Session info is below:

R version 4.3.3 (2024-02-29)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/groups/AjamiLab/Bouchard/miniconda3/envs/newcondaenv1/lib/libopenblasp-r0.3.27.so;  LAPACK version 3.12.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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] renv_1.0.11           schard_0.0.1          sceasy_0.0.7         
 [4] anndata_0.7.5.6       SeuratDisk_0.0.0.9021 reticulate_1.38.0    
 [7] DoubletFinder_2.0.4   RColorBrewer_1.1-3    pheatmap_1.0.12      
[10] ggrepel_0.9.5         dplyr_1.1.4           harmony_1.2.0        
[13] Rcpp_1.0.13           glmGamPoi_1.14.3      ggplot2_3.5.1        
[16] gridExtra_2.3         Seurat_5.1.0          SeuratObject_5.0.2   
[19] sp_2.1-4             

loaded via a namespace (and not attached):
  [1] RcppAnnoy_0.0.22            splines_4.3.3              
  [3] later_1.3.2                 pbdZMQ_0.3-11              
  [5] bitops_1.0-8                tibble_3.2.1               
  [7] polyclip_1.10-7             fastDummies_1.7.3          
  [9] lifecycle_1.0.4             rprojroot_2.0.4            
 [11] globals_0.16.3              processx_3.8.2             
 [13] lattice_0.22-6              hdf5r_1.3.11               
 [15] MASS_7.3-60                 magrittr_2.0.3             
 [17] plotly_4.10.4               remotes_2.4.2.1            
 [19] httpuv_1.6.15               sctransform_0.4.1          
 [21] spam_2.10-0                 sessioninfo_1.2.2          
 [23] pkgbuild_1.4.2              spatstat.sparse_3.1-0      
 [25] cowplot_1.1.3               pbapply_1.7-2              
 [27] abind_1.4-5                 pkgload_1.3.3              
 [29] zlibbioc_1.48.2             Rtsne_0.17                 
 [31] GenomicRanges_1.54.1        purrr_1.0.2                
 [33] BiocGenerics_0.48.1         RCurl_1.98-1.16            
 [35] rappdirs_0.3.3              GenomeInfoDbData_1.2.11    
 [37] IRanges_2.36.0              S4Vectors_0.40.2           
 [39] irlba_2.3.5.1               listenv_0.9.1              
 [41] spatstat.utils_3.0-5        goftest_1.2-3              
 [43] RSpectra_0.16-1             spatstat.random_3.2-3      
 [45] fitdistrplus_1.2-1          parallelly_1.38.0          
 [47] leiden_0.4.3.1              codetools_0.2-20           
 [49] DelayedArray_0.28.0         tidyselect_1.2.1           
 [51] matrixStats_1.3.0           stats4_4.3.3               
 [53] base64enc_0.1-3             spatstat.explore_3.2-6     
 [55] jsonlite_1.8.8              ellipsis_0.3.2             
 [57] progressr_0.14.0            ggridges_0.5.6             
 [59] survival_3.6-4              tools_4.3.3                
 [61] ica_1.0-3                   glue_1.7.0                 
 [63] SparseArray_1.2.4           here_1.0.1                 
 [65] usethis_2.2.2               MatrixGenerics_1.14.0      
 [67] GenomeInfoDb_1.38.8         IRdisplay_1.1              
 [69] withr_3.0.2                 fastmap_1.2.0              
 [71] rhdf5filters_1.14.1         fansi_1.0.6                
 [73] callr_3.7.3                 digest_0.6.36              
 [75] R6_2.5.1                    mime_0.12                  
 [77] colorspace_2.1-1            scattermore_1.2            
 [79] tensor_1.5                  spatstat.data_3.1-2        
 [81] utf8_1.2.4                  tidyr_1.3.1                
 [83] generics_0.1.3              data.table_1.15.4          
 [85] prettyunits_1.2.0           httr_1.4.7                 
 [87] htmlwidgets_1.6.4           S4Arrays_1.2.1             
 [89] uwot_0.2.2                  pkgconfig_2.0.3            
 [91] gtable_0.3.5                lmtest_0.9-40              
 [93] XVector_0.42.0              htmltools_0.5.8.1          
 [95] profvis_0.3.8               dotCall64_1.1-1            
 [97] scales_1.3.0                Biobase_2.62.0             
 [99] png_0.1-8                   reshape2_1.4.4             
[101] uuid_1.2-1                  curl_5.2.1                 
[103] nlme_3.1-165                rhdf5_2.46.1               
[105] repr_1.1.7                  zoo_1.8-12                 
[107] cachem_1.1.0                stringr_1.5.1              
[109] KernSmooth_2.23-24          parallel_4.3.3             
[111] miniUI_0.1.1.1              desc_1.4.2                 
[113] pillar_1.9.0                grid_4.3.3                 
[115] vctrs_0.6.5                 RANN_2.6.1                 
[117] urlchecker_1.0.1            promises_1.3.0             
[119] xtable_1.8-4                cluster_2.1.6              
[121] evaluate_0.24.0             cli_3.6.3                  
[123] compiler_4.3.3              rlang_1.1.4                
[125] crayon_1.5.3                future.apply_1.11.2        
[127] ps_1.7.5                    getPass_0.2-4              
[129] plyr_1.8.9                  fs_1.6.4                   
[131] stringi_1.8.4               viridisLite_0.4.2          
[133] deldir_2.0-4                assertthat_0.2.1           
[135] munsell_0.5.1               lazyeval_0.2.2             
[137] devtools_2.4.5              spatstat.geom_3.2-9        
[139] Matrix_1.6-5                IRkernel_1.3.2             
[141] RcppHNSW_0.6.0              patchwork_1.2.0            
[143] bit64_4.0.5                 future_1.34.0              
[145] Rhdf5lib_1.24.2             shiny_1.9.1                
[147] SummarizedExperiment_1.32.0 ROCR_1.0-11                
[149] igraph_2.0.3                memoise_2.0.1              
[151] bit_4.0.5          
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions