Coder Social home page Coder Social logo

mojaveazure / seurat-disk Goto Github PK

View Code? Open in Web Editor NEW
139.0 139.0 44.0 564 KB

Interfaces for HDF5-based Single Cell File Formats

Home Page: https://mojaveazure.github.io/seurat-disk

License: GNU General Public License v3.0

R 100.00%
hdf5-format single-cell-genomics single-cell-rna-seq

seurat-disk's Introduction

Hello World

I am Paul Hoffman, a senior bioinformatician with the Satija and Lappalainen Labs at the New York Genome Center. My work revolves around building software and for bioinformatic analyses, including an R package for analyzing single-cell data, along with several extension packages, and a pipeline for processing RNA-seq data. I work primarily in R and Python, but am always learning.

Social

Connect on LinkedIn

Technologies Used

Basic Stats

GitHub stats Top languages

Recent Activity

seurat-disk's People

Contributors

bbimber avatar mojaveazure avatar sheetalgiri avatar timoast avatar yuhanh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seurat-disk's Issues

create dataset _index - already exists! error

I am trying to convert a H5Seurat object to h5 and getting an error as follows

SaveH5Seurat(WT_KO, filename = "WT_KO_v5_RNAAssay.h5Seurat")
Convert("WT_KO_v5_RNAAssay.h5Seurat", dest = "h5ad", overwrite = TRUE)
Validating h5Seurat file

Adding scale.data from RNA as X

Adding data from RNA as raw

Transfering meta.data to obs

Error in dfile[["obs"]]$create_dataset(name = rownames, robj = Cells(x = source), : Can't create dataset _index - already exists!
Traceback:

1. Convert("WT_KO_v5_RNAAssay.h5Seurat", dest = "h5ad", overwrite = TRUE)
2. Convert.character("WT_KO_v5_RNAAssay.h5Seurat", dest = "h5ad", 
 .     overwrite = TRUE)
3. Convert(source = hfile, dest = dest, assay = assay, overwrite = overwrite, 
 .     verbose = verbose, ...)
4. Convert.h5Seurat(source = hfile, dest = dest, assay = assay, 
 .     overwrite = overwrite, verbose = verbose, ...)
5. H5SeuratToH5AD(source = source, dest = dest, assay = assay, overwrite = overwrite, 
 .     verbose = verbose)
6. dfile[["obs"]]$create_dataset(name = rownames, robj = Cells(x = source), 
 .     dtype = GuessDType(x = Cells(x = source)))
7. stop(paste("Can't create dataset", name, "- already exists!"))
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
[1] SeuratDisk_0.0.0.9018 SeuratObject_4.0.0    Seurat_4.0.0         

loaded via a namespace (and not attached):
  [1] Rtsne_0.15           colorspace_2.0-0     deldir_0.2-9        
  [4] ellipsis_0.3.1       ggridges_0.5.3       IRdisplay_0.7.0     
  [7] base64enc_0.1-3      spatstat.data_1.7-0  leiden_0.3.7        
 [10] listenv_0.8.0        farver_2.0.3         ggrepel_0.9.1       
 [13] bit64_4.0.5          codetools_0.2-18     splines_4.0.3       
 [16] polyclip_1.10-0      IRkernel_1.1.1.9000  jsonlite_1.7.2      
 [19] ica_1.0-2            cluster_2.1.0        png_0.1-7           
 [22] uwot_0.1.10          shiny_1.6.0          sctransform_0.3.2   
 [25] compiler_4.0.3       httr_1.4.2           assertthat_0.2.1    
 [28] Matrix_1.3-2         fastmap_1.1.0        lazyeval_0.2.2      
 [31] cli_2.3.0            later_1.1.0.1        htmltools_0.5.1.1   
 [34] tools_4.0.3          igraph_1.2.6         gtable_0.3.0        
 [37] glue_1.4.2           RANN_2.6.1           reshape2_1.4.4      
 [40] dplyr_1.0.4          Rcpp_1.0.6           spatstat_1.64-1     
 [43] scattermore_0.7      vctrs_0.3.6          nlme_3.1-151        
 [46] lmtest_0.9-38        stringr_1.4.0        globals_0.14.0      
 [49] mime_0.9             miniUI_0.1.1.1       lifecycle_0.2.0     
 [52] irlba_2.3.3          goftest_1.2-2        future_1.21.0       
 [55] MASS_7.3-53          zoo_1.8-8            scales_1.1.1        
 [58] promises_1.1.1       spatstat.utils_2.0-0 parallel_4.0.3      
 [61] RColorBrewer_1.1-2   reticulate_1.18      pbapply_1.4-3       
 [64] gridExtra_2.3        ggplot2_3.3.3        rpart_4.1-15        
 [67] stringi_1.5.3        repr_1.1.0           rlang_0.4.10        
 [70] pkgconfig_2.0.3      matrixStats_0.58.0   evaluate_0.14       
 [73] lattice_0.20-41      ROCR_1.0-11          purrr_0.3.4         
 [76] tensor_1.5           patchwork_1.1.1      htmlwidgets_1.5.3   
 [79] labeling_0.4.2       cowplot_1.1.1        bit_4.0.4           
 [82] tidyselect_1.1.0     parallelly_1.23.0    RcppAnnoy_0.0.18    
 [85] plyr_1.8.6           magrittr_2.0.1       R6_2.5.0            
 [88] generics_0.1.0       pbdZMQ_0.3-4         DBI_1.1.0           
 [91] pillar_1.4.7         withr_2.4.1          mgcv_1.8-33         
 [94] fitdistrplus_1.1-3   survival_3.2-7       abind_1.4-5         
 [97] tibble_3.0.6         future.apply_1.7.0   crayon_1.4.0        
[100] hdf5r_1.3.3          uuid_0.1-4           KernSmooth_2.23-18  
[103] plotly_4.9.3         grid_4.0.3           data.table_1.13.6   
[106] digest_0.6.27        xtable_1.8-4         tidyr_1.1.2         
[109] httpuv_1.5.5         munsell_0.5.0        viridisLite_0.3.0   

Convert between H5AD and H5Seurat results in an abrupt termination of the R session

Hi guys,

I tried to use the convert() function to read H5AD files into Seurat. However, after running convert( ), The R session was abruptly terminated. Below you can find the code:

library(SeuratDisk)

Registered S3 method overwritten by 'SeuratDisk':
method from
as.sparse.H5Group Seurat

Convert('adata_raw_beta_step5.h5ad', assay ='RNA',dest = "h5seurat", overwrite = TRUE,verbose = TRUE)

Warning: Unknown file type: h5ad
Creating h5Seurat file for version 3.1.2
Adding X as scale.data
Adding raw/X as data
Adding raw/X as counts
Adding meta.features from raw/var
Merging dispersions from scaled feature-level metadata
Merging dispersions_norm from scaled feature-level metadata
Merging highly_variable from scaled feature-level metadata
Merging means from scaled feature-level metadata
Merging n_cells from scaled feature-level metadata

Assertion failed : (oh ->mesg[u].dirty==0), function H50_ _ free, file ../../src/hdf5-1.12.0/src/h50int.c,line 3117

After I received the assertion failed message, the R session finished abruptly

The h5ad file was produced as follows:

A H5AD file was generated in python using scanpy==1.5.1 anndata==0.7.3 and h5py ==2.10.0

It did not make any difference whether adata.X dense or adata.raw.X sparse

Previously, I successfully used Convert() to produce Seurat objects (Normalized with SCRAN). However, in my unsuccessful attempt to produce a Seurat object, I used sc.pp.normalize_total( ) from scanpy.

Best,

Felipe

Error: Cannot acccess information in H5AD file

Similar to this issue (#7), I am trying to open an h5ad file from here: https://covid19.cog.sanger.ac.uk/submissions/release1/Immunodeficiency_Nasal_swabs.h5ad

Following your instructions...

import anndata
adata = anndata.read("deprez19_restricted.processed.h5ad")
adata.write("deprez19_restricted.processed.gzip.h5ad", compression="gzip")

I was able to created a gzipped file, but now when I try to use Read10X_h5, I get the following error:

An object with name X/shape does not exist in this group
Calls: soupify_h5 -> Read10X_h5 -> [[ -> [[.H5File
Execution halted

If I try:

   Convert(filename, dest='h5seurat', overwrite=TRUE)
   seurat_object <- LoadH5Seurat(paste(sample, '.h5seurat', sep=''))

I get this error:

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.5.9900
Adding X as data
Adding raw/X as counts
Adding meta.features from raw/var
R: H5Oint.c:3117: H5O__free: Assertion `oh->mesg[u].dirty == 0' failed.
h5.sh: line 1: 21356 Aborted

Very very stuck, any assistance is greatly appreciated.

Unable to read adata.h5ad file in R

Hi,
I'm unable to read any files saved from my analyses in Scanpy to Seurat. I've tried downgrading my Seurat package from V3 to V2 but this has been unsuccessful, here is a snippet of the error:

devtools::install_version(package = 'Seurat', version = package_version('2.3.4'))

ERROR: dependency ‘SDMTools’ is not available for package ‘Seurat’

  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Seurat’

Since I'm unable to downgrade, I have also tried Seurat-Disk and I get the following errors in response to my command:

Convert("/Users/.../adata.h5ad", dest = "h5seurat", overwrite = F)
scanpy_object_Seurat <- LoadH5Seurat("adata.h5seurat")
Screen Shot 2021-01-22 at 4 16 37 PM
Screen Shot 2021-01-22 at 4 17 03 PM

Error in H5File.open(filename, mode, file_create_pl, file_access_pl) :
HDF5-API Errors:
error #000: H5F.c in H5Fopen(): line 793: unable to open file
class: HDF5
major: File accessibility
minor: Unable to open file

error #001: H5VLcallback.c in H5VL_file_open(): line 3500: open failed
    class: HDF5
    major: Virtual Object Layer
    minor: Can't open object

error #002: H5VLcallback.c in H5VL__file_open(): line 3465: open failed
    class: HDF5
    major: Virtual Object Layer
    minor: Can't open object

error #003: H5VLnative_file.c in H5VL__native_file_open(): line 100: unable to open file
    class: HDF5
    major: File accessibility
    minor: Unable to open file

error #004: H5Fint.c in H5F_open(): line 1707: unable to read superblock
    class: HDF5
    major: File accessibility
    minor: Read failed

error #005: H5Fsuper.c in H5F__super_read(): line 621: truncated file: eof = 8798260576, sblock->base_addr = 0, stored_eof = 8798262112

SeuratDisk with Seurat 3.0.2 ?

Hello!

I was hoping to use SeuratDisk with Seurat 3.0.2, but I get the following error:

Error: package or namespace load failed for ‘SeuratDisk’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 namespace ‘Seurat’ 3.0.2 is being loaded, but >= 3.1.2 is required

I appreciate the clear error message, but I need to use Seurat 3.0.2 to maintain compatibility with Jupyter notebooks (for several reasons I do require Jupyter). Is there some reason SeuratDisk requires Seurat 3.1.2? I still have trouble opening h5ad files saved by anndata 0.7+ in Seurat 3.0.2.

Setup:

  • Ubuntu 18.04
  • R 4.0.2
  • Seurat 3.0.2

Thanks!

Error: class "Neighbor" is not exported by 'namespace:Seurat'

Hi,

I cannot be sure if this is a bug per se, but it has me stumped. I am trying to install Seurat-disk in RStudio with Seurat version 3.2.0 on Xubuntu 18.04.5 LTS using the suggested command, but I receive below error.

Do you have any suggestions on how to overcome this issue?

Thanks. Really appreciate your help :)

> if (!requireNamespace("remotes", quietly = TRUE)) {
+     install.packages("remotes")
+ }
> remotes::install_github("mojaveazure/seurat-disk")
Downloading GitHub repo mojaveazure/seurat-disk@master
Skipping 1 packages not available: Seurat
✓  checking for file ‘/tmp/RtmpsPTZ6o/remotesa57b199dad/mojaveazure-seurat-disk-003cdf0/DESCRIPTION’ ...
─  preparing ‘SeuratDisk’:
✓  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘SeuratDisk_0.0.0.9018.tar.gz’
   
Installing package into ‘/home/username/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package ‘SeuratDisk’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Error: class "Neighbor" is not exported by 'namespace:Seurat'
Execution halted
ERROR: lazy loading failed for package ‘SeuratDisk’
* removing ‘/home/username/R/x86_64-pc-linux-gnu-library/3.6/SeuratDisk’
Error: Failed to install 'SeuratDisk' from GitHub:
  (converted from warning) installation of package ‘/tmp/RtmpsPTZ6o/filea5767560513/SeuratDisk_0.0.0.9018.tar.gz’ had non-zero exit status

Problems in finding the cell and feature metadata

Hi guys,

I tried to use the convert() function to read H5AD files into Seurat. This worked to some extent. However, after running convert( ), I noticed the following warnings.

Convert("/Users/felipe/adatabeta_seurat.h5ad", dest = "h5seurat", overwrite = TRUE)

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.2
Adding X as data
Adding X as counts
Warning: Cannot yet add feature-level metadata from compound datasets
Warning: No cell-level metadata present, creating fake cell names

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 Treatment_categories to miscellaneous data
Adding batch_categories to miscellaneous data
Adding louvain_final_categories to miscellaneous data
Adding louvain_r0.0195_categories to miscellaneous data
Adding phase_categories to miscellaneous data
Adding layer counts as data in assay counts
Adding layer counts as counts in assay counts

Then, I loaded the created seurat object in R. After inspecting the data, I noticed that the feature and cell metadata were not imported. However, all the dimensionality reductions and count matrix were properly imported.

The h5ad file was produced as follows:

A loom file was generated in python using scanpy==1.5.1 anndata==0.7.3 and h5py ==2.10.0
Then, in a different environment with scanpy==1.4.4.post1 anndata==0.6.22.post1 and h5py==2.9.0, I finally produced the h5ad file.

It did not make any difference whether adata.X was sparse or whether I stored adata.raw.X as sparse and adata.X as dense.

Could be that I am failing to import all the data because the h5ad file was produced in an older scanpy and anndata version ?

Best,

Felipe

Error converting h5Seurat to h5ad

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...

Installation error SeuratDisk

Dear all,

I seem to have an issue installing the seuratdisk
can anyone maybe help me?

thank you so so much

i used:

remotes::install_github("mojaveazure/seurat-disk")

but i get the error below

* installing *source* package ‘SeuratDisk’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
sh: line 1: 11045 Killed: 9               R_TESTS= '/Library/Frameworks/R.framework/Resources/bin/R' --no-save --slave 2>&1 < '/var/folders/nb/57kr63yx2q53xww_zr7pgfrmncmyb0/T//RtmpRmhR3v/file2b1e40839b93'
ERROR: lazy loading failed for package ‘SeuratDisk’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/SeuratDisk’
Error: Failed to install 'SeuratDisk' from GitHub:
  (converted from warning) installation of package ‘/var/folders/nb/57kr63yx2q53xww_zr7pgfrmncmyb0/T//RtmpgxvSso/file29cf37ab7eaf/SeuratDisk_0.0.0.9019.tar.gz’ had non-zero exit status

with my R info

R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] Seurat_3.2.2

loaded via a namespace (and not attached):
  [1] nlme_3.1-149          matrixStats_0.57.0   
  [3] RcppAnnoy_0.0.16      RColorBrewer_1.1-2   
  [5] httr_1.4.2            rprojroot_1.3-2      
  [7] backports_1.1.10      sctransform_0.3.1    
  [9] tools_3.6.3           R6_2.4.1             
 [11] irlba_2.3.3           rpart_4.1-15         
 [13] KernSmooth_2.23-17    uwot_0.1.8           
 [15] lazyeval_0.2.2        mgcv_1.8-33          
 [17] colorspace_1.4-1      withr_2.3.0          
 [19] prettyunits_1.1.1     processx_3.4.4       
 [21] tidyselect_1.1.0      gridExtra_2.3        
 [23] curl_4.3              compiler_3.6.3       
 [25] cli_2.3.1             plotly_4.9.2.1       
 [27] scales_1.1.1          lmtest_0.9-38        
 [29] spatstat.data_1.4-3   callr_3.5.1          
 [31] ggridges_0.5.2        pbapply_1.4-3        
 [33] spatstat_1.64-1       goftest_1.2-2        
 [35] stringr_1.4.0         digest_0.6.26        
 [37] spatstat.utils_1.17-0 pkgconfig_2.0.3      
 [39] htmltools_0.5.0       fastmap_1.0.1        
 [41] htmlwidgets_1.5.2     rlang_0.4.10         
 [43] rstudioapi_0.11       shiny_1.5.0          
 [45] generics_0.0.2        zoo_1.8-8            
 [47] jsonlite_1.7.1        ica_1.0-2            
 [49] dplyr_1.0.2           magrittr_1.5         
 [51] patchwork_1.0.1       Matrix_1.2-18        
 [53] Rcpp_1.0.5            munsell_0.5.0        
 [55] abind_1.4-5           reticulate_1.16      
 [57] lifecycle_0.2.0       stringi_1.5.3        
 [59] MASS_7.3-53           pkgbuild_1.1.0       
 [61] Rtsne_0.15            plyr_1.8.6           
 [63] grid_3.6.3            parallel_3.6.3       
 [65] listenv_0.8.0         promises_1.1.1       
 [67] ggrepel_0.8.2         crayon_1.3.4         
 [69] miniUI_0.1.1.1        deldir_0.1-29        
 [71] lattice_0.20-41       cowplot_1.1.0        
 [73] splines_3.6.3         tensor_1.5           
 [75] ps_1.4.0              pillar_1.4.6         
 [77] igraph_1.2.6          future.apply_1.6.0   
 [79] reshape2_1.4.4        codetools_0.2-16     
 [81] leiden_0.3.3          glue_1.4.2           
 [83] remotes_2.2.0         data.table_1.13.2    
 [85] png_0.1-7             vctrs_0.3.4          
 [87] httpuv_1.5.4          gtable_0.3.0         
 [89] RANN_2.6.1            purrr_0.3.4          
 [91] polyclip_1.10-0       tidyr_1.1.2          
 [93] assertthat_0.2.1      future_1.19.1        
 [95] ggplot2_3.3.2         rsvd_1.0.3           
 [97] mime_0.9              xtable_1.8-4         
 [99] later_1.1.0.1         survival_3.2-7       
[101] viridisLite_0.3.0     tibble_3.0.4         
[103] cluster_2.1.0         globals_0.13.1       
[105] fitdistrplus_1.1-1    ellipsis_0.3.1       
[107] ROCR_1.0-11  

Error: Ambigious assay when using LoadH5Seurat()

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

Convert Error in dfile$obj_copy_from

I am trying to convert from AnnData to Seurat via h5Seurat. The process started, but then I got an error and an incomplete h5seurat was generated.

> Convert("file.h5ad", dest = "h5seurat", overwrite = TRUE) 
Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.5.9900
Adding X as data
Adding X as counts
Adding meta.features from var
Error in dfile$obj_copy_from(src_loc = source, src_name = "obs", dst_name = "meta.data") : 
  HDF5-API Errors:
    error #000: H5Ocopy.c in H5Ocopy(): line 233: unable to copy object
        class: HDF5
        major: Object header
        minor: Unable to copy object

    error #001: H5Ocopy.c in H5O__copy(): line 317: unable to copy object
        class: HDF5
        major: Object header
        minor: Unable to copy object

There were a few other error messages. I am just showing the first ones. Any idea how I may resolve this?

ValueError when reading .h5ad file (converted from .rds)

Hi,
I'm attempting to convert the .rds object from the Nieto et al 2020 preprint, following the recommended tutorial with SeuratDisk. I'm getting a value error when I try to read the .h5ad object using scanpy.

Load rds object in R:

library('Seurat')
library('SeuratDisk')
seurat <- readRDS('/mnt/data/public/nieto20/TICAtlas.rds')`
seurat

An object of class Seurat
92265 features across 317111 samples within 2 assays
Active assay: RNA (87659 features, 5000 variable features)
1 other assay present: integrated
2 dimensional reductions calculated: pca, umap

To convert:
SaveH5Seurat(seurat, filename = "/mnt/data/public/nieto20/TICAtlas.h5Seurat")

Creating h5Seurat file for version 3.1.5.9900
Adding counts for RNA
Adding data for RNA
Adding scale.data for RNA
Adding variable features for RNA
Adding feature-level metadata for RNA
Adding data for integrated
Adding scale.data for integrated
Adding variable features for integrated
No feature-level metadata found for integrated
Adding cell embeddings for pca
Adding loadings for pca
No projected loadings for pca
Adding standard deviations for pca
No JackStraw data for pca
Adding cell embeddings for umap
No loadings for umap
No projected loadings for umap
No standard deviations for umap
No JackStraw data for umap

Convert("/mnt/data/public/nieto20/TICAtlas.h5Seurat", dest = "h5ad")

Validating h5Seurat file
Adding scale.data from RNA as X
Transfering meta.features to var
Adding data from RNA as raw
Transfering meta.features to raw/var
Transfering meta.data to obs
Adding dimensional reduction information for umap (global)

Read .h5ad in python:

import scanpy as sc  
adata = sc.read_h5ad("/mnt/data/public/nieto20/TICAtlas.h5ad") 
adata

ValueError Traceback (most recent call last)
in
~/miniconda3/envs/r_env/lib/python3.8/site-packages/anndata/_io/h5ad.py in read_h5ad(filename, backed, as_sparse, as_sparse_fmt, chunk_size)
427 _clean_uns(d) # backwards compat
428
--> 429 return AnnData(**d)
430
431
~/miniconda3/envs/r_env/lib/python3.8/site-packages/anndata/_core/anndata.py in init(self, X, obs, var, uns, obsm, varm, layers, raw, dtype, shape, filename, filemode, asview, obsp, varp, oidx, vidx)
305 self._init_as_view(X, oidx, vidx)
306 else:
--> 307 self._init_as_actual(
308 X=X,
309 obs=obs,
~/miniconda3/envs/r_env/lib/python3.8/site-packages/anndata/_core/anndata.py in _init_as_actual(self, X, obs, var, uns, obsm, varm, varp, obsp, raw, layers, dtype, shape, filename, filemode)
516 _move_adj_mtx({"uns": self._uns, "obsp": self._obsp})
517
--> 518 self._check_dimensions()
519 self._check_uniqueness()
520
~/miniconda3/envs/r_env/lib/python3.8/site-packages/anndata/_core/anndata.py in _check_dimensions(self, key)
1774 )
1775 if "var" in key and len(self._var) != self._n_vars:
-> 1776 raise ValueError(
1777 "Variables annot. var must have number of columns of X"
1778 f" ({self._n_vars}), but has {self._var.shape[0]} rows."
ValueError: Variables annot. var must have number of columns of X (5000), but has 4997 rows.

Environment info
(let me know if you need more detailed, it's rather long)

R version 3.6.1
SeuratDisk_0.0.0.9013
Seurat_3.2.2
python==3.8.5
scanpy==1.6.0
anndata==0.7.4

I wanted to report the issue and ask if there were any obvious mistakes or workarounds?
(Just as a warning, I had to use an EC2 instance with 128Gb RAM as it was crashing my instance with 64Gb RAM. Not totally sure if there's a straightforward way to subset the seurat object to test the conversion?)

Thanks,
Julie

Update about the data ... I guess they just also released the data with a h5ad version already. :/

Error converting h5ad file

Dear Developers,

I tried to convert an h5ad file to h5seurat, but encountered the error messages below. The h5ad file was from https://zenodo.org/record/3572422#.X76nKVNKh-U (HTA08.v01.A06.Science_human_tcells.h5ad). Any suggestions on how to fix this? Thanks!

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.5.9900
Adding X as data
Adding X as counts
Error: Cannot find feature names in this H5AD file

SeuratDisk::as.loom fails to store umap embeddings in loom object

Hello,

I have an integrated dataset (with SCT used for normalization) that I tried to save as a loom file for downstream analysis with Scanpy. I am, however, unable to get back the umap and pca embedding as before. Please advise.

R version 4.0.2 (2020-06-22)
SeuratDisk_0.0.0.9018
Seurat_4.0.0

as.loom output:
Adding col attribute CellID
Adding col attribute orig.ident
Adding col attribute nCount_RNA
Adding col attribute nFeature_RNA
Adding col attribute percent.mt
Adding col attribute percent.S100
Adding col attribute percent.Ly6
Adding col attribute percent.Cd14
Adding col attribute nCount_SCT
Adding col attribute nFeature_SCT
Adding col attribute integrated_snn_res.0.8
Adding col attribute seurat_clusters
Adding row attribute Gene

adata object in Scanpy:
AnnData object with n_obs × n_vars = 2238 × 15611
obs: 'integrated_snn_res.0.8', 'nCount_RNA', 'nCount_SCT', 'nFeature_RNA', 'nFeature_SCT', 'orig.ident', 'percent.Cd14', 'percent.Ly6', 'percent.S100', 'percent.mt', 'seurat_clusters'
layers: 'scale.data'

Not compatible with new AnnData file format/shape

Hi!

I tested out the package the other way around, I found a work-around to load an AnnData object in Seurat and did some analyses. Now I want to return with my new and improved Seurat-object to Scanpy.

So I followed the following steps:

SaveH5Seurat(object, filename = "ConvertTest.h5Seurat")
Convert("ConvertTest.h5Seurat", dest = "h5ad")

And it throws the following error when reading in with scanpy==1.4.6:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-977de11dd812> in <module>
----> 1 adata = sc.read_h5ad("../../data/output/embryo_Hb/embryo.test2.h5ad")

~\Anaconda3\envs\UMCU\lib\site-packages\anndata\_io\h5ad.py in read_h5ad(filename, backed, as_sparse, as_sparse_fmt, chunk_size)
    427     _clean_uns(d)  # backwards compat
    428 
--> 429     return AnnData(**d)
    430 
    431 

~\Anaconda3\envs\UMCU\lib\site-packages\anndata\_core\anndata.py in __init__(self, X, obs, var, uns, obsm, varm, layers, raw, dtype, shape, filename, filemode, asview, obsp, varp, oidx, vidx)
    296                 varp=varp,
    297                 filename=filename,
--> 298                 filemode=filemode,
    299             )
    300 

~\Anaconda3\envs\UMCU\lib\site-packages\anndata\_core\anndata.py in _init_as_actual(self, X, obs, var, uns, obsm, varm, varp, obsp, raw, layers, dtype, shape, filename, filemode)
    495             self._raw = None
    496         elif isinstance(raw, cabc.Mapping):
--> 497             self._raw = Raw(self, **raw)
    498         else:  # is a Raw from another AnnData
    499             self._raw = Raw(self, raw._X, raw.var, raw.varm)

~\Anaconda3\envs\UMCU\lib\site-packages\anndata\_core\raw.py in __init__(self, adata, X, var, varm)
     29         if adata.isbacked == (X is None):
     30             self._X = X
---> 31             self._var = _gen_dataframe(var, self.X.shape[1], ["var_names"])
     32             self._varm = AxisArrays(self, 1, varm)
     33         elif X is None:  # construct from adata

AttributeError: 'dict' object has no attribute 'shape'

And I think it has to do with the fact that they changed the file format in AnnData =>0.7

Support for AnnData/H5AD files

Tracker for bugs in the h5Seurat/H5AD converter. Please note:

  • All support for reading and writing H5AD files is done through the h5Seurat intermediate. There is no direct Seurat object/H5AD saving and loading
  • There is no support for H5T_COMPOUND datasets found in the obs, var, obsm, and varm slots older AnnData objects. Modern AnnData objects use HDF5 groups, which are supported in SeuratDisk

Strange h5.ad conversion error

I run SaveH5Seurat(pbmc10k, filename = "pbmc10k.h5Seurat") and an output of a verbose is as follows;

Creating h5Seurat file for version 3.1.5.9900
Adding counts for RNA
Adding data for RNA
Adding scale.data for RNA
Adding variable features for RNA
Adding feature-level metadata for RNA
Adding counts for unspliced
Adding data for unspliced
No variable features found for unspliced
No feature-level metadata found for unspliced
Adding counts for spliced
Adding data for spliced
No variable features found for spliced
No feature-level metadata found for spliced
Adding counts for SCT
Adding data for SCT
Adding scale.data for SCT
Adding variable features for SCT
Adding feature-level metadata for SCT
Adding cell embeddings for pca
Adding loadings for pca
No projected loadings for pca
Adding standard deviations for pca
No JackStraw data for pca
Adding cell embeddings for umap
No loadings for umap
No projected loadings for umap
No standard deviations for umap
No JackStraw data for umap

It looks like spliced and unspliced counts were added in pbmc10k.h5Seurat. Then I converted this to .h5ad as follows,

> Convert("pbmc10k.h5Seurat", dest = "h5ad" )
Validating h5Seurat file
Adding scale.data from RNA as X
Transfering meta.features to var
Adding data from RNA as raw
Transfering meta.features to raw/var
Transfering meta.data to obs
Adding dimensional reduction information for pca
Adding feature loadings for pca
Adding dimensional reduction information for umap (global)

After importing pbmc10k.h5Seurat in scVelo, there was no spliced or unspliced variables (counts);

adata = scv.read("/Desktop/pbmc10k.h5ad")
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
WARNING: Could not find spliced / unspliced counts.

When I looked in adata, I found;

scv.utils.show_proportions(adata)
Abundance of []: []

adata
AnnData object with n_obs × n_vars = 10194 × 2000
    obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'percent.mt', 'nCount_SCT', 'nFeature_SCT', 'SCT_snn_res.0.8', 'seurat_clusters', 'S.Score', 'G2M.Score', 'Phase', 'old.ident', 'hpca.fine', 'hpca.main', 'monaco.main', 'monaco.fine', 'initial_size'
    var: 'vst.mean', 'vst.variance', 'vst.variance.expected', 'vst.variance.standardized', 'vst.variable'
    obsm: 'X_pca', 'X_umap'
    varm: 'PCs'

For some reason, spliced and unsplivced vars were replaced by 'vst.mean', 'vst.variance', 'vst.variance.expected', 'vst.variance.standardized', 'vst.variable'

I really appreciate any help for resolution of this issue.

str(pbmc10k)
Formal class 'Seurat' [package "SeuratObject"] with 13 slots
  ..@ assays      :List of 4
  .. ..$ RNA      :Formal class 'Assay' [package "Seurat"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:24330253] 25 30 32 42 43 44 51 59 60 62 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 4803 7036 11360 11703 15846 18178 20413 22584 27802 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "MIR1302-2HG" "FAM138A" "OR4F5" "AL627309.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:24330253] 1 2 1 1 1 3 1 1 1 1 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:24330253] 25 30 32 42 43 44 51 59 60 62 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 4803 7036 11360 11703 15846 18178 20413 22584 27802 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "MIR1302-2HG" "FAM138A" "OR4F5" "AL627309.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:24330253] 0.367 0.634 0.367 0.367 0.367 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ scale.data   : num [1:2000, 1:10194] -0.0829 -0.2648 -0.195 -0.0133 1.2823 ...
  .. .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. .. ..$ : chr [1:2000] "PLEKHN1" "HES4" "ISG15" "LINC01342" ...
  .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. ..@ key          : chr "rna_"
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : chr [1:2000] "PTGDS" "IGLC3" "PPBP" "CXCL10" ...
  .. .. .. ..@ meta.features:'data.frame':	36601 obs. of  5 variables:
  .. .. .. .. ..$ vst.mean                 : num [1:36601] 0 0 0 0.00392 0 ...
  .. .. .. .. ..$ vst.variance             : num [1:36601] 0 0 0 0.00391 0 ...
  .. .. .. .. ..$ vst.variance.expected    : num [1:36601] 0 0 0 0.00452 0 ...
  .. .. .. .. ..$ vst.variance.standardized: num [1:36601] 0 0 0 0.865 0 ...
  .. .. .. .. ..$ vst.variable             : logi [1:36601] FALSE FALSE FALSE FALSE FALSE FALSE ...
  .. .. .. ..@ misc         : NULL
  .. ..$ unspliced:Formal class 'Assay' [package "Seurat"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:20057627] 8 46 53 69 70 71 72 73 84 89 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 3837 6398 9489 10407 14220 16595 18856 20831 24609 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "BX004987.1" "AC145212.1" "MAFIP" "AC011043.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:20057627] 1 3 1 1 2 1 1 9 1 1 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:20057627] 8 46 53 69 70 71 72 73 84 89 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 3837 6398 9489 10407 14220 16595 18856 20831 24609 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "BX004987.1" "AC145212.1" "MAFIP" "AC011043.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:20057627] 1 3 1 1 2 1 1 9 1 1 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ key          : chr "unspliced_"
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : logi(0) 
  .. .. .. ..@ meta.features:'data.frame':	36601 obs. of  0 variables
  .. .. .. ..@ misc         : NULL
  .. ..$ spliced  :Formal class 'Assay' [package "Seurat"] with 8 slots
  .. .. .. ..@ counts       :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:19059316] 48 49 50 54 59 60 61 65 70 72 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 3840 5465 8968 9150 12398 14145 15854 17504 21746 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "BX004987.1" "AC145212.1" "MAFIP" "AC011043.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:19059316] 1 1 3 1 1 1 1 1 1 2 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ data         :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. .. .. .. ..@ i       : int [1:19059316] 48 49 50 54 59 60 61 65 70 72 ...
  .. .. .. .. .. ..@ p       : int [1:10195] 0 3840 5465 8968 9150 12398 14145 15854 17504 21746 ...
  .. .. .. .. .. ..@ Dim     : int [1:2] 36601 10194
  .. .. .. .. .. ..@ Dimnames:List of 2
  .. .. .. .. .. .. ..$ : chr [1:36601] "BX004987.1" "AC145212.1" "MAFIP" "AC011043.1" ...
  .. .. .. .. .. .. ..$ : chr [1:10194] "AAACCCACATAACTCG-1" "AAACCCACATGTAACC-1" "AAACCCAGTGAGTCAG-1" "AAACCCAGTGCTTATG-1" ...
  .. .. .. .. .. ..@ x       : num [1:19059316] 1 1 3 1 1 1 1 1 1 2 ...
  .. .. .. .. .. ..@ factors : list()
  .. .. .. ..@ scale.data   : num[0 , 0 ] 
  .. .. .. ..@ key          : chr "spliced_"
  .. .. .. ..@ assay.orig   : NULL
  .. .. .. ..@ var.features : logi(0) 
  .. .. .. ..@ meta.features:'data.frame':	36601 obs. of  0 variables

package.version("SeuratDisk")
[1] "0.0.0.9018"

SaveH5Seurat error

Hello, when I run
SaveH5Seurat(lung.integrated, filename = "./tmp.h5Seurat")
There has an error:

`Error in H5File.open(filename, mode, file_create_pl, file_access_pl) : 
  HDF5-API Errors:
    error #000: H5F.c in H5Fcreate(): line 444: unable to create file
        class: HDF5
        major: File accessibilty
        minor: Unable to open file

    error #001: H5Fint.c in H5F_open(): line 1567: unable to lock the file
        class: HDF5
        major: File accessibilty
        minor: Unable to open file

    error #002: H5FD.c in H5FD_lock(): line 1640: driver lock request failed
        class: HDF5
        major: Virtual File Layer
        minor: Can't update object

    error #003: H5FDsec2.c in H5FD_sec2_lock(): line 959: unable to lock file, errno = 5, error message = 'Input/output error'
        class: HDF5
        major: File accessibilty
        minor: Bad file ID accessed`

Unable to convert from AnnData to Seurat object

I was previously able to use SeuratDisk to convert from AnnData to Seurat object (using SeuratDisk version 0.0.0.9013). However, when updating the package to the most recent version (0.0.0.9018), this code no longer works. I have tried with my data and the pbmc3k data. Although the website lists 0.0.0.9015 as the current version, I can only install version 0.0.0.9018 from github. Can you also provide also older versions of SeuratDisk?

Is it possible to install seurat-disk for R 3.6.0 ?

Hi,

Is it possible to install seurat-disk for R 3.6.0? When trying, I get an error message about the "methods" version not being new enough. When trying to update methods, R gives me an error message saying that it is a base package that cannot be updated.

Installing package into ‘/cluster/home/sfux/R/x86_64-slackware-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
* installing *source* package ‘SeuratDisk’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
  namespace ‘methods’ 3.6.0 is already loaded, but >= 3.6.1 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package ‘SeuratDisk’
* removing ‘/cluster/home/sfux/R/x86_64-slackware-linux-gnu-library/3.6/SeuratDisk’
Error in i.p(...) :
  (converted from warning) installation of package ‘/tmp/RtmppXw4v3/file3fbe2edcc041/SeuratDisk_0.0.0.9010.tar.gz’ had non-zero exit status
> install.packages("methods")
Installing package into ‘/cluster/home/sfux/R/x86_64-slackware-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
Warning messages:
1: package ‘methods’ is not available (for R version 3.6.0)
2: package ‘methods’ is a base package, and should not be updated

Does this mean that at least R 3.6.1 is required to install seurat-disk? If yes, could you please add this requirement to the README file. If this is the case, is it possible to install an older version of seurat-disk for R 3.6.0?

I noticed that this github repository does not have any releases or tags, just a master branch. Is there no versioning of this package?

Best regards

Sam

Error in Graphs(object = x) : could not find function "Graphs"

When I want to save seurat.object to loom file, I encountered this error:

> object.loom <- as.loom(object, filename = 'neurons.loom', verbose = T)
Saving data from RNA as /matrix
  |===========================================================| 100%
Adding slot counts for assay RNA
Adding layer counts
  |===========================================================| 100%
Adding slot scale.data for assay RNA
Adding layer scale.data
Error in Graphs(object = x) : could not find function "Graphs"

The code performed well on previous version of seurat. However, the new seurat required SeuratDisk. Even I checked all the dependencies listed, I still got this error.

Error: Too many values for levels provided

Hi,

Thank you for creating Seurat-disk.

I am running in the following error:
obj <- LoadH5Seurat("obj_170820.h5seurat")
Validating h5Seurat file
Initializing Ms with data
Initializing Mu with data
Initializing RNA with data
Adding counts for RNA
Adding scale.data for RNA
Adding feature-level metadata for RNA
Error: Too many values for levels provided

Ler me know if I am doing anything wrong, Convert runs smoothly before that

Error: Cannot find feature names in this H5AD file

File:

The h5ad file was obtained here: https://covid19.cog.sanger.ac.uk/deprez19_restricted.processed.h5ad

I also tried a few other h5ad files and had the same error.

Command:

Convert("deprez19_restricted.processed.h5ad", dest = "h5seurat", overwrite = TRUE)`

Error message:

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.2
Adding X as data
Adding X as counts
Error: Cannot find feature names in this H5AD file

> sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] 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.9009

loaded via a namespace (and not attached):
[1] httr_1.4.1 tidyr_1.1.0 bit64_0.9-7 hdf5r_1.3.2.9000 jsonlite_1.6.1 viridisLite_0.3.0 splines_3.6.1
[8] leiden_0.3.3 assertthat_0.2.1 ggrepel_0.8.2 globals_0.12.5 pillar_1.4.4 lattice_0.20-41 glue_1.4.1
[15] reticulate_1.15 digest_0.6.25 RColorBrewer_1.1-2 colorspace_1.4-1 cowplot_1.0.0 htmltools_0.4.0 Matrix_1.2-18
[22] plyr_1.8.6 pkgconfig_2.0.3 tsne_0.1-3 listenv_0.8.0 purrr_0.3.4 patchwork_1.0.0 scales_1.1.1
[29] RANN_2.6.1 Rtsne_0.15 tibble_3.0.1 ggplot2_3.3.0 ellipsis_0.3.1 withr_2.2.0 ROCR_1.0-11
[36] pbapply_1.4-2 lazyeval_0.2.2 cli_2.0.2 survival_3.1-12 magrittr_1.5 crayon_1.3.4 future_1.17.0
[43] fansi_0.4.1 nlme_3.1-148 MASS_7.3-51.6 ica_1.0-2 tools_3.6.1 fitdistrplus_1.1-1 data.table_1.12.8
[50] lifecycle_0.2.0 stringr_1.4.0 plotly_4.9.2.1 munsell_0.5.0 cluster_2.1.0 irlba_2.3.3 packrat_0.5.0
[57] compiler_3.6.1 rsvd_1.0.3 rlang_0.4.6 grid_3.6.1 ggridges_0.5.2 rstudioapi_0.11 RcppAnnoy_0.0.16
[64] rappdirs_0.3.1 htmlwidgets_1.5.1 igraph_1.2.5 Seurat_3.1.5 gtable_0.3.0 codetools_0.2-16 reshape2_1.4.4
[71] R6_2.4.1 gridExtra_2.3 zoo_1.8-8 dplyr_0.8.5 bit_1.1-15.2 future.apply_1.5.0 uwot_0.1.8
[78] KernSmooth_2.23-17 ape_5.3 stringi_1.4.6 parallel_3.6.1 Rcpp_1.0.4.6 vctrs_0.3.0 sctransform_0.2.1
[85] png_0.1-7 tidyselect_1.1.0 lmtest_0.9-37

Unable transfer h5ad to Seurat with unwanted ERROR,please help!

I generated h5ad by scanpy and I want to load it to R by SeuratDisk, but an unwanted Error happend which is shown below , any idea to solve this problem?

Convert("ECC.h5ad", dest = "h5seurat", overwrite = TRUE)
Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
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
Merging dispersions from scaled feature-level metadata
Merging dispersions_norm from scaled feature-level metadata
Adding gene_ids from scaled feature-level metadata
Adding genenames from scaled feature-level metadata
Merging highly_variable from scaled feature-level metadata
Adding mean from scaled feature-level metadata
Merging means from scaled feature-level metadata
Adding std from scaled feature-level metadata
Adding X_pca as cell embeddings for pca
Adding X_pca_harmony as cell embeddings for pca_harmony
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
Error in dfile[["reductions"]][[reduc]]$obj_copy_from(src_loc = source[["uns"]], :
HDF5-API Errors:
error #000: H5Ocopy.c in H5Ocopy(): line 233: unable to copy object
class: HDF5
major: Object header
minor: Unable to copy object

error #001: H5Ocopy.c in H5O__copy(): line 317: unable to copy object
    class: HDF5
    major: Object header
    minor: Unable to copy object

error #002: H5Ocopy.c in H5O__copy_obj(): line 1221: unable to copy object
    class: HDF5
    major: Object header
    minor: Unable to copy object

error #003: H5Ocopy.c in H5O__copy_header(): line 1165: unable to copy object
    class: HDF5
    major: Object header
    minor: Unable to copy object

error #004: H5Ocopy.c in H5O__copy_header_real(): line 872: unable to perform 'post copy' operation on message
    class: HDF5
    major: Object header
    minor: Unable to initialize object

error #005: H5Ostab.c in H5O__stab_post_copy_file(): line 403: iteration operator failed
    class: HD

Error in private$closeFun(id) : HDF5-API Errors:
error #000: H5F.c in H5Fclose(): line 675: closing file ID failed
class: HDF5
major: File accessibilty
minor: Unable to close file

error #001: H5Fint.c in H5F__close(): line 1952: decrementing file ID failed
    class: HDF5
    major: File accessibilty
    minor: Unable to decrement reference count

error #002: H5I.c in H5I_dec_app_ref(): line 1300: can't decrement ID ref count
    class: HDF5
    major: Object atom
    minor: Unable to decrement reference count

error #003: H5Fint.c in H5F__close_cb(): line 2010: can't close file
    class: HDF5
    major: File accessibilty
    minor: Unable to close file

error #004: H5Fint.c in H5F_try_close(): line 2181: problems closing file
    class: HDF5
    major: File accessibilty
    minor: Unable to close file

error #005: H5Fint.c in H5F__dest(): line 1277: problems closing file
    class: HDF5
    major: File

Convert error with an .h5ad file

Hi,

I am trying to Convert an .h5ad file like so:
Convert('/path/dat.h5ad', dest='/path/dat.h5seurat')

and I get the following error:

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.2
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
Adding highly_variable from scaled feature-level metadata
Adding means from scaled feature-level metadata
Error in attr_obj$read() : HDF5-API Errors:
    error #000: ../../src/hdf5-1.10.0-1/src/H5A.c in H5Aread(): line 687: null attribute buffer
        class: HDF5
        major: Invalid arguments to routine
        minor: Bad value

traceback:

8: .Call("R_H5Aread", self$id, mem_type$id, buffer, FALSE, PACKAGE = "hdf5r")
7: attr_obj$read()
6: h5attr(x = assay.group[["meta.features"]], which = "column-order")
5: H5ADToH5Seurat(source = source, dest = dest, assay = assay, overwrite = overwrite, 
       verbose = verbose)
4: Convert.H5File(source = hfile, dest = dest, assay = assay, overwrite = overwrite, 
       verbose = verbose, ...)
3: Convert(source = hfile, dest = dest, assay = assay, overwrite = overwrite, 
       verbose = verbose, ...)
2: Convert.character("/Users/bsierieb/Work-local/project_scRNA-seq/2019.12.03_scRNA-seq/data/BS_10X_1/BS_10X_1_update15_alevin/Scanpy+2_3_4/dat_1_2_3_4_KC.h5ad", 
       dest = "/Users/bsierieb/Work-local/project_scRNA-seq/2019.12.03_scRNA-seq/data/BS_10X_1/BS_10X_1_update15_alevin/Scanpy+2_3_4/dat_1_2_3_4_KC.h5seurat")
1: Convert("/Users/bsierieb/Work-local/project_scRNA-seq/2019.12.03_scRNA-seq/data/BS_10X_1/BS_10X_1_update15_alevin/Scanpy+2_3_4/dat_1_2_3_4_KC.h5ad", 
       dest = "/Users/bsierieb/Work-local/project_scRNA-seq/2019.12.03_scRNA-seq/data/BS_10X_1/BS_10X_1_update15_alevin/Scanpy+2_3_4/dat_1_2_3_4_KC.h5seurat")

sessionInfo:

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] SeuratDisk_0.0.0.9008

loaded via a namespace (and not attached):
 [1] httr_1.4.1         tidyr_1.1.0        bit64_0.9-7        hdf5r_1.3.2       
 [5] jsonlite_1.6.1     viridisLite_0.3.0  splines_3.6.1      leiden_0.3.3      
 [9] assertthat_0.2.1   ggrepel_0.8.2      globals_0.12.5     pillar_1.4.4      
[13] lattice_0.20-38    glue_1.4.1         reticulate_1.15    digest_0.6.25     
[17] RColorBrewer_1.1-2 colorspace_1.4-1   cowplot_1.0.0      htmltools_0.4.0   
[21] Matrix_1.2-18      plyr_1.8.6         pkgconfig_2.0.3    tsne_0.1-3        
[25] listenv_0.8.0      purrr_0.3.4        patchwork_1.0.0    scales_1.1.1      
[29] RANN_2.6.1         Rtsne_0.15         tibble_3.0.1       ggplot2_3.3.0     
[33] ellipsis_0.3.1     withr_2.2.0        ROCR_1.0-11        pbapply_1.4-2     
[37] lazyeval_0.2.2     cli_2.0.2          survival_3.1-8     magrittr_1.5      
[41] crayon_1.3.4       future_1.17.0      fansi_0.4.1        nlme_3.1-143      
[45] MASS_7.3-51.4      ica_1.0-2          tools_3.6.1        fitdistrplus_1.1-1
[49] data.table_1.12.8  lifecycle_0.2.0    stringr_1.4.0      plotly_4.9.2.1    
[53] munsell_0.5.0      cluster_2.1.0      irlba_2.3.3        compiler_3.6.1    
[57] rsvd_1.0.3         rlang_0.4.6        grid_3.6.1         ggridges_0.5.2    
[61] rstudioapi_0.11    RcppAnnoy_0.0.16   rappdirs_0.3.1     htmlwidgets_1.5.1 
[65] igraph_1.2.5       Seurat_3.1.5       gtable_0.3.0       codetools_0.2-16  
[69] reshape2_1.4.4     R6_2.4.1           gridExtra_2.3      zoo_1.8-8         
[73] dplyr_0.8.5        bit_1.1-15.2       uwot_0.1.8         future.apply_1.5.0
[77] KernSmooth_2.23-16 ape_5.3            stringi_1.4.6      parallel_3.6.1    
[81] Rcpp_1.0.4         vctrs_0.3.0        sctransform_0.2.1  png_0.1-7         
[85] tidyselect_1.1.0   lmtest_0.9-37  

Error saving as.loom

Good day,

I am having problems saving objects as.loom. I tried to install loom branch as suggested here (satijalab/seurat#3869), but did not work (got the same error mention there).

My sessionInfo

R version 4.0.3 (2020-10-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /hpc/pmc_stunnenberg/cruiz/miniconda3/envs/r_env_4.0.3/lib/libopenblasp-r0.3.10.so

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       

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

other attached packages:
 [1] SeuratDisk_0.0.0.9018 loomR_0.2.1.9000      hdf5r_1.3.3          
 [4] R6_2.5.0              future_1.21.0         SeuratWrappers_0.3.0 
 [7] ggplot2_3.3.3.9000    cowplot_1.1.1         dplyr_1.0.4          
[10] SeuratObject_4.0.0    Seurat_4.0.0.9005    

loaded via a namespace (and not attached):
  [1] uuid_0.1-4                  plyr_1.8.6                 
  [3] igraph_1.2.6                repr_1.1.0                 
  [5] lazyeval_0.2.2              splines_4.0.3              
  [7] BiocParallel_1.24.1         listenv_0.8.0              
  [9] scattermore_0.7             GenomeInfoDb_1.26.2        
 [11] digest_0.6.27               htmltools_0.5.1.1          
 [13] magrittr_2.0.1              tensor_1.5                 
 [15] cluster_2.1.0               ROCR_1.0-11                
 [17] limma_3.46.0                remotes_2.2.0              
 [19] globals_0.14.0              matrixStats_0.58.0         
 [21] prettyunits_1.1.1           colorspace_2.0-0           
 [23] ggrepel_0.9.1               callr_3.5.1                
 [25] crayon_1.4.1                RCurl_1.98-1.2             
 [27] jsonlite_1.7.2              spatstat_1.64-1            
 [29] spatstat.data_2.0-0         survival_3.2-7             
 [31] zoo_1.8-8                   glue_1.4.2                 
 [33] polyclip_1.10-0             gtable_0.3.0               
 [35] zlibbioc_1.36.0             XVector_0.30.0             
 [37] leiden_0.3.7                DelayedArray_0.16.0        
 [39] pkgbuild_1.2.0              BiocSingular_1.6.0         
 [41] future.apply_1.7.0          SingleCellExperiment_1.12.0
 [43] BiocGenerics_0.36.0         abind_1.4-5                
 [45] scales_1.1.1                DBI_1.1.0                  
 [47] miniUI_0.1.1.1              Rcpp_1.0.6                 
 [49] viridisLite_0.3.0           xtable_1.8-4               
 [51] reticulate_1.18             bit_4.0.4                  
 [53] rsvd_1.0.3                  stats4_4.0.3               
 [55] ResidualMatrix_1.0.0        htmlwidgets_1.5.3          
 [57] httr_1.4.2                  RColorBrewer_1.1-2         
 [59] ellipsis_0.3.1              ica_1.0-2                  
 [61] scuttle_1.0.3               pkgconfig_2.0.3            
 [63] farver_2.0.3                uwot_0.1.10                
 [65] deldir_0.2-10               tidyselect_1.1.0           
 [67] labeling_0.4.2              rlang_0.4.10               
 [69] reshape2_1.4.4              later_1.1.0.1              
 [71] munsell_0.5.0               tools_4.0.3                
 [73] cli_2.3.0                   generics_0.1.0             
 [75] ggridges_0.5.3              batchelor_1.6.2            
 [77] evaluate_0.14               stringr_1.4.0              
 [79] fastmap_1.1.0               goftest_1.2-2              
 [81] processx_3.4.5              bit64_4.0.5                
 [83] fitdistrplus_1.1-3          purrr_0.3.4                
 [85] RANN_2.6.1                  pbapply_1.4-3              
 [87] nlme_3.1-150                sparseMatrixStats_1.2.0    
 [89] mime_0.10                   compiler_4.0.3             
 [91] curl_4.3                    plotly_4.9.3               
 [93] png_0.1-7                   spatstat.utils_2.0-0       
 [95] tibble_3.0.6                stringi_1.5.3              
 [97] ps_1.5.0                    RSpectra_0.16-0            
 [99] lattice_0.20-41             IRdisplay_0.7.0            
[101] Matrix_1.2-18               vctrs_0.3.6                
[103] pillar_1.4.7                lifecycle_1.0.0            
[105] BiocManager_1.30.10         lmtest_0.9-38              
[107] RcppAnnoy_0.0.18            BiocNeighbors_1.8.2        
[109] data.table_1.13.6           bitops_1.0-6               
[111] irlba_2.3.3                 httpuv_1.5.5               
[113] patchwork_1.1.1             GenomicRanges_1.42.0       
[115] promises_1.2.0.1            KernSmooth_2.23-18         
[117] gridExtra_2.3               IRanges_2.24.1             
[119] parallelly_1.23.0           codetools_0.2-18           
[121] MASS_7.3-53                 assertthat_0.2.1           
[123] SummarizedExperiment_1.20.0 rprojroot_2.0.2            
[125] withr_2.4.1                 sctransform_0.3.2.9003     
[127] S4Vectors_0.28.1            GenomeInfoDbData_1.2.4     
[129] mgcv_1.8-33                 parallel_4.0.3             
[131] grid_4.0.3                  rpart_4.1-15               
[133] beachmat_2.6.4              IRkernel_1.1.1             
[135] tidyr_1.1.2                 DelayedMatrixStats_1.12.1  
[137] MatrixGenerics_1.2.0        Cairo_1.5-12.2             
[139] Rtsne_0.15                  pbdZMQ_0.3-3.1             
[141] Biobase_2.50.0              shiny_1.6.0                
[143] base64enc_0.1-3            

Thanks!

Error loading .h5ad file to Scvelo

Hi,

I converted a seurat obj to a h5ad format successfully and tried to load it into ScVelo as follows:

adata=scv.read("~/Desktop/pbmc10k.h5ad")

and got a following error.

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py in func_wrapper(elem, *args, **kwargs)
    155         try:
--> 156             return func(elem, *args, **kwargs)
    157         except Exception as e:

/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py in read_dataframe(group)
    483     columns = list(group.attrs["column-order"])
--> 484     idx_key = group.attrs["_index"]
    485     df = pd.DataFrame(

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

/usr/local/lib/python3.8/site-packages/h5py/_hl/attrs.py in __getitem__(self, name)
     55         """
---> 56         attr = h5a.open(self._id, self._e(name))
     57 

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5a.pyx in h5py.h5a.open()

KeyError: "Can't open attribute (can't locate attribute: '_index')"

During handling of the above exception, another exception occurred:

AnnDataReadError                          Traceback (most recent call last)
<ipython-input-7-f2696a3315c6> in <module>
----> 1 adata=scv.read("/Users/akihikohohji/Desktop/pbmc10k.h5ad")

/usr/local/lib/python3.8/site-packages/scanpy/readwrite.py in read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, **kwargs)
    110     filename = Path(filename)  # allow passing strings
    111     if is_valid_filename(filename):
--> 112         return _read(
    113             filename,
    114             backed=backed,

/usr/local/lib/python3.8/site-packages/scanpy/readwrite.py in _read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, suppress_cache_warning, **kwargs)
    711     if ext in {'h5', 'h5ad'}:
    712         if sheet is None:
--> 713             return read_h5ad(filename, backed=backed)
    714         else:
    715             logg.debug(f'reading sheet {sheet} from file {filename}')

/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py in read_h5ad(filename, backed, as_sparse, as_sparse_fmt, chunk_size)
    426                 d[k] = read_attribute(f[k])
    427 
--> 428         d["raw"] = _read_raw(f, as_sparse, rdasp)
    429 
    430         X_dset = f.get("X", None)

/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py in _read_raw(f, as_sparse, rdasp, attrs)
    458     for v in ("var", "varm"):
    459         if v in attrs and f"raw/{v}" in f:
--> 460             raw[v] = read_attribute(f[f"raw/{v}"])
    461     return _read_legacy_raw(f, raw, read_dataframe, read_attribute, attrs=attrs)
    462 

/usr/local/Cellar/[email protected]/3.8.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py in func_wrapper(elem, *args, **kwargs)
    157         except Exception as e:
    158             if isinstance(e, AnnDataReadError):
--> 159                 raise e
    160             else:
    161                 parent = _get_parent(elem)

/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py in func_wrapper(elem, *args, **kwargs)
    154     def func_wrapper(elem, *args, **kwargs):
    155         try:
--> 156             return func(elem, *args, **kwargs)
    157         except Exception as e:
    158             if isinstance(e, AnnDataReadError):

/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py in read_group(group)
    536         pass
    537     elif encoding_type == "dataframe":
--> 538         return read_dataframe(group)
    539     elif encoding_type in {"csr_matrix", "csc_matrix"}:
    540         return SparseDataset(group).to_memory()

/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py in func_wrapper(elem, *args, **kwargs)
    160             else:
    161                 parent = _get_parent(elem)
--> 162                 raise AnnDataReadError(
    163                     f"Above error raised while reading key {elem.name!r} of "
    164                     f"type {type(elem)} from {parent}."

AnnDataReadError: Above error raised while reading key '/raw/var' of type <class 'h5py._hl.group.Group'> from /.

This could be an issue with ScVelo but I'd really appreciate any help on fixing this.

package.version("Seurat")
[1] "4.0.0"

package.version("SeuratDisk")
[1] "0.0.0.9018"

scv.logging.print_versions()
scvelo==0.2.3  scanpy==1.7.0  anndata==0.7.5  loompy==3.0.6  numpy==1.20.1  scipy==1.6.1  matplotlib==3.3.4  sklearn==0.24.1  pandas==1.2.2  

Conversion from Seurat to AnnData changes metadata column

Hi!

In Seurat I have a metadata column (merged object) that holds 30 different cell types with a combination of "real" strings ("Neuron") and "integer" strings ("0") . When I Convert to AnnData, that column holds integers from 0-29.
I can perform a work-around to create a cell type column after conversion, but it's kind of annoying.

Metadata column in Seurat:

> levels([email protected]$orig.celltype)
[1] "0"                   "1"                   "10"                  "11"                  "12"                  "13"                  "2"                  
 [8] "3"                   "4"                   "5"                   "6"                   "7"                   "8"                   "9"                  
[15] "Neuron4"        "Astro1"           "Astro2"       "Ependy"       "MGlia2"                "Neuron1"                "NPC"               
[22] "PC1"                "Olf"                "Oligo"                "OPC"      "PC2"                "Neuron5"                "Neuron3"               
[29] "MGlia1"                "Neuron2" 

Conversion to .h5ad:

SeuratDisk::SaveH5Seurat(object, filename = "path/to/file.h5Seurat")
SeuratDisk::Convert("path/to/file.h5Seurat", dest="h5ad")

Metadata column in Scanpy:

adata = sc.read_h5ad("path/to/file.h5ad")
set(adata.obs["orig.celltype"])
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29}

Scanpy: scanpy==1.4.6 anndata==0.7.1 umap==0.3.10 numpy==1.18.1 scipy==1.4.1 pandas==1.0.1 scikit-learn==0.22.1 statsmodels==0.11.1 python-igraph==0.8.0 louvain==0.6.1
Seurat: SeuratDisk_0.0.0.9013 Seurat_3.2.1

File size differences of AnnData .h5ad

Dear Paul,
I found SeuratDisk very useful, thank you for implementing it!
I converted .h5ad file (~23G) to h5seurat(~28G) to work in Seurat. Then I saved it as h5seurat (becomes ~5G) and converted to .h5ad(~3.7G) and loaded it to Scanpy.
questions:

  • the file size of converted .h5ad is small (~3.7G), if I load it to Scanpy and safe it as .h5ad it becomes larger (~44g). Any ideas why? Probably the way Scanpy write the anndata?
  • also if @metadata in Seurat object has factors, numeric, etc.. they are all transformed to integers once loaded to Scanpy as .h5ad. Any reason for that?
    Many Thanks
    Alik

Keep same datatypes when converting from seurat to anndata

I noticed that when you convert your seurat object with seuratdisk all your category variables such as your seurat_clusters will become integers (int32) in your anndata object. This is quite problematic when opening this directly with cellxgene because this obs data will be put into the continuous metadata and not the categorical metadata. Is there a way to keep the datatypes as they are? Sceasy for example does this. Check included html file.[
SeuratDisk and sceasy comparison.html.zip
](url)

SaveH5Seurat failing on example mouse bone marrow dataset

Hey! This issue is linked with the scVelo tutorial which uses seurat-disk.

I used the exact code form the tutorial and came across this error:

> SaveH5Seurat(bm, filename = "mouseBM.h5Seurat")
Creating h5Seurat file for version 3.1.5.9900
Error in attr$write(robj) : HDF5-API Errors:
    error #000: H5A.c in H5Awrite(): line 676: buf parameter can't be NULL
        class: HDF5
        major: Invalid arguments to routine
        minor: Bad value

Thanks in advance for any assistance!

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

other attached packages:
[1] SeuratWrappers_0.3.0  SeuratDisk_0.0.0.9015 Seurat_3.2.3         

loaded via a namespace (and not attached):
  [1] Rtsne_0.15            colorspace_1.4-1      deldir_0.1-29         ellipsis_0.3.1        ggridges_0.5.2       
  [6] rstudioapi_0.11       spatstat.data_1.4-3   leiden_0.3.3          listenv_0.8.0         remotes_2.2.0        
 [11] ggrepel_0.8.2         bit64_4.0.5           RSpectra_0.16-0       fansi_0.4.1           codetools_0.2-16     
 [16] splines_4.0.3         polyclip_1.10-0       jsonlite_1.7.1        ica_1.0-2             cluster_2.1.0        
 [21] png_0.1-7             uwot_0.1.10           shiny_1.5.0           sctransform_0.3.1     BiocManager_1.30.10  
 [26] compiler_4.0.3        httr_1.4.2            assertthat_0.2.1      SeuratObject_4.0.0    Matrix_1.2-18        
 [31] fastmap_1.0.1         lazyeval_0.2.2        cli_2.1.0             later_1.1.0.1         htmltools_0.5.1.1    
 [36] prettyunits_1.1.1     tools_4.0.3           rsvd_1.0.3            igraph_1.2.6          gtable_0.3.0         
 [41] glue_1.4.2            RANN_2.6.1            reshape2_1.4.4        dplyr_1.0.2           rappdirs_0.3.1       
 [46] tinytex_0.26          Rcpp_1.0.6            spatstat_1.64-1       Biobase_2.50.0        scattermore_0.7      
 [51] cellranger_1.1.0      vctrs_0.3.4           nlme_3.1-149          lmtest_0.9-38         xfun_0.18            
 [56] stringr_1.4.0         globals_0.13.1        ps_1.4.0              mime_0.9              miniUI_0.1.1.1       
 [61] lifecycle_0.2.0       irlba_2.3.3           goftest_1.2-2         future_1.19.1         MASS_7.3-53          
 [66] zoo_1.8-8             scales_1.1.1          pcaMethods_1.80.0     promises_1.1.1        spatstat.utils_1.17-0
 [71] parallel_4.0.3        RColorBrewer_1.1-2    reticulate_1.18       pbapply_1.4-3         gridExtra_2.3        
 [76] ggplot2_3.3.2         rpart_4.1-15          stringi_1.5.3         velocyto.R_0.6        BiocGenerics_0.36.0  
 [81] pkgbuild_1.1.0        rlang_0.4.10          pkgconfig_2.0.3       matrixStats_0.57.0    lattice_0.20-41      
 [86] ROCR_1.0-11           purrr_0.3.4           tensor_1.5            patchwork_1.0.1       htmlwidgets_1.5.2    
 [91] cowplot_1.1.0         bit_4.0.4             processx_3.4.4        tidyselect_1.1.0      RcppAnnoy_0.0.18     
 [96] plyr_1.8.6            magrittr_2.0.1        R6_2.5.0              generics_0.1.0        DBI_1.1.0            
[101] pillar_1.4.6          withr_2.3.0           mgcv_1.8-33           fitdistrplus_1.1-1    survival_3.2-7       
[106] abind_1.4-5           tibble_3.0.4          future.apply_1.6.0    crayon_1.3.4          hdf5r_1.3.3          
[111] KernSmooth_2.23-17    plotly_4.9.2.1        grid_4.0.3            readxl_1.3.1          data.table_1.13.2    
[116] callr_3.5.1           digest_0.6.27         xtable_1.8-4          tidyr_1.1.2           httpuv_1.5.4         
[121] munsell_0.5.0         viridisLite_0.3.0    

object ‘markvario’ is not exported by 'namespace:spatstat'

Hello, I report an install bug here. I installed the latest version of 'spatsat' released at 2021-03-13, and when I try to install the seurat-dist ,I got the error report:

object ‘markvario’ is not exported by 'namespace:spatstat'

So, I installed the older version of spatsat-1.64-1, and problem solved.

I think the seurat-dist may be not compatible with the latest spatsat and need some update. Thank you for your amazing job.

Errors when converting HCA h5ad file into h5seurat file

Hi! I met this error when I try to convert a h5ad file in 1.6G size to h5seurat. It seems something wrong with hdf5. But when I used the same code to convert a smaller h5ad file, this error did not appear. I also checked the RAM and the storage space on the disk, they are far from exhausted.

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

Adding X as data

Adding X as counts

Adding meta.features from var

Adding X_pca as cell embeddings for pca

Error in self$write_low_level(value, file_space = self_space_id, mem_space = mem_space_id, : HDF5-API Errors:
    error #000: H5Dio.c in H5Dwrite(): line 336: can't write data
        class: HDF5
        major: Dataset
        minor: Write failed

    error #001: H5Dio.c in H5D__write(): line 828: can't write data
        class: HDF5
        major: Dataset
        minor: Write failed

    error #002: H5Dchunk.c in H5D__chunk_write(): line 2363: unable to read raw data chunk
        class: HDF5
        major: Low-level I/O
        minor: Read failed

    error #003: H5Dchunk.c in H5D__chunk_lock(): line 3686: unable to preempt chunk(s) from cache
        class: HDF5
        major: Low-level I/O
        minor: Unable to initialize object

    error #004: H5Dchunk.c in H5D__chunk_cache_prune(): line 3352: unable to preempt one or more raw data cache entry
        class: HDF5
        major: Low-level I/O
        minor: Unable to flush data from cache

    error #005: H5Dchunk.c in H5D__chunk_cache_evict(): line 3203: cannot flush indexed storage buffer
        class: HDF5
       
Traceback:

1. Convert(paste0(path, "vascular", ".h5ad"), dest = "h5seurat", 
 .     overwrite = TRUE)
2. Convert.character(paste0(path, "vascular", ".h5ad"), dest = "h5seurat", 
 .     overwrite = TRUE)
3. Convert(source = hfile, dest = dest, assay = assay, overwrite = overwrite, 
 .     verbose = verbose, ...)
4. Convert.H5File(source = hfile, dest = dest, assay = assay, overwrite = overwrite, 
 .     verbose = verbose, ...)
5. H5ADToH5Seurat(source = source, dest = dest, assay = assay, overwrite = overwrite, 
 .     verbose = verbose)
6. Transpose(x = source[["obsm"]][[reduc]], dest = reduc.group, 
 .     dname = "cell.embeddings", verbose = FALSE)
7. Transpose.H5D(x = source[["obsm"]][[reduc]], dest = reduc.group, 
 .     dname = "cell.embeddings", verbose = FALSE)
8. tmtx$write(args = dims, value = t(x = x$read(args = rev(x = dims))))
9. self$write_low_level(value, file_space = self_space_id, mem_space = mem_space_id, 
 .     dataset_xfer_pl = dataset_xfer_pl)

Sometimes it would also show the error of failed to closed the file in hdf5 or just kill the R kernel.

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

Adding X as data

Adding X as counts

Adding meta.features from var

Adding X_pca as cell embeddings for pca

Adding X_umap as cell embeddings for umap

Error in H5_close_any(self$id): HDF5-API Errors:
    error #000: H5F.c in H5Fclose(): line 668: closing file ID failed
        class: HDF5
        major: File accessibilty
        minor: Unable to close file

    error #001: H5Fint.c in H5F__close(): line 2047: decrementing file ID failed
        class: HDF5
        major: File accessibilty
        minor: Unable to decrement reference count

    error #002: H5I.c in H5I_dec_app_ref(): line 1309: can't decrement ID ref count
        class: HDF5
        major: Object atom
        minor: Unable to decrement reference count

    error #003: H5Fint.c in H5F__close_cb(): line 2105: can't close file
        class: HDF5
        major: File accessibilty
        minor: Unable to close file

    error #004: H5Fint.c in H5F_try_close(): line 2276: problems closing file
        class: HDF5
        major: File accessibilty
        minor: Unable to close file

    error #005: H5Fint.c in H5F__dest(): line 1299: unable to close file
        class: HDF5
        major: File accessibi
Traceback:

1. Convert(paste0(path, "ventricular", ".h5ad"), dest = "h5seurat", 
 .     overwrite = TRUE)
2. Convert.character(paste0(path, "ventricular", ".h5ad"), dest = "h5seurat", 
 .     overwrite = TRUE)
3. dfile$close_all()
4. H5_close_any(self$id)

The environment is CentOS Linux release 7.6.1810 (Core), 128G RAM, R version 3.6.1, Seurat 3.2.2, SeuratDisk 0.0.0.9013

Error when saving h5seurat

Good day,

I am having issues saving a Seurat object with SaveH5Seurat. Do not know what the problem can be.

Creating h5Seurat file for version 3.1.5.9900

Adding counts for RNA

Adding data for RNA

No variable features found for RNA

No feature-level metadata found for RNA

Adding counts for SCT

Adding data for SCT

Adding scale.data for SCT

No variable features found for SCT

No feature-level metadata found for SCT

Adding data for integrated

Adding scale.data for integrated

Adding variable features for integrated

No feature-level metadata found for integrated

Adding cell embeddings for pca

Adding loadings for pca

No projected loadings for pca

Adding standard deviations for pca

No JackStraw data for pca

Adding cell embeddings for umap

No loadings for umap

No projected loadings for umap

No standard deviations for umap

No JackStraw data for umap

Error in guess_dtype(x = x, ...): unknown type
Traceback:

1. 1
2. 2
3. 3
4. 4
5. 5
6. 5
7. 7
8. 7
9. 9
10. ⋯
11. 9
12. 13
13. 13
14. 15
15. 16
16. 17
17. 18
18. 19

Any ideas on how to solve this issue? thanks in advance

Error when saving H5Seurat

Thanks for this great tool. I was attempting to save a large dataset and came across an error right at the end of saving

`
Creating h5Seurat file for version 3.1.5.9900
Adding counts for RNA
Adding data for RNA
No variable features found for RNA
No feature-level metadata found for RNA
Adding counts for hto
Adding data for hto
No variable features found for hto
No feature-level metadata found for hto
Adding counts for spliced
Adding data for spliced
No variable features found for spliced
No feature-level metadata found for spliced
Adding counts for unspliced
Adding data for unspliced
No variable features found for unspliced
No feature-level metadata found for unspliced
Adding counts for SCT
Adding data for SCT
Adding scale.data for SCT
Adding variable features for SCT
Adding feature-level metadata for SCT

Error in xgroup$create_attr(attr_name = "names", robj = intersect(x = names(x = x), :
HDF5-API Errors:
error #000: /home/hdftest/snapshots-hdf5_1_10_5/current/src/H5A.c in H5Acreate2(): line 279: unable to create attribute
class: HDF5
major: Attribute
minor: Unable to initialize object

error #001: /home/hdftest/snapshots-hdf5_1_10_5/current/src/H5Aint.c in H5A__create(): line 275: unable to create attribute in object header
    class: HDF5
    major: Attribute
    minor: Unable to insert object

error #002: /home/hdftest/snapshots-hdf5_1_10_5/current/src/H5Oattribute.c in H5O__attr_create(): line 335: unable to create new attribute in header
    class: HDF5
    major: Attribute
    minor: Unable to insert object

error #003: /home/hdftest/snapshots-hdf5_1_10_5/current/src/H5Omessage.c in H5O__msg_append_real(): line 222: unable to create new message
    class: HDF5
    major: Object header
    minor: No space available for allocation

error #004: /home/hdftest/snapshots-hdf5_1_10_

`

Do you have any suggestions on dealing with this?

my session info is below

`
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Storage

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.3.so

locale:
[1] LC_CTYPE=en_DK.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_DK.UTF-8 LC_COLLATE=en_DK.UTF-8
[5] LC_MONETARY=en_DK.UTF-8 LC_MESSAGES=en_DK.UTF-8
[7] LC_PAPER=en_DK.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_DK.UTF-8 LC_IDENTIFICATION=C

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

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

loaded via a namespace (and not attached):
[1] nlme_3.1-148 bit64_0.9-7.1 filelock_1.0.2
[4] RcppAnnoy_0.0.16 RColorBrewer_1.1-2 progress_1.2.2
[7] httr_1.4.2 sctransform_0.2.1 tools_4.0.2
[10] backports_1.1.8 R6_2.4.1 irlba_2.3.3
[13] rpart_4.1-15 KernSmooth_2.23-17 uwot_0.1.8
[16] mgcv_1.8-31 lazyeval_0.2.2 colorspace_1.4-1
[19] withr_2.2.0 gridExtra_2.3 tidyselect_1.1.0
[22] prettyunits_1.1.1 bit_1.1-15.2 compiler_4.0.2
[25] cli_2.0.2 hdf5r_1.3.2 plotly_4.9.2.1
[28] stringfish_0.13.3 scales_1.1.1 spatstat.data_1.4-3
[31] lmtest_0.9-37 ggridges_0.5.2 pbapply_1.4-2
[34] goftest_1.2-2 spatstat_1.64-1 stringr_1.4.0
[37] digest_0.6.25 spatstat.utils_1.17-0 txtq_0.2.3
[40] pkgconfig_2.0.3 htmltools_0.5.0 fastmap_1.0.1
[43] htmlwidgets_1.5.1 rlang_0.4.7 shiny_1.5.0
[46] generics_0.0.2 RApiSerialize_0.1.0 zoo_1.8-8
[49] drake_7.12.4 jsonlite_1.7.0 ica_1.0-2
[52] dplyr_1.0.0 magrittr_1.5 patchwork_1.0.1
[55] Matrix_1.2-18 Rcpp_1.0.5 munsell_0.5.0
[58] fansi_0.4.1 abind_1.4-5 ape_5.4
[61] reticulate_1.16 lifecycle_0.2.0 stringi_1.4.6
[64] MASS_7.3-51.6 storr_1.2.1 Rtsne_0.15
[67] plyr_1.8.6 grid_4.0.2 parallel_4.0.2
[70] listenv_0.8.0 promises_1.1.1 ggrepel_0.8.2
[73] crayon_1.3.4 deldir_0.1-28 miniUI_0.1.1.1
[76] lattice_0.20-41 cowplot_1.0.0 splines_4.0.2
[79] tensor_1.5 hms_0.5.3 pillar_1.4.6
[82] igraph_1.2.5 base64url_1.4 future.apply_1.6.0
[85] reshape2_1.4.4 codetools_0.2-16 leiden_0.3.3
[88] glue_1.4.1 data.table_1.13.0 vctrs_0.3.2
[91] png_0.1-7 httpuv_1.5.4 polyclip_1.10-0
[94] gtable_0.3.0 RANN_2.6.1 purrr_0.3.4
[97] tidyr_1.1.0 qs_0.23.2 future_1.18.0
[100] assertthat_0.2.1 ggplot2_3.3.2 rsvd_1.0.3
[103] mime_0.9 xtable_1.8-4 later_1.1.0.1
[106] survival_3.1-12 viridisLite_0.3.0 tibble_3.0.3
[109] cluster_2.1.0 globals_0.12.5 fitdistrplus_1.1-1
[112] ellipsis_0.3.1 ROCR_1.0-11
`

Save SaveH5Seurat() -Error: Invalid version specification: 3.1.5.999

Hello,

Thank you for creating this package. However I appear to have problems creating H5Seurat file due to invalid version specification error? I tried updating seurat object to see if that would help but the error persists. Could you please give me some clues as to how to fix this?

Cheers,
Lucy

> SaveH5Seurat(MFTatlas, overwrite = TRUE)
Creating h5Seurat file for version 3.1.5.9900
Error: Invalid version specification: 3.1.5.999
> MFTatlas <- UpdateSeuratObject(MFTatlas)
Validating object structure
Updating object slots
Ensuring keys are in the proper strucutre
Ensuring feature names don't have underscores or pipes
Object representation is consistent with the most current Seurat version
> SaveH5Seurat(MFTatlas, overwrite = TRUE)
Creating h5Seurat file for version 3.1.5.9900
Error: Invalid version specification: 3.1.5.999

Error in LoadH5Seurat: invalid dimnames given for “dgCMatrix” object

Hello,

I am trying to load an h5Ad file from scanpy v 1.4.6 to Seurat using Seurat disk. I did the following steps:

  1. Convert scanpy to seurat
Convert(
    source=scanpy_src,
    dest="h5Seurat",
    overwrite=TRUE,
    verbose=TRUE
)

This created the following messages:

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

Adding X as data

Adding raw/X as counts

Adding meta.features from raw/var

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

Warning message:
“Cannot find features for feature loadings, will not be able to load”
Adding miscellaneous information for pca

Adding standard deviations for pca

Adding miscellaneous information for umap

Saving nearest-neighbor graph as RNA_umap

Adding Biological Sample_colors to miscellaneous data

Adding colorme_colors to miscellaneous data

Adding dendrogram_leiden to miscellaneous data

Adding leiden to miscellaneous data

Adding leiden_colors to miscellaneous data
  1. Once the h5Seurat file was created I tried to load into Seurat but got an error
s_obj = LoadH5Seurat(h5Seurat)

The following traceback:

**Error in dimnamesGets(x, value): invalid dimnames given for “dgCMatrix” object
Traceback:**

LoadH5Seurat("../work/data_out/final_RSM_data_05132020/NSCLCCellAnnotatedBatchBBKNNSettingsV2AndClustered.h5seurat", 
 .     assays = list(RNA = c("data", "counts"))) LoadH5Seurat.character("../work/data_out/final_RSM_data_05132020/NSCLCCellAnnotatedBatchBBKNNSettingsV2AndClustered.h5seurat", 
 .     assays = list(RNA = c("data", "counts")))
 LoadH5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, images = images, meta.data = meta.data, 
 .     commands = commands, misc = misc, tools = tools, verbose = verbose, 
 .     ...)
 LoadH5Seurat.h5Seurat(file = hfile, assays = assays, reductions = reductions, 
 .     graphs = graphs, images = images, meta.data = meta.data, 
 .     commands = commands, misc = misc, tools = tools, verbose = verbose, 
 .     ...)
 as.Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, images = images, meta.data = meta.data, 
 .     commands = commands, misc = misc, tools = tools, verbose = verbose, 
 .     ...)
 as.Seurat.h5Seurat(x = file, assays = assays, reductions = reductions, 
 .     graphs = graphs, images = images, meta.data = meta.data, 
 .     commands = commands, misc = misc, tools = tools, verbose = verbose, 
 .     ...)
AssembleAssay(assay = assay, file = x, slots = assays[[assay]], 
 .     verbose = verbose)
`rownames<-`(x = `*tmp*`, value = features)
 `dimnames<-`(`*tmp*`, value = dn)
`dimnames<-`(`*tmp*`, value = dn)
 dimnamesGets(x, value)
 stop(gettextf("invalid dimnames given for %s object", dQuote(class(x))), 
  .     domain = NA)
  1. Session Info
R version 3.6.3 (2020-02-29)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS/LAPACK: /opt/conda/lib/libopenblasp-r0.3.7.so

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       

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

other attached packages:
[1] SeuratDisk_0.0.0.9008 Seurat_3.1.5         

loaded via a namespace (and not attached):
 [1] nlme_3.1-147       tsne_0.1-3         bit64_0.9-7        RcppAnnoy_0.0.16  
 [5] RColorBrewer_1.1-2 httr_1.4.1         repr_1.1.0         sctransform_0.2.1 
 [9] tools_3.6.3        R6_2.4.1           irlba_2.3.3        KernSmooth_2.23-16
[13] uwot_0.1.8         lazyeval_0.2.2     colorspace_1.4-1   withr_2.2.0       
[17] tidyselect_1.1.0   gridExtra_2.3      bit_1.1-15.2       compiler_3.6.3    
[21] cli_2.0.2          hdf5r_1.3.2        plotly_4.9.2.1     scales_1.1.1      
[25] lmtest_0.9-37      ggridges_0.5.2     pbapply_1.4-2      rappdirs_0.3.1    
[29] pbdZMQ_0.3-3       stringr_1.4.0      digest_0.6.25      base64enc_0.1-3   
[33] pkgconfig_2.0.3    htmltools_0.4.0    htmlwidgets_1.5.1  rlang_0.4.6       
[37] zoo_1.8-8          jsonlite_1.6.1     ica_1.0-2          dplyr_0.8.5       
[41] magrittr_1.5       patchwork_1.0.0    Matrix_1.2-18      Rcpp_1.0.4.6      
[45] IRkernel_1.1       munsell_0.5.0      fansi_0.4.1        ape_5.3           
[49] reticulate_1.15    lifecycle_0.2.0    stringi_1.4.6      MASS_7.3-51.5     
[53] Rtsne_0.15         plyr_1.8.6         grid_3.6.3         parallel_3.6.3    
[57] listenv_0.8.0      ggrepel_0.8.2      crayon_1.3.4       lattice_0.20-41   
[61] IRdisplay_0.7.0    cowplot_1.0.0      splines_3.6.3      pillar_1.4.4      
[65] igraph_1.2.5       uuid_0.1-4         future.apply_1.5.0 reshape2_1.4.4    
[69] codetools_0.2-16   leiden_0.3.3       glue_1.4.1         evaluate_0.14     
[73] data.table_1.12.8  png_0.1-7          vctrs_0.3.0        gtable_0.3.0      
[77] RANN_2.6.1         purrr_0.3.4        tidyr_1.1.0        future_1.17.0     
[81] assertthat_0.2.1   ggplot2_3.3.0      rsvd_1.0.3         survival_3.1-12   
[85] viridisLite_0.3.0  tibble_3.0.1       cluster_2.1.0      globals_0.12.5    
[89] fitdistrplus_1.1-1 ellipsis_0.3.1     ROCR_1.0-11       

Thanks so much for any help!

HDF5 errors on `h5$copy_obj_to(...)` calls

Hello @mojaveazure

Thanks for your work in creating this package, I believe it is very valuable to be able to store seurat objects as h5 files, as well as convert between h5seurat and h5ad.

I'm encountering a strange issue which occurs some of the times. I attached my input files, scripts and output as a zip file:
seurat_disk_issue_with_hdf5r.zip

When using SeuratDisk to convert input1.h5ad and input2.h5ad (in that order) to h5seurat, everything works fine (see script1.R). When the order is reversed, I get an error because it was not able to copy meta.data/_index to cell.names (see script2.R). The error occurs at Convert.R#L566-L570.

script1.R
library(SeuratDisk)

converted <- Convert("input1.h5ad", dest = "output1.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Adding X_pca as cell embeddings for pca
# 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
# Saving nearest-neighbor graph as RNA_umap
# Adding filteringParameters to miscellaneous data
# Adding hvgParameters to miscellaneous data
# Adding nearestNeighbourParameters to miscellaneous data
# Adding normalizationParameters to miscellaneous data
# Adding pcaParameters to miscellaneous data


converted <- Convert("input2.h5ad", dest = "output2.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Adding filteringParameters to miscellaneous data
script2.R
library(SeuratDisk)

converted <- Convert("input2.h5ad", dest = "output2.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Adding filteringParameters to miscellaneous data
# Error in dfile[["misc"]]$obj_copy_from(src_loc = source[["uns"]], src_name = i,  : 
#   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 314: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #002: ../../src/H5Ocopy.c in H5O__copy_obj(): line 1218: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #003: ../../src/H5Ocopy.c in H5O__copy_header(): line 1162: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #004: ../../src/H5Ocopy.c in H5O__copy_header_real(): line 869: unable to perform 'post copy' operation on message
#         class: HDF5
#         major: Object header
#         minor: Unable to initialize object
#
#     error #005: ../../src/H5Ostab.c in H5O__stab_post_copy_f
# Error in private$closeFun(id) : HDF5-API Errors:
#     error #000: ../../src/H5F.c in H5Fclose(): line 675: closing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #001: ../../src/H5Fint.c in H5F__close(): line 1952: decrementing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to decrement reference count
#
#     error #002: ../../src/H5I.c in H5I_dec_app_ref(): line 1300: can't decrement ID ref count
#         class: HDF5
#         major: Object atom
#         minor: Unable to decrement reference count
#
#     error #003: ../../src/H5Fint.c in H5F__close_cb(): line 2010: can't close file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #004: ../../src/H5Fint.c in H5F_try_close(): line 2181: problems closing file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #005: ../../src/H5Fint.c in H5F__dest(): line 1277: p

converted <- Convert("input1.h5ad", dest = "output1.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Error in dfile$obj_copy_from(src_loc = dfile, src_name = paste0("meta.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 314: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object

#     error #002: ../../src/H5Ocopy.c in H5O__copy_obj(): line 1218: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
# 
#     error #003: ../../src/H5Ocopy.c in H5O__copy_header(): line 1162: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
# 
#     error #004: ../../src/H5Ocopy.c in H5O__copy_header_real(): line 887: unable to re-tag metadata entries
#         class: HDF5
#         major: Object cache
#         minor: Unable to tag metadata in the cache
# 
#     error #005: ../../src/H5AC.c in H5AC_retag_copied_metadata(): line
# Error in private$closeFun(id) : HDF5-API Errors:
#     error #000: ../../src/H5F.c in H5Fclose(): line 675: closing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #001: ../../src/H5Fint.c in H5F__close(): line 1952: decrementing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to decrement reference count
# 
#     error #002: ../../src/H5I.c in H5I_dec_app_ref(): line 1300: can't decrement ID ref count
#         class: HDF5
#         major: Object atom
#         minor: Unable to decrement reference count
# 
#     error #003: ../../src/H5Fint.c in H5F__close_cb(): line 2010: can't close file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #004: ../../src/H5Fint.c in H5F_try_close(): line 2181: problems closing file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #005: ../../src/H5Fint.c in H5F__dest(): line 1277: p

converted <- Convert("input2.h5ad", dest = "output2.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Error in dfile$obj_copy_from(src_loc = dfile, src_name = paste0("meta.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 314: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #002: ../../src/H5Ocopy.c in H5O__copy_obj(): line 1218: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #003: ../../src/H5Ocopy.c in H5O__copy_header(): line 1162: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
#
#     error #004: ../../src/H5Ocopy.c in H5O__copy_header_real(): line 887: unable to re-tag metadata entries
#         class: HDF5
#         major: Object cache
#         minor: Unable to tag metadata in the cache
#
#     error #005: ../../src/H5AC.c in H5AC_retag_copied_metadata(): line
# Error in private$closeFun(id) : HDF5-API Errors:
#     error #000: ../../src/H5F.c in H5Fclose(): line 675: closing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #001: ../../src/H5Fint.c in H5F__close(): line 1952: decrementing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to decrement reference count
#
#     error #002: ../../src/H5I.c in H5I_dec_app_ref(): line 1300: can't decrement ID ref count
#         class: HDF5
#         major: Object atom
#         minor: Unable to decrement reference count
#
#     error #003: ../../src/H5Fint.c in H5F__close_cb(): line 2010: can't close file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #004: ../../src/H5Fint.c in H5F_try_close(): line 2181: problems closing file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
#
#     error #005: ../../src/H5Fint.c in H5F__dest(): line 1277: p
Execution environment
$ h5cc -showconfig
	    SUMMARY OF THE HDF5 CONFIGURATION
	    =================================

General Information:
-------------------
                   HDF5 Version: 1.10.5
                  Configured on: Wed Jan 29 04:16:03 UTC 2020
                  Configured by: mockbuild@
                    Host system: x86_64-redhat-linux-gnu
              Uname information: Linux buildvm-24.phx2.fedoraproject.org 5.4.8-200.fc31.x86_64 #1 SMP Mon Jan 6 16:44:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
                       Byte sex: little-endian
             Installation point: /usr

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Fedora 32 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.9.so

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8   
 [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] SeuratDisk_0.0.0.9010

loaded via a namespace (and not attached):
 [1] httr_1.4.1         tidyr_1.1.0        bit64_0.9-7        hdf5r_1.3.2        jsonlite_1.7.0     viridisLite_0.3.0  splines_4.0.2     
 [8] leiden_0.3.3       assertthat_0.2.1   ggrepel_0.8.2      globals_0.12.5     pillar_1.4.4       lattice_0.20-41    glue_1.4.1        
[15] reticulate_1.16    digest_0.6.25      RColorBrewer_1.1-2 colorspace_1.4-1   cowplot_1.0.0      htmltools_0.5.0    Matrix_1.2-18     
[22] plyr_1.8.6         pkgconfig_2.0.3    tsne_0.1-3         listenv_0.8.0      purrr_0.3.4        patchwork_1.0.1    scales_1.1.1      
[29] RANN_2.6.1         Rtsne_0.15         tibble_3.0.1       generics_0.0.2     ggplot2_3.3.2      ellipsis_0.3.1     withr_2.2.0       
[36] ROCR_1.0-11        pbapply_1.4-2      lazyeval_0.2.2     cli_2.0.2          survival_3.1-12    magrittr_1.5       crayon_1.3.4      
[43] fansi_0.4.1        future_1.17.0      nlme_3.1-148       MASS_7.3-51.6      ica_1.0-2          tools_4.0.2        fitdistrplus_1.1-1
[50] data.table_1.12.8  lifecycle_0.2.0    stringr_1.4.0      plotly_4.9.2.1     munsell_0.5.0      cluster_2.1.0      irlba_2.3.3       
[57] compiler_4.0.2     rsvd_1.0.3         rlang_0.4.6        grid_4.0.2         ggridges_0.5.2     rstudioapi_0.11    RcppAnnoy_0.0.16  
[64] rappdirs_0.3.1     htmlwidgets_1.5.1  igraph_1.2.5       Seurat_3.1.5       gtable_0.3.0       codetools_0.2-16   reshape2_1.4.4    
[71] R6_2.4.1           gridExtra_2.3      zoo_1.8-8          dplyr_1.0.0        bit_1.1-15.2       future.apply_1.6.0 uwot_0.1.8        
[78] KernSmooth_2.23-17 ape_5.4            stringi_1.4.6      parallel_4.0.2     Rcpp_1.0.4.6       vctrs_0.3.1        sctransform_0.2.1 
[85] png_0.1-7          tidyselect_1.1.0   lmtest_0.9-37     

The issue isn't related to R 4.0, since I'm able to replicate it in rocker/tidyverse:3.6.3:

Replicate issue in Docker
$ docker pull rocker/tidyverse:3.6.3
$ docker run -it -v `pwd`:/mount --entrypoint bash rocker/tidyverse:3.6.3
$ cd /mount
$ sudo apt-get install libhdf5-dev
$ h5cc -showconfig | grep Version
                   HDF5 Version: 1.10.4
$ R
> install.packages("hdf5r")
> remotes::install_github("mojaveazure/seurat-disk")
> library(SeuratDisk)
> converted <- Convert("input2.h5ad", dest = "output2.h5seurat", overwrite = TRUE)
# Warning: Unknown file type: h5ad
# Warning: 'assay' not set, setting to 'RNA'
# Creating h5Seurat file for version 3.1.2
# Adding X as data
# Adding raw/X as counts
# Adding meta.features from raw/var
# Error in dfile$obj_copy_from(src_loc = dfile, src_name = paste0("meta.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 317: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
# 
#     error #002: ../../../src/H5Ocopy.c in H5O__copy_obj(): line 1221: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
# 
#     error #003: ../../../src/H5Ocopy.c in H5O__copy_header(): line 1165: unable to copy object
#         class: HDF5
#         major: Object header
#         minor: Unable to copy object
# 
#     error #004: ../../../src/H5Ocopy.c in H5O__copy_header_real(): line 890: unable to re-tag metadata entries
#         class: HDF5
#         major: Object cache
#         minor: Unable to tag metadata in the cache
# 
#     error #005: ../../../src/H5AC.c in H5AC_retag_copie
# Error in private$closeFun(id) : HDF5-API Errors:
#     error #000: ../../../src/H5F.c in H5Fclose(): line 668: closing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #001: ../../../src/H5Fint.c in H5F__close(): line 2047: decrementing file ID failed
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to decrement reference count
# 
#     error #002: ../../../src/H5I.c in H5I_dec_app_ref(): line 1309: can't decrement ID ref count
#         class: HDF5
#         major: Object atom
#         minor: Unable to decrement reference count
# 
#     error #003: ../../../src/H5Fint.c in H5F__close_cb(): line 2105: can't close file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #004: ../../../src/H5Fint.c in H5F_try_close(): line 2276: problems closing file
#         class: HDF5
#         major: File accessibilty
#         minor: Unable to close file
# 
#     error #005: ../../../src/H5Fint.c in H5F__de
> sessionInfo()
# R version 3.6.3 (2020-02-29)
# Platform: x86_64-pc-linux-gnu (64-bit)
# Running under: Debian GNU/Linux 10 (buster)
# 
# Matrix products: default
# BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.3.5.so
# 
# 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=C             
#  [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       
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] SeuratDisk_0.0.0.9010
# 
# loaded via a namespace (and not attached):
#  [1] httr_1.4.1          tidyr_1.0.2         bit64_0.9-7        
#  [4] hdf5r_1.3.2         jsonlite_1.6.1      viridisLite_0.3.0  
#  [7] splines_3.6.3       lsei_1.2-0          leiden_0.3.3       
# [10] gtools_3.8.2        assertthat_0.2.1    ggrepel_0.8.2      
# [13] globals_0.12.5      pillar_1.4.3        lattice_0.20-38    
# [16] glue_1.4.0          reticulate_1.15     digest_0.6.25      
# [19] RColorBrewer_1.1-2  colorspace_1.4-1    cowplot_1.0.0      
# [22] htmltools_0.4.0     Matrix_1.2-18       plyr_1.8.6         
# [25] pkgconfig_2.0.3     tsne_0.1-3          listenv_0.8.0      
# [28] purrr_0.3.4         patchwork_1.0.0     scales_1.1.0       
# [31] RANN_2.6.1          gdata_2.18.0        Rtsne_0.15         
# [34] tibble_3.0.1        ggplot2_3.3.0       ellipsis_0.3.0     
# [37] withr_2.2.0         ROCR_1.0-7          pbapply_1.4-2      
# [40] lazyeval_0.2.2      cli_2.0.2           survival_3.1-8     
# [43] magrittr_1.5        crayon_1.3.4        fansi_0.4.1        
# [46] future_1.17.0       nlme_3.1-144        MASS_7.3-51.5      
# [49] gplots_3.0.3        ica_1.0-2           tools_3.6.3        
# [52] fitdistrplus_1.0-14 data.table_1.12.8   lifecycle_0.2.0    
# [55] stringr_1.4.0       plotly_4.9.2.1      munsell_0.5.0      
# [58] cluster_2.1.0       irlba_2.3.3         compiler_3.6.3     
# [61] rsvd_1.0.3          caTools_1.18.0      rlang_0.4.5        
# [64] grid_3.6.3          ggridges_0.5.2      RcppAnnoy_0.0.16   
# [67] rappdirs_0.3.1      htmlwidgets_1.5.1   igraph_1.2.5       
# [70] bitops_1.0-6        Seurat_3.1.5        npsurv_0.4-0       
# [73] gtable_0.3.0        codetools_0.2-16    reshape2_1.4.4     
# [76] R6_2.4.1            gridExtra_2.3       zoo_1.8-7          
# [79] dplyr_0.8.5         bit_1.1-15.2        uwot_0.1.8         
# [82] future.apply_1.5.0  KernSmooth_2.23-16  ape_5.3            
# [85] stringi_1.4.6       parallel_3.6.3      Rcpp_1.0.4.6       
# [88] vctrs_0.2.4         sctransform_0.2.1   png_0.1-7          
# [91] tidyselect_1.0.0    lmtest_0.9-37 

I did manage to find a workaround by closing and re-opening the output file right before the error occurs, though this is nothing more than a temporary hack, and a real solution should be found.

Do you have any ideas that could solve this problem?

Kind regards,
Robrecht

Convert do not allow multiple assays to be converted at a time for use with scVelo as demonstrated in scVelo vignette

Hi,

I am following the scVelo vignette (in seuratwrappers) with the following seurat Object. After creating h5ad file and importing it as an anndata object, it seems that, assays other than RNA is not written to h5ad. If I use assays argument in Convert function, it only allows one assay, not multiple assays. Can you help me solve this? Thanks in advance!

Fib
An object of class Seurat
152625 features across 13143 samples within 6 assays
Active assay: RNA (25697 features, 0 variable features)
5 other assays present: SCT, integrated, spliced, unspliced, ambiguous
4 dimensional reductions calculated: pca, umap, harm_umap, harmony

In R

>DefaultAssay(Fib) <- "RNA"

>SaveH5Seurat(Fib, filename = "Fibroblast_for_scVelo_complete.h5Seurat")
Creating h5Seurat file for version 3.1.2
Adding counts for RNA
Adding data for RNA
No variable features found for RNA
No feature-level metadata found for RNA
Adding counts for SCT
Adding data for SCT
Adding scale.data for SCT
No variable features found for SCT
No feature-level metadata found for SCT
Adding data for integrated
Adding scale.data for integrated
Adding variable features for integrated
No feature-level metadata found for integrated
Adding counts for spliced
Adding data for spliced
No variable features found for spliced
No feature-level metadata found for spliced
Adding counts for unspliced
Adding data for unspliced
No variable features found for unspliced
No feature-level metadata found for unspliced
Adding counts for ambiguous
Adding data for ambiguous
No variable features found for ambiguous
No feature-level metadata found for ambiguous
Adding cell embeddings for pca
Adding loadings for pca
No projected loadings for pca
Adding standard deviations for pca
No JackStraw data for pca
Adding cell embeddings for umap
No loadings for umap
No projected loadings for umap
No standard deviations for umap
No JackStraw data for umap
Adding cell embeddings for harm_umap
No loadings for harm_umap
No projected loadings for harm_umap
No standard deviations for harm_umap
No JackStraw data for harm_umap
Adding cell embeddings for harmony
No loadings for harmony
No projected loadings for harmony
No standard deviations for harmony
No JackStraw data for harmony

>Convert("Fibroblast_for_scVelo_complete.h5Seurat", dest = "h5ad")
Validating h5Seurat file
Adding data from RNA as X
Adding counts from RNA as raw
Transfering meta.data to obs
Adding dimensional reduction information for umap (global)

In python

import scvelo as scv
adata = scv.read("/mnt/DATA1/Fibrosis/Full Scale Analysis/scVelo/Fibroblast_integrated_for_scVelo_complete.h5ad")
adata
Out[8]: 
AnnData object with n_obs × n_vars = 13143 × 25697 
    obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'GC_Sample_Number', 'Location', 'Segment', 'Patient_Type', 'Biopsy_method', 'Age', 'Patient_no', 'Sample', 'Sample_type', 'Gender', 'percent.mt', 'nCount_SCT', 'nFeature_SCT', 'integrated_snn_res.2', 'seurat_clusters', 'Harmony_Clusters', 'integrated_snn_res.1', 'integrated_snn_res.0.6', 'integrated_snn_res.0.4', 'integrated_snn_res.0.3', 'integrated_snn_res.0.2', 'integrated_snn_res.0.15', 'subtype', 'colors', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'nCount_ambiguous', 'nFeature_ambiguous', 'initial_size'
    var: 'features'
    obsm: 'X_umap'

notice that var: only shows 'features' as opposed to var: 'features', 'ambiguous_features', 'spliced_features', 'unspliced_features' shown in the vignette (below is how it is in the vignette) and the layers are not added.

 AnnData object with n_obs × n_vars = 6667 × 24421
    obs: 'orig.ident', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'nCount_ambiguous', 'nFeature_ambiguous', 'nCount_RNA', 'nFeature_RNA', 'nCount_SCT', 'nFeature_SCT', 'SCT_snn_res.0.8', 'seurat_clusters'
    var: 'features', 'ambiguous_features', 'spliced_features', 'unspliced_features'
    obsm: 'X_umap'
    layers: 'ambiguous', 'spliced', 'unspliced'

h5ad->Seurat:Not a sparse matrix

When using the covert function I get the following error using the Villani dataset from https://www.covid19cellatlas.org/:
Error: Not a sparse matrix

It generates a file output but then LoadH5Seurat can't read it:
Validating h5Seurat file
Error in h5attr(x = self[["reductions"]][[reduc]], which = "active.assay") :
Attribute does not exist

Any help much appreciated

Error in getOption("SeuratDisk.dtypes.dataframe_as_group", x = TRUE)

Just testing the functionality and have encountered the following error:

Convert("kallisto.dir/HEK293-NIH3T3-DropSeq2_S2/bus/counts_unfiltered/adata.h5ad", dest = "h5seurat", assay="RNA", overwrite = TRUE)
Unknown file type: h5adCreating h5Seurat file for version 3.1.2
Adding X as data
Adding X as counts
Adding meta.features from var
Error in getOption("SeuratDisk.dtypes.dataframe_as_group", x = TRUE) : 
  'x' must be a character string

Any advice would be much appreciated Thanks

Cannot convert an h5ad file back to Seurat object

Hi,

Great package. But I'm having issues converting a seurat object to h5ad file and then reading that file back in. I analyzed my data using Seurat and saved it as sc.h5ad

> SaveH5Seurat(scrna, filename = "sc.h5Seurat")

Creating h5Seurat file for version 3.1.5.9900
Adding counts for RNA
Adding data for RNA
Adding variable features for RNA
Adding feature-level metadata for RNA
Adding counts for SCT
Adding data for SCT
Adding scale.data for SCT
Adding variable features for SCT
Adding feature-level metadata for SCT
Adding cell embeddings for pca
Adding loadings for pca
No projected loadings for pca
Adding standard deviations for pca
No JackStraw data for pca
Adding cell embeddings for tsne
No loadings for tsne
No projected loadings for tsne
No standard deviations for tsne
No JackStraw data for tsne
Adding cell embeddings for umap
No loadings for umap
No projected loadings for umap
No standard deviations for umap
No JackStraw data for umap

> Convert("sc.h5Seurat", dest = "h5ad")

Validating h5Seurat file
Adding scale.data from SCT as X
Transfering meta.features to var
Adding data from SCT as raw
Transfering meta.features to raw/var
Transfering meta.data to obs
Adding dimensional reduction information for pca
Adding feature loadings for pca
Adding dimensional reduction information for tsne
Adding dimensional reduction information for umap
Adding SCT_snn as neighbors

I now want this h5ad file to be read into a shiny interface. But converting it back gives me this issue

> Convert("sc.h5ad", dest = "h5seurat", overwrite = TRUE)

Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
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
Merging sct.detection_rate from scaled feature-level metadata
Merging sct.gmean from scaled feature-level metadata
Merging sct.residual_mean from scaled feature-level metadata
Merging sct.residual_variance from scaled feature-level metadata
Merging sct.variable from scaled feature-level metadata
Merging sct.variance from scaled feature-level metadata
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
Saving nearest-neighbor graph as RNA_snn
Error in dfile[["graphs"]][[graph.name]]$create_attr(attr_name = "assay.used",  : 
  Can't create attribute; already exists

>scrna <- LoadH5Seurat("sc.h5seurat")

Same issue with the example pbmc data in the documentation.

Error: Object too old to save

Not sure what is going on here, since the Seurat object is definitely updated:

SaveH5Seurat(bm, filename = "mouseBM.h5Seurat")
Creating h5Seurat file for version 3.1.5.9900
Error: Object too old to save, please update your Seurat object to at least v3.1.2 using UpdateSeuratObject

Unclear as to what is going on! Session info below

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] SeuratDisk_0.0.0.9011 shiny_1.5.0 dittoSeq_1.1.6 velocyto.R_0.6 SeuratWrappers_0.2.0
[6] devtools_2.3.1 usethis_1.6.1 sctransform_0.2.1 ggplot2_3.3.2 cowplot_1.0.0
[11] Matrix_1.2-18 dplyr_1.0.1 Seurat_3.2.0 escape_0.99.7

Error in Initializing RNA with data

Hi.

This is probably not directly related to SeuratDisk function, but when attempting to read a large .h5ad converted to .h5seurat by Convert(), the loading crashed in LoadH5Seurat(). The dataset I pretend to load is huge (>1M cells). Is it possible that R and consequently Seurat is limited to a matrix size that does not allow to import such files? Do you know any workaround to this error?

## My code
library(Seurat)
library(SeuratDisk)
library(hdf5r)
file=paste0(pathToDir,"allpools.scanpy.init.h5ad")
fileSeurat=paste0(pathToDir,"allpools.scanpy.init.h5seurat")
Convert(file, dest = fileSeurat, overwrite = TRUE)
test <- LoadH5Seurat(fileSeurat)

This is the error message I obtained:
Registered S3 method overwritten by 'cli':
method from
print.boxx spatstat
Registered S3 method overwritten by 'SeuratDisk':
method from
as.sparse.H5Group Seurat
Warning: Unknown file type: h5ad
Warning: 'assay' not set, setting to 'RNA'
Creating h5Seurat file for version 3.1.5.9900
Adding X as data
Adding X as counts
Adding meta.features from var
Validating h5Seurat file
Initializing RNA with data
Error in if ((lp <- length(p)) < 1 || p[1] != 0 || any((dp <- p[-1] - :
missing value where TRUE/FALSE needed
Calls: LoadH5Seurat ... as.matrix.H5Group -> as.sparse -> as.sparse.H5Group -> sparseMatrix
In addition: Warning message:
In sparseMatrix(i = x[["indices"]][] + 1, p = x[["indptr"]][], x = x[["data"]][], :
NAs introduced by coercion to integer range
Execution halted

Thanks in advance for your help.

Error when saving h5seurat

Good day,

I am having issues saving a Seurat object with SaveH5Seurat. Do not know what the problem can be.

Creating h5Seurat file for version 3.1.5.9900

Adding counts for RNA

Adding data for RNA

No variable features found for RNA

No feature-level metadata found for RNA

Adding counts for SCT

Adding data for SCT

Adding scale.data for SCT

No variable features found for SCT

No feature-level metadata found for SCT

Adding data for integrated

Adding scale.data for integrated

Adding variable features for integrated

No feature-level metadata found for integrated

Adding cell embeddings for pca

Adding loadings for pca

No projected loadings for pca

Adding standard deviations for pca

No JackStraw data for pca

Adding cell embeddings for umap

No loadings for umap

No projected loadings for umap

No standard deviations for umap

No JackStraw data for umap

Error in guess_dtype(x = x, ...): unknown type
Traceback:

1. 1
2. 2
3. 3
4. 4
5. 5
6. 5
7. 7
8. 7
9. 9
10. ⋯
11. 9
12. 13
13. 13
14. 15
15. 16
16. 17
17. 18
18. 19

Any ideas on how to solve this issue? thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.