Write a QFeatures object to an .h5mu file.
writeLinkH5MU.RdInverse of readLinkH5MU(). MuData::writeH5MU() covers the
MultiAssayExperiment skeleton; the feature graph held in AssayLinks is
written separately to the global .varp as a p x p sparse adjacency
matrix over the global .var index.
Arguments
- object
A
QFeaturesobject prepared withprepareQFeatures().- path
Path of the .h5mu file to create.
- feature_mapping_key
Key to store the feature graph under in
.varp.- overwrite
Whether to replace
pathif it already exists.
Limitations
Writing to .h5mu does not preserve all R data types and structures:
Date and date-time classes (
Date,POSIXct, andPOSIXlt) are not supported natively and must be converted before writing.The distinction between numeric
NAandNaNis lost: both are read back asNaNbyreadLinkH5MU().Complex data structures in
rowDataormetadataare not fully supported. Matrix-valuedrowDatacolumns are dropped with a warning. Unsupported metadata objects, such asscpModelobjects (classScpModel), must be simplified before writing.Unused factor levels are not preserved.
Feature row names must be globally unique across all sets. Duplicate row names cause an error.
Integer and logical columns containing
NAin globalcolData, set-specificcolData, orrowDataare converted to doubles with a warning. Their original types are lost; logical values become1and0, while missing values remain missing.
Use object <- prepareQFeatures(object) before writing to address some of
these limitations. prepareQFeatures() converts date and date-time columns
in global colData and set-specific rowData and colData to formatted
character strings, converts scpModel objects in set metadata to lists,
and prefixes feature row names with set names when needed to make them
globally unique, updating the set links accordingly. It does not restore
the original date classes, missing-value distinction, unused factor levels,
or integer/logical column types when the file is read back.
Examples
data("feat3", package = "QFeatures")
preparedFeat3 <- prepareQFeatures(feat3)
#> Warning: Prefixed feature row names with assay names because they were not globally unique across the QFeatures object.
filePath <- tempfile(fileext = ".h5mu")
writeLinkH5MU(preparedFeat3, filePath)
file.exists(filePath)
#> [1] TRUE
unlink(filePath)