saveRDS,SpatialFeatureExperiment-method | R Documentation |
Saving SFE objects as RDS files is complicated by the SpatRaster
class
of the images. If present, the images need to be wrapped with the wrap
function in terra
before serializing the SFE object. Otherwise the
images will be invalid pointers when the RDS is reloaded. If the image does
not fit in memory and its file source is unknown, then it will be written to
a temporary file, which is reloaded when the RDS file is loaded. When an SFE
object with images is read from an RDS file, the images will not be unwrapped
until necessary.
## S4 method for signature 'SpatialFeatureExperiment'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
object |
A |
file |
a connection or the name of the file where the R object is saved to or read from. |
ascii |
a logical. If |
version |
the workspace format version to use. |
compress |
a logical specifying whether saving to a named file is
to use |
refhook |
a hook function for handling reference objects. |
Invisibly NULL
.
outdir <- system.file("extdata", package = "SpatialFeatureExperiment")
samples <- file.path(outdir, paste0("sample0", 1:2))
sfe <- read10xVisiumSFE(samples, type = "sparse", data = "filtered")
saveRDS(sfe, "foo.rds")
# Clean up
file.remove("foo.rds")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.