seurat-disk icon indicating copy to clipboard operation
seurat-disk copied to clipboard

Error converting h5Seurat to h5ad

Open EmeTexe opened this issue 4 years ago • 2 comments

I am currently having an error when converting a h5Seurat file to h5ad. Here is the command i use :

Convert("Nx.h5Seurat", dest = "h5ad", overwrite = TRUE)

And the error I get :

Validating h5Seurat file
Adding data from RNA as X
Error in `[[.H5Group`(assay.group, "features") : 
  An object with name features does not exist in this group

The object I am using is a merge of 2 other Seurat objects, and these 2 separately have no problem converting from h5Seurat to h5ad. I have no idea what might be causing this error...

EmeTexe avatar Jan 28 '21 12:01 EmeTexe

I'm also having this problem, it seems to not just be converting but loading of the h5seurat file after merging...

Here's an example:

library(SeuratDisk)
library(Seurat)
library(SeuratData)

data("pbmc3k.final")

so <- merge(pbmc3k.final, pbmc3k.final)
so <- NormalizeData(so, normalization.method = "LogNormalize", scale.factor = 10000)
so <- FindVariableFeatures(so, selection.method = "vst", nfeatures = 2000)
so <- ScaleData(so, verbose = FALSE)

SaveH5Seurat(so, 'tmp.h5seurat', overwrite = T)
x <- LoadH5Seurat('tmp.h5seurat')

gives me

Validating h5Seurat file
Error in `[[.H5Group`(assay.group, "features") : 
  An object with name features does not exist in this group
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS:   /opt/local/R-4.0.3/lib/R/lib/libRblas.so
LAPACK: /opt/local/R-4.0.3/lib/R/lib/libRlapack.so

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] pbmc3k.SeuratData_3.1.4 SeuratData_0.2.1        Seurat_3.2.2            SeuratDisk_0.0.0.9019  

loaded via a namespace (and not attached):
  [1] nlme_3.1-150         matrixStats_0.57.0   bit64_4.0.5          RcppAnnoy_0.0.17     RColorBrewer_1.1-2  
  [6] httr_1.4.2           sctransform_0.3.1    tools_4.0.3          R6_2.5.0             irlba_2.3.3         
 [11] rpart_4.1-15         KernSmooth_2.23-18   uwot_0.1.9           mgcv_1.8-33          lazyeval_0.2.2      
 [16] colorspace_2.0-0     withr_2.3.0          tidyselect_1.1.0     gridExtra_2.3        bit_4.0.4           
 [21] compiler_4.0.3       cli_2.2.0            hdf5r_1.3.3          plotly_4.9.2.1       scales_1.1.1        
 [26] lmtest_0.9-38        spatstat.data_2.0-0  ggridges_0.5.2       pbapply_1.4-3        rappdirs_0.3.1      
 [31] spatstat_1.64-1      goftest_1.2-2        stringr_1.4.0        digest_0.6.27        spatstat.utils_2.1-0
 [36] pkgconfig_2.0.3      htmltools_0.5.1.1    parallelly_1.21.0    fastmap_1.0.1        htmlwidgets_1.5.2   
 [41] rlang_0.4.9          rstudioapi_0.13      shiny_1.5.0          generics_0.1.0       zoo_1.8-8           
 [46] jsonlite_1.7.1       ica_1.0-2            dplyr_1.0.2          magrittr_2.0.1       patchwork_1.1.0     
 [51] Matrix_1.2-18        fansi_0.4.1          Rcpp_1.0.5           munsell_0.5.0        abind_1.4-5         
 [56] reticulate_1.18      lifecycle_0.2.0      stringi_1.5.3        yaml_2.2.1           MASS_7.3-53         
 [61] Rtsne_0.15           plyr_1.8.6           grid_4.0.3           parallel_4.0.3       listenv_0.8.0       
 [66] promises_1.1.1       ggrepel_0.8.2        crayon_1.3.4         miniUI_0.1.1.1       deldir_0.2-3        
 [71] lattice_0.20-41      cowplot_1.1.0        splines_4.0.3        tensor_1.5           pillar_1.4.7        
 [76] igraph_1.2.6         future.apply_1.6.0   reshape2_1.4.4       codetools_0.2-18     leiden_0.3.5        
 [81] glue_1.4.2           SeuratObject_4.0.0   data.table_1.13.2    png_0.1-7            vctrs_0.3.5         
 [86] httpuv_1.5.4         gtable_0.3.0         RANN_2.6.1           purrr_0.3.4          polyclip_1.10-0     
 [91] tidyr_1.1.2          assertthat_0.2.1     future_1.20.1        ggplot2_3.3.2        rsvd_1.0.3          
 [96] mime_0.9             xtable_1.8-4         later_1.1.0.1        survival_3.2-7       viridisLite_0.3.0   
[101] tibble_3.0.4         cluster_2.1.0        globals_0.14.0       fitdistrplus_1.1-1   ellipsis_0.3.1      
[106] ROCR_1.0-11 

Jon-bioinfo avatar Apr 23 '21 08:04 Jon-bioinfo

This seems to be fixed when I've made a new R environment in conda with create -c conda-forge -c bioconda -n r r-base r-seurat r-seuratdisk so some problem with a version of what I had above. Not sure what though.

Jon-bioinfo avatar May 18 '21 15:05 Jon-bioinfo