mojaveazure / seurat-disk

Interfaces for HDF5-based Single Cell File Formats
https://mojaveazure.github.io/seurat-disk
GNU General Public License v3.0
155 stars 49 forks source link

Error when saving Seurat to H5Seurat file with latest Seurat Version #154

Open ShanshanHe-44 opened 1 year ago

ShanshanHe-44 commented 1 year ago

Dear team,

Hi, first of all thank for you great work! I faced an error once I want to save my seurat object to Anndata with the latest Seurat Version 4.99. Error in if (ncol(x = x[[]])) { : argument is of length zero I can run the same code and got Anndata before I updated. Therefore, I am wondering how can I fix the problem withSaveH5Seurat and Convert instead of other packages. Below is my code and sessioninfo() . Thanks for your help! DefaultAssay(obj.rna) <- "RNA" obj.rna[["SCT"]] <- NULL obj.rna[["integrated"]] <- NULL obj.rna@reductions$tsne <- NULL obj.rna@reductions$umap <- NULL batch.list <- c("Healthy1a", "Healthy1b", "Healthy2a", "Healthy3a", "Healthy3b", "Healthy4a", "Healthy1", "Healthy2","Healthy3","Healthy4","Healthy5") temp <- subset(obj.rna, orig.ident == "Healthy1a") for (batch in batch.list){ temp <- subset(obj.rna, orig.ident == batch) SaveH5Seurat(temp, overwrite = TRUE, filename = paste0("batch_",batch,"_liver_RNA.h5Seurat")) Convert(paste0("batch_",batch,"_liver_RNA.h5Seurat"), dest = "h5ad", overwrite = TRUE) } `> sessionInfo() R version 4.2.0 (2022-04-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS 13.2.1

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2/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] stats4 stats graphics grDevices utils datasets methods base

other attached packages: [1] data.table_1.14.6 EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.22.0
[4] AnnotationFilter_1.22.0 GenomicFeatures_1.50.4 AnnotationDbi_1.60.0
[7] Biobase_2.58.0 GenomicRanges_1.50.2 GenomeInfoDb_1.34.9
[10] IRanges_2.32.0 S4Vectors_0.36.1 BiocGenerics_0.44.0
[13] qs_0.25.4 ggrepel_0.9.3 symphony_0.1.1
[16] harmony_0.1.1 Rcpp_1.0.10 SeuratDisk_0.0.0.9020
[19] forcats_1.0.0 stringr_1.5.0 dplyr_1.1.0
[22] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0
[25] tibble_3.1.8 ggplot2_3.4.1 tidyverse_1.3.2
[28] Signac_1.9.0.9000 Seurat_4.9.9.9044 SeuratObject_4.9.9.9084
[31] sp_1.6-0
`

Victor21v commented 1 year ago

I have exactly the same error with that version.

christensensm commented 1 year ago

Duplicate issue...potentially resolved in #147

yamihn commented 1 year ago

hello, how can I install your branch? @christensensm

christensensm commented 1 year ago

hello, how can I install your branch? @christensensm

Hi @yamihn, you can install using devtools or remotes. For example, devtools::install_github("christensensm/seurat-disk-fixattempt"). Then load as you would load Seurat Disk: library(SeuratDisk).