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

Error: Ambigious assay when using LoadH5Seurat()

Open Averiian opened this issue 5 years ago • 6 comments

Hello,

I'm currently trying to read in a h5ad-file into R. Since seurats ReadH5ad()-function didn't work out for me, I tried to do it with seurat-disk. First I converted my file into a h5seurat-file:

Convert("test.h5ad", dest = "h5seurat", overwrite = TRUE, assay="RNA")

it printed:

Warning: Unknown file type: h5ad
Creating h5Seurat file for version 3.1.5.9900
Adding X as scale.data
Adding raw/X as data
Adding raw/X as counts
Adding meta.features from raw/var
Adding dispersions from scaled feature-level metadata
Adding dispersions_norm from scaled feature-level metadata
Merging gene_id from scaled feature-level metadata
Adding highly_variable from scaled feature-level metadata
Adding means from scaled feature-level metadata
Merging n_cells from scaled feature-level metadata
Adding X_diffmap as cell embeddings for diffmap
Adding X_draw_graph_fa as cell embeddings for draw_graph_fa
Adding X_pca as cell embeddings for pca
Adding X_tsne as cell embeddings for tsne
Adding X_umap as cell embeddings for umap
Adding PCs as feature loadings fpr pca
Adding miscellaneous information for pca
Adding standard deviations for pca
Adding miscellaneous information for umap
Adding diffmap_evals to miscellaneous data
Adding draw_graph to miscellaneous data
Adding louvain to miscellaneous data
Adding louvain_final_colors to miscellaneous data
Adding louvain_r0.5_entero_mat_sub_colors to miscellaneous data
Adding louvain_r0.5_entero_sub_colors to miscellaneous data
Adding phase_colors to miscellaneous data
Adding rank_genes_r0.5 to miscellaneous data
Adding rank_genes_r0.5_entero_mat_sub to miscellaneous data
Adding rank_genes_r0.5_entero_sub to miscellaneous data
Adding region_colors to miscellaneous data
Adding sample_colors to miscellaneous data
Adding umap_density_prox_dist_params to miscellaneous data
Adding layer counts as data in assay counts

That command generated a test.h5seurat-file, which I then tried to read in with:

var <- LoadH5Seurat("test.h5seurat")

and ran into following error:

Validating h5Seurat file
Error: Ambiguous assays

my sessioninfo is:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

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

other attached packages:
[1] SeuratDisk_0.0.0.9012 Seurat_3.2.0         

loaded via a namespace (and not attached):
  [1] nlme_3.1-148          bit64_4.0.2           RcppAnnoy_0.0.16      RColorBrewer_1.1-2   
  [5] httr_1.4.2            sctransform_0.2.1     tools_4.0.2           R6_2.4.1             
  [9] irlba_2.3.3           rpart_4.1-15          KernSmooth_2.23-17    uwot_0.1.8           
 [13] lazyeval_0.2.2        mgcv_1.8-31           colorspace_1.4-1      withr_2.2.0          
 [17] tidyselect_1.1.0      gridExtra_2.3         bit_4.0.4             compiler_4.0.2       
 [21] cli_2.0.2             hdf5r_1.3.2           plotly_4.9.2.1        scales_1.1.1         
 [25] lmtest_0.9-37         spatstat.data_1.4-3   ggridges_0.5.2        pbapply_1.4-2        
 [29] rappdirs_0.3.1        spatstat_1.64-1       goftest_1.2-2         stringr_1.4.0        
 [33] digest_0.6.25         spatstat.utils_1.17-0 pkgconfig_2.0.3       htmltools_0.5.0      
 [37] fastmap_1.0.1         htmlwidgets_1.5.1     rlang_0.4.7           rstudioapi_0.11      
 [41] shiny_1.5.0           generics_0.0.2        zoo_1.8-8             jsonlite_1.7.0       
 [45] ica_1.0-2             dplyr_1.0.1           magrittr_1.5          patchwork_1.0.1      
 [49] Matrix_1.2-18         fansi_0.4.1           Rcpp_1.0.5            munsell_0.5.0        
 [53] ape_5.4               abind_1.4-5           reticulate_1.16       lifecycle_0.2.0      
 [57] stringi_1.4.6         MASS_7.3-51.6         Rtsne_0.15            plyr_1.8.6           
 [61] grid_4.0.2            parallel_4.0.2        listenv_0.8.0         promises_1.1.1       
 [65] ggrepel_0.8.2         crayon_1.3.4          miniUI_0.1.1.1        deldir_0.1-28        
 [69] lattice_0.20-41       cowplot_1.0.0         splines_4.0.2         tensor_1.5           
 [73] pillar_1.4.6          igraph_1.2.5          future.apply_1.6.0    reshape2_1.4.4       
 [77] codetools_0.2-16      leiden_0.3.3          glue_1.4.1            data.table_1.13.0    
 [81] png_0.1-7             vctrs_0.3.2           httpuv_1.5.4          gtable_0.3.0         
 [85] RANN_2.6.1            purrr_0.3.4           polyclip_1.10-0       tidyr_1.1.1          
 [89] assertthat_0.2.1      future_1.18.0         ggplot2_3.3.2         rsvd_1.0.3           
 [93] mime_0.9              xtable_1.8-4          later_1.1.0.1         survival_3.1-12      
 [97] viridisLite_0.3.0     tibble_3.0.3          cluster_2.1.0         globals_0.12.5       
[101] fitdistrplus_1.1-1    ellipsis_0.3.1        ROCR_1.0-11          

and the h5ad-file was generated with these versions: scanpy=1.5.1 anndata=0.7.3 h5py=2.10.0 hdf5=1.10.6, following the steps of the latest notebook from https://github.com/theislab/single-cell-tutorial. Right before step 3.5.1 the file was generated with adata_ent.write("test.h5ad")

Does anyone have a solution or faced a similar issue?

Best regards, Averian

Averiian avatar Aug 17 '20 18:08 Averiian

Hi!

Just a note: I was able to circumvent this issue by removing the "layer" counts from my anndata object in python: del adata.layers Afterwards, the conversion to h5seurat and loading using LoadH5Seurat worked fine for me.

schmic05 avatar Mar 04 '21 12:03 schmic05

one could do var <- LoadH5Seurat("test.h5seurat",assays = "RNA") that worked for me.

alikhuseynov avatar Apr 14 '21 10:04 alikhuseynov

Hi

I have the same problem. When I run LoadH5Seurat() I get:

Validating h5Seurat file Error: Ambiguous assays

I have tried deleting the 'layers' from my Anndata object and repeating, but I then have this:

Convert("/path/obj_no_layers.h5ad", dest = "h5seurat", overwrite = F, assay = "RNA") Warning: Unknown file type: h5adCreating h5Seurat file for version 3.1.5.9900 Adding X as data Adding X as counts Adding meta.features from var Adding X_umap as cell embeddings for umap Adding cluster name_colors to miscellaneous data obj <- LoadH5Seurat("/path/obj_no_layers.h5seurat", assays="RNA") Validating h5Seurat file Initializing RNA with data Adding counts for RNA Adding feature-level metadata for RNA Error: Missing required datasets 'levels' and 'values'

If you could help that would be great thanks,

chrismahony avatar Feb 03 '23 10:02 chrismahony

this similar issue #109 might help

alikhuseynov avatar Feb 03 '23 10:02 alikhuseynov

Thanks, in the end is ran

del adata.var del adata.obs del adata.uns del adata.obsm del adata.layers

Then follwed SeuratDisk to read into Seurt. Then exported meta.data from Scanpy and loaded in that into the Seurat object.

chrismahony avatar Feb 03 '23 14:02 chrismahony