Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unknown file type: h5seurat #166

Open
aodainic7 opened this issue Oct 25, 2023 · 6 comments
Open

Error: Unknown file type: h5seurat #166

aodainic7 opened this issue Oct 25, 2023 · 6 comments

Comments

@aodainic7
Copy link

aodainic7 commented Oct 25, 2023

Hey everyone,
I am trying to convert Seurat to AnnData via h5Seurat following this guide https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html. My Object has 3 assays (RNA, ADT and SCT) and multiple reductions. Unfortunately, I have two issues:

  1. While saving the h5Seurat I get Error in if (ncol(x = x[[]])) { : argument is of length zero
    SeuratDisk::SaveH5Seurat(CD8_adt.harmony_sct_WNN, filename = "CD8_adt.harmony_sct_WNN.h5Seurat", overwrite = T, verbose = T)
    Although the error comes up, I still get a h5Seurat file saved.
  2. The Convert function does not recognize h5Seurat and will give the following error:
SeuratDisk::Convert("CD8_adt.harmony_sct_WNN.h5Seurat", dest = "h5ad")
Validating h5Seurat file
Warning: Cannot find dataset with cell namesWarning: 'assay' not set, setting to 'RNA'Error: Unknown file type: h5seurat

I have tried to save the object both as "h5seurat" and "h5Seurat" without success.
Thanks in advance!

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

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] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] SeuratDisk_0.0.0.9020   pbmc3k.SeuratData_3.1.4 cbmc.SeuratData_3.1.4   SeuratData_0.2.2        rstatix_0.7.2          
 [6] gt_0.10.0               limma_3.54.2            tidygate_0.4.9          progressr_0.14.0        RColorBrewer_1.1-3     
[11] gitlabr_2.0.1.9000      harmony_1.1.0           Rcpp_1.0.11             glmGamPoi_1.10.2        tidyseurat_0.7.4       
[16] ttservice_0.3.8         patchwork_1.1.3         Seurat_4.4.0            lubridate_1.9.3         forcats_1.0.0          
[21] stringr_1.5.0           dplyr_1.1.3             purrr_1.0.2             readr_2.1.4             tidyr_1.3.0            
[26] tibble_3.2.1            ggplot2_3.4.4           tidyverse_2.0.0         SeuratObject_4.9.9.9091 sp_2.1-1               

loaded via a namespace (and not attached):
  [1] utf8_1.2.4                  spatstat.explore_3.2-5      reticulate_1.34.0           tidyselect_1.2.0           
  [5] htmlwidgets_1.6.2           grid_4.2.1                  BiocParallel_1.32.6         Rtsne_0.16                 
  [9] munsell_0.5.0               ScaledMatrix_1.6.0          preprocessCore_1.60.2       codetools_0.2-18           
 [13] ica_1.0-3                   future_1.33.0               miniUI_0.1.1.1              withr_2.5.1                
 [17] spatstat.random_3.2-1       colorspace_2.1-0            Biobase_2.58.0              knitr_1.44                 
 [21] rstudioapi_0.15.0           stats4_4.2.1                SingleCellExperiment_1.20.1 ROCR_1.0-11                
 [25] tensor_1.5                  listenv_0.9.0               MatrixGenerics_1.10.0       GenomeInfoDbData_1.2.9     
 [29] polyclip_1.10-6             bit64_4.0.5                 rprojroot_2.0.3             parallelly_1.36.0          
 [33] vctrs_0.6.4                 generics_0.1.3              xfun_0.40                   timechange_0.2.0           
 [37] R6_2.5.1                    GenomeInfoDb_1.34.9         ggbeeswarm_0.7.2            rsvd_1.0.5                 
 [41] hdf5r_1.3.8                 cachem_1.0.8                bitops_1.0-7                spatstat.utils_3.0-4       
 [45] DelayedArray_0.24.0         promises_1.2.1              scales_1.2.1                beeswarm_0.4.0             
 [49] gtable_0.3.4                beachmat_2.14.2             globals_0.16.2              processx_3.8.2             
 [53] goftest_1.2-3               spam_2.10-0                 tidybulk_1.10.1             rlang_1.1.1                
 [57] splines_4.2.1               lazyeval_0.2.2              spatstat.geom_3.2-7         broom_1.0.5                
 [61] yaml_2.3.7                  reshape2_1.4.4              abind_1.4-5                 backports_1.4.1            
 [65] httpuv_1.6.12               tools_4.2.1                 ellipsis_0.3.2              jquerylib_0.1.4            
 [69] BiocGenerics_0.44.0         ggridges_0.5.4              plyr_1.8.9                  base64enc_0.1-3            
 [73] sparseMatrixStats_1.10.0    zlibbioc_1.44.0             RCurl_1.98-1.12             prettyunits_1.1.1          
 [77] ps_1.7.5                    deldir_1.0-9                pbapply_1.7-2               viridis_0.6.4              
 [81] cowplot_1.1.1               S4Vectors_0.36.2            zoo_1.8-12                  SummarizedExperiment_1.28.0
 [85] ggrepel_0.9.4               cluster_2.1.3               magrittr_2.0.3              data.table_1.14.8          
 [89] scattermore_1.2             lmtest_0.9-40               RANN_2.6.1                  fitdistrplus_1.1-11        
 [93] matrixStats_1.0.0           evaluate_0.22               hms_1.1.3                   mime_0.12                  
 [97] xtable_1.8-4                IRanges_2.32.0              gridExtra_2.3               compiler_4.2.1             
[101] scater_1.26.1               crayon_1.5.2                KernSmooth_2.23-20          htmltools_0.5.6.1          
[105] later_1.3.1                 tzdb_0.4.0                  rappdirs_0.3.3              MASS_7.3-57                
[109] Matrix_1.5-3                car_3.1-2                   cli_3.6.1                   parallel_4.2.1             
[113] dotCall64_1.1-0             igraph_1.5.1                arpr_0.1.2                  GenomicRanges_1.50.2       
[117] pkgconfig_2.0.3             job_0.3.0                   plotly_4.10.3               scuttle_1.8.4              
[121] spatstat.sparse_3.0-3       xml2_1.3.5                  bslib_0.5.1                 vipor_0.4.5                
[125] XVector_0.38.0              callr_3.7.3                 digest_0.6.33               sctransform_0.4.1          
[129] RcppAnnoy_0.0.21            spatstat.data_3.0-3         rmarkdown_2.25              leiden_0.4.3               
[133] uwot_0.1.16                 DelayedMatrixStats_1.20.0   curl_5.1.0                  shiny_1.7.5.1              
[137] lifecycle_1.0.3             nlme_3.1-157                jsonlite_1.8.7              carData_3.0-5              
[141] BiocNeighbors_1.16.0        desc_1.4.2                  viridisLite_0.4.2           fansi_1.0.5                
[145] pillar_1.9.0                lattice_0.20-45             pkgbuild_1.4.2              ggrastr_1.0.2              
[149] fastmap_1.1.1               httr_1.4.7                  survival_3.3-1              remotes_2.4.2.1            
[153] glue_1.6.2                  png_0.1-8                   bit_4.0.5                   sass_0.4.7                 
[157] stringi_1.7.12              BiocSingular_1.14.0         irlba_2.3.5.1               future.apply_1.11.0 
@Rohit-Satyam
Copy link

I am also getting the same error

@Rohit-Satyam
Copy link

Rohit-Satyam commented Nov 5, 2023

Okay this is weird. When I run FindVariableFeatures the error Error in guess_dtype(x = x, ...) : unknown type disappears

ring.mca<-mca[,c(mca$STAGE_HR == "ring" & mca$singleR %in% c("2hpi","4hpi") )] %>% NormalizeData()%>% FindVariableFeatures( selection.method = "vst", nfeatures = 2000)
SaveH5Seurat(ring.mca, filename = "ring.h5Seurat",verbose = TRUE, overwrite = TRUE)
Warning: Overwriting previous file ring.h5Seurat
Creating h5Seurat file for version 3.1.5.9900

But then a new error emerges when I run Convert("ring.h5Seurat", dest = "h5ad")

> Convert("ring.h5Seurat", dest = "h5ad")
Validating h5Seurat file
Adding data from RNA as X
Error in assay.group$obj_copy_to(dst_loc = dfile, dst_name = "X", src_name = x.data) : 
  HDF5-API Errors:
    error #000: ../../../src/H5Ocopy.c in H5Ocopy(): line 233: unable to copy object
        class: HDF5
        major: Object header
        minor: Unable to copy object

    error #001: ../../../src/H5Ocopy.c in H5O__copy(): line 289: source object not found
        class: HDF5
        major: Symbol table
        minor: Object not found

    error #002: ../../../src/H5Gloc.c in H5G_loc_find(): line 422: can't find object
        class: HDF5
        major: Symbol table
        minor: Object not found

    error #003: ../../../src/H5Gtraverse.c in H5G_traverse(): line 851: internal path traversal failed
        class: HDF5
        major: Symbol table
        minor: Object not found

    error #004: ../../../src/H5Gtraverse.c in H5G__traverse_real(): line 627: traversal operator failed
        class: HDF5
        major: Symbol table
        minor: Callback failed

    error #005: ../../../src/H5Gloc.c in H5G__loc_find_cb(): line 378: object 'data' doesn't exist

@Rohit-Satyam
Copy link

Rohit-Satyam commented Dec 18, 2023

Hi @mojaveazure, I was wondering if you guys looked into this behavior of the package?

Edit1: I even tried UpdateSeuratObject function to update my Seurat object as per latest recommendation but the error persists.

>SaveH5Seurat(ring.mca, filename = "ring.h5seurat", overwrite = TRUE, verbose = TRUE)
Creating h5Seurat file for version 3.1.5.9900
Error in guess_dtype(x = x, ...) : unknown type
> Convert("ring.h5seurat", dest = "h5ad", overwrite = TRUE)
Validating h5Seurat file
Warning: Cannot find dataset with cell names
Warning: 'assay' not set, setting to 'RNA'
Error: Unknown file type: h5seurat

@chloesavignac
Copy link

@Rohit-Satyam I faced the same problem. Downgrading Seurat and SeuratObject to v4 solved the issue for me.

@greensii
Copy link

I have this same problem when trying to convert a (source) h5Seurat file to a (dest) h5ad file.
Looking at the source code, I think it might stem from the Convert function calling the Convert.H5File method when it should be calling Convert.h5Seurat ?
the error message

stop("Unknown file type: ", stype, call. = FALSE)

only exists in Convert.H5File

@emidalla
Copy link

Downgrading Seurat and SeuratObject to v4 solved the issue for me.

Thank you very much @chloesavignac downgrading fixed the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants