Write an AnnData object atomically, validating the round trip
Description
Writes ‘adata’ to a temporary ‘.h5ad’ in the destination directory, reads it back with [anndataR::read_h5ad()], calls ‘validate’ on the restored object, and renames the temporary file to ‘path’ only if validation returns. The temporary file is removed on any failure.
Usage
write_h5ad_atomic(
adata,
path,
validate = function(restored) NULL,
compression = "gzip"
)
Arguments
adata
|
An ‘anndataR’ AnnData object. |
path
|
Destination ‘.h5ad’ path. Its directory must exist. |
validate
|
Function of one argument, the restored AnnData. Should ‘stop()’ on a failed round trip; its return value is ignored. |
compression
|
Passed to ‘write_h5ad()’. Default ‘"gzip"’. |
Value
The normalized destination path, invisibly.