Here is a toy SingleCellExperiment
object with a counts
assay using an HDF5 realization:
library(Matrix)
library(HDF5Array)
library(SingleCellExperiment)
library(magrittr)
cts <- writeHDF5Array(rsparsematrix(10,10,0.1), "test.h5",
as.sparse=TRUE, with.dimnames=TRUE)
sce <- SingleCellExperiment(assays=list(counts=cts))
saveRDS(sce, "test.rds")
If I relocate these two files, test.h5
and test.rds
, say to a subfolder, foo
, then the RDS object still loads fine, but the counts
assay can no longer find the realization, since it appears to have recorded an absolute path. For example, I see this behavior:
sce_reload <- readRDS("foo/test.rds")
counts(sce_reload)
## Error in value[[3L]](cond) :
## 'assay(<SingleCellExperiment>, i="character", ...)' invalid subscript 'i'
## H5Fis_hdf5() returned an error
Examining, the object, I can see that sce_reload@assays@data@listData$counts@seed@filepath
points to the original full path.
Is there are way to save a SingleCellExperiment
object with a DelayedArray
assays that is portable? i.e., one can share or move the objects and still be loadable?