seurat-disk
seurat-disk copied to clipboard
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:
- 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
- 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)
- 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!
Hi @cchrysostomou, did you by any chance figure out how to fix this? I'm having the same issue.
This error may be caused by the different features or cells between assays or slots in the h5Seurat. You can load them separately and check whether has an equal length. The easiest way to check the structure and data dimensions in a hdf5 file is using rhdf5::h5ls() function:
library(rhdf5)
structure <- h5ls("srt.h5Seurat")
You can also check the cells or features in Seurat:
cells <- h5read("srt.h5Seurat","cell.names")
features <- h5read(filename,"/assays/RNA/features")
It should be noted that the sparse matrix representation in h5Seurat is special, which is explained in this Article.
Hi, I also encounter this error when rerun the chromatin assay today. I keep the settings and pipelines the same as previous running. My code is,
library(Signac) #control counts_ctrl <- Read10X_h5(filename = "/PHShome/sn225/bio/scRNA_scATAC/KW8595_Athe/GRCh38/BRI-1020/outs/filtered_peak_bc_matrix.h5") Warning message: In sparseMatrix(i = indices[] + 1, p = indptr[], x = as.numeric(x = counts[]), : 'giveCsparse' has been deprecated; setting 'repr = "T"' for you metadata_ctrl <- read.csv(
- file = "/PHShome/sn225/bio/scRNA_scATAC/KW8595_Athe/GRCh38/BRI-1020/outs/singlecell.csv",
- header = TRUE,
- row.names = 1
- )
chrom_assay_ctrl <- CreateChromatinAssay(
- counts = counts_ctrl,
- sep = c(":", "-"),
- genome = 'hg38',
- fragments = '/PHShome/sn225/bio/scRNA_scATAC/KW8595_Athe/GRCh38/BRI-1020/outs/fragments.tsv.gz',
- min.cells = 10,
- min.features = 200
- ) Error in dimnamesGets(x, value) : invalid dimnames given for "dgCMatrix" object
My sessioninfo()is,
sessionInfo () R version 4.0.2 (2020-06-22) 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
Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats4 parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] future_1.21.0 cowplot_1.1.1 EnsDb.Hsapiens.v75_2.99.0
[4] glmGamPoi_1.0.0 sctransform_0.3.2 gridExtra_2.3
[7] AnnotationHub_2.20.2 BiocFileCache_1.12.1 dbplyr_2.1.1
[10] reticulate_1.20 knitr_1.33 RCurl_1.98-1.3
[13] pbmcMultiome.SeuratData_0.1.0 SeuratData_0.2.1 SeuratDisk_0.0.0.9019
[16] forcats_0.5.1 stringr_1.4.0 purrr_0.3.4
[19] readr_1.4.0 tidyr_1.1.3 tibble_3.1.2
[22] tidyverse_1.3.1 dplyr_1.0.6 patchwork_1.1.1
[25] EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.12.1 AnnotationFilter_1.12.0
[28] GenomicFeatures_1.40.1 AnnotationDbi_1.50.3 Biobase_2.50.0
[31] GenomicRanges_1.40.0 GenomeInfoDb_1.26.7 IRanges_2.24.1
[34] S4Vectors_0.28.1 BiocGenerics_0.36.1 SeuratObject_4.0.2
[37] Seurat_4.0.3 ggplot2_3.3.4 devtools_2.3.2
[40] usethis_1.6.3 SnapATAC_1.0.0 rhdf5_2.34.0
[43] Matrix_1.3-4 Signac_1.2.1
loaded via a namespace (and not attached):
[1] rappdirs_0.3.3 SnowballC_0.7.0 rtracklayer_1.48.0
[4] scattermore_0.7 bit64_4.0.5 irlba_2.3.3
[7] DelayedArray_0.16.3 data.table_1.14.0 rpart_4.1-15
[10] doParallel_1.0.16 generics_0.1.0 snow_0.4-3
[13] callr_3.4.4 RSQLite_2.2.0 RANN_2.6.1
[16] bit_4.0.4 xml2_1.3.2 spatstat.data_2.1-0
[19] lubridate_1.7.10 httpuv_1.6.1 SummarizedExperiment_1.18.2
[22] assertthat_0.2.1 viridis_0.6.1 xfun_0.22
[25] hms_1.1.0 promises_1.2.0.1 fansi_0.5.0
[28] progress_1.2.2 readxl_1.3.1 igraph_1.2.6
[31] DBI_1.1.0 htmlwidgets_1.5.3 sparsesvd_0.2
[34] spatstat.geom_2.2-0 ellipsis_0.3.2 backports_1.1.10
[37] biomaRt_2.44.1 deldir_0.2-10 MatrixGenerics_1.2.1
[40] vctrs_0.3.8 remotes_2.2.0 ROCR_1.0-11
[43] abind_1.4-5 withr_2.2.0 ggforce_0.3.3
[46] GenomicAlignments_1.24.0 prettyunits_1.1.1 goftest_1.2-2
[49] bigmemory_4.5.36 cluster_2.1.0 lazyeval_0.2.2
[52] crayon_1.4.1 hdf5r_1.3.2 edgeR_3.32.1
[55] pkgconfig_2.0.3 slam_0.1-48 tweenr_1.0.2
[58] nlme_3.1-149 pkgload_1.1.0 ProtGenerics_1.20.0
[61] rlang_0.4.11 globals_0.14.0 lifecycle_1.0.0
[64] miniUI_0.1.1.1 bigmemory.sri_0.1.3 doSNOW_1.0.18
[67] modelr_0.1.8 cellranger_1.1.0 rprojroot_1.3-2
[70] polyclip_1.10-0 matrixStats_0.59.0 lmtest_0.9-38
[73] ggseqlogo_0.1 Rhdf5lib_1.12.1 zoo_1.8-9
[76] reprex_2.0.0 ggridges_0.5.3 processx_3.4.4
[79] png_0.1-7 viridisLite_0.4.0 bitops_1.0-7
[82] KernSmooth_2.23-17 rhdf5filters_1.2.1 Biostrings_2.56.0
[85] blob_1.2.1 parallelly_1.26.0 scales_1.1.1
[88] memoise_1.1.0 magrittr_2.0.1 plyr_1.8.6
[91] ica_1.0-2 zlibbioc_1.36.0 compiler_4.0.2
[94] RColorBrewer_1.1-2 fitdistrplus_1.1-5 Rsamtools_2.4.0
[97] cli_2.5.0 XVector_0.30.0 listenv_0.8.0
[100] pbapply_1.4-3 ps_1.3.4 MASS_7.3-52
[103] mgcv_1.8-33 tidyselect_1.1.1 stringi_1.6.2
[106] yaml_2.2.1 askpass_1.1 locfit_1.5-9.4
[109] ggrepel_0.9.1 grid_4.0.2 fastmatch_1.1-0
[112] tools_4.0.2 future.apply_1.7.0 rstudioapi_0.13
[115] foreach_1.5.1 lsa_0.73.2 farver_2.1.0
[118] Rtsne_0.15 rvcheck_0.1.8 BiocManager_1.30.10
[121] digest_0.6.27 shiny_1.6.0 qlcMatrix_0.9.7
[124] Rcpp_1.0.6 broom_0.7.7 BiocVersion_3.11.1
[127] later_1.2.0 RcppAnnoy_0.0.18 httr_1.4.2
[130] colorspace_2.0-1 rvest_1.0.0 XML_3.99-0.5
[133] fs_1.5.0 tensor_1.5 splines_4.0.2
[136] uwot_0.1.10.9000 RcppRoll_0.3.0 spatstat.utils_2.2-0
[139] plotly_4.9.4.1 sessioninfo_1.1.1 xtable_1.8-4
[142] jsonlite_1.7.2 testthat_2.3.2 R6_2.5.0
[145] pillar_1.6.1 htmltools_0.5.1.1 mime_0.10
[148] glue_1.4.2 fastmap_1.1.0 BiocParallel_1.24.1
[151] interactiveDisplayBase_1.26.3 codetools_0.2-16 pkgbuild_1.1.0
[154] utf8_1.2.1 lattice_0.20-41 spatstat.sparse_2.0-0
[157] curl_4.3.1 leiden_0.3.8 misc3d_0.8-4
[160] openssl_1.4.4 survival_3.2-3 limma_3.46.0
[163] docopt_0.7.1 desc_1.2.0 munsell_0.5.0
[166] GenomeInfoDbData_1.2.4 plot3D_1.3 iterators_1.0.13
[169] haven_2.3.1 reshape2_1.4.4 gtable_0.3.0
[172] spatstat.core_2.2-0
did you ever solve this issue?
No.
| | Suhui Zhao | | @.*** | 签名由网易邮箱大师定制 On 9/30/2021 @.***> wrote:
did you ever solve this issue?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
It's been some time for me but I think I found that a lot of the seurat disk errors were caused by having a lot of in compatible scanpy objects. So for example, If I just had count data, then seurat disk would work fine, but once I started storing other parts of the pipeline such as umap, .raw variables then I would not be able to load them into seurat disk. You might try and just play with saving different objects that have different amounts of data stored and see if any of them can be loaded in.
In the end, it was a lot more stable for me to just use rpy2 and then save as an RDS.
same issue, any suggestion?