-
Notifications
You must be signed in to change notification settings - Fork 955
Closed
Description
Hello, I created a lot of rds files using Seurat V5 and merged all the rds files together and merged the Count using JoinLayers(). I am now trying to convert the rds to h5ad but I am getting the following error. Thanks !!!
pbmc_filter <- as.SingleCellExperiment(pbmc, assay = c("RNA"))
writeH5AD(pbmc_filter, "pbmc_filter.h5ad", X_name = 'counts')
No module named 'anndata'Traceback:
1. writeH5AD(pbmc_filter, "pbmc_filter.h5ad", X_name = "counts")
2. basiliskRun(env = env, fun = .H5ADwriter, sce = sce, file = file,
. X_name = X_name, skip_assays = skip_assays, compression = compression,
. verbose = verbose, ...)
3. fun(...)
4. SCE2AnnData(sce, X_name = X_name, skip_assays = skip_assays,
. verbose = verbose, ...)
5. import("anndata")
6. py_module_import(module, convert = convert)
Activity
yangshichen0713 commentedon Dec 25, 2023
Then I used another method and that didn't work either. -_-
haukeh90 commentedon Dec 29, 2023
Hi,
this problem can be circumvented by converting the V5 to a V3 assay in the seurat object before the conversion:
object[["RNA3"]] <- as(object = object[["RNA"]], Class = "Assay")
DefaultAssay(object) <- "RNA3"
object[["RNA"]] <- NULL
object <- RenameAssays(object = object, RNA3 = 'RNA')
please find additional information here: https://satijalab.org/seurat/articles/seurat5_essential_commands
subsequent conversion could be done using sceasy: https://github.com/cellgeni/sceasy
However I could imagine that the conversion outlined by mojaveazure (without using sceasy) should also work after converting the V5 to the V3 assay: https://mojaveazure.github.io/seurat-disk/articles/convert-anndata.html
Best
Hauke
yangshichen0713 commentedon Jan 2, 2024
Thanks, I will have a try!
samuel-marsh commentedon Feb 28, 2024
Hi,
Not member of dev team but hopefully can be helpful. As per other issues here Seurat team has updated that SeuratData (convert function) is no longer being actively maintained.
As others have mentioned sceasy will work if it’s Assay (Seurat v3/4) object but not v5 and unfortunately package doesn’t appear to be actively maintained. To simplify the process I have introduced
as.anndata
function in my package scCustomize which will work will either type of Seurat object and without requiring conversion of assay type.https://samuel-marsh.github.io/scCustomize/articles/Object_Conversion.html#convert-seurat-or-liger-objects-to-anndata-objects
Best,
Sam
Note: Closing issue as it pertains to SeuratDisk/Convert function.
heteyszabolcs commentedon Mar 20, 2024
After I converted back to V3 the mojaveazure way worked. Thanks!
albertfei1998 commentedon Jun 14, 2025
obj[["RNA3"]] <- as(obj[["RNA"]], Class = "Assay")
DefaultAssay(obj) <- "RNA3"
obj[["RNA"]] <- NULL
obj <- RenameAssays(object = obj, RNA3 = 'RNA')
after converted back to V3, it works.
but scanpy read the converted .h5sd file and showed only 2000 genes, which might be the high variable gene.
very inconvenient in V5, suggest use scanpy from the very begining.
albertfei1998 commentedon Jun 14, 2025
great work!