Open whtns opened 8 months ago
I got an error while using your SaveH5SeuratObject function. It says: Cannot delete default assay. Do you know what to do?
I got an error while using your SaveH5SeuratObject function. It says: Cannot delete default assay. Do you know what to do?
It's because you cannot assign NULL
to a default Assay:
https://github.com/satijalab/seurat-object/blob/1a140c74b25f0f9755c21032bc1a97c15140b36d/R/seurat.R#L4899
@whtns A fix is to switch the default assay to "RNA-tmp" before removing the original:
DefaultAssay(object) <- "RNA-tmp"
And do the same in LoadH5SeuratObject
for the Assay5 "RNA" before deleting the corresponding "Assay" class.
It is possible to "patch" each of
SaveH5Seurat
,LoadH5Seurat
functions (tested with Seurat v5.0.1).Here it is for
SaveH5Seurat
:And for
LoadH5Seurat
:The biggest caveat is that it requires to make a copy of the RNA assay at each pass (saving or loading). A direct conversion would be preferable, but I have not found such a function in the SeuratObject package.
EDIT: A better function would iterate over all assays and do what I did for RNA for each "Assay5" class assay.
Originally posted by @Gilquin in https://github.com/mojaveazure/seurat-disk/issues/172#issuecomment-1931709246