| Title: | Infrastructure to serialize and restore mass spectrometry data objects |
|---|---|
| Description: | The serialization mechanism of R allows to save and load R data objects in a binary format, that can however not be read by other programming languages or software. The MsStash package defines classes and method to enable serializing and restoring, or importing, mass spectrometry data objects to and from language agnostic file formats. A variety of different file types, including HDF5 and JSON-based formats defined by the Bioconductor *alabaster* package are supported. The file type can be defined and configured through a second argument `param` of the save/read methods. |
| Authors: | Johannes Rainer [aut, cre] (ORCID: <https://orcid.org/0000-0002-6977-7147>), Philippine Louail [aut] (ORCID: <https://orcid.org/0009-0007-5429-6846>), Laurent Gatto [ctb] (ORCID: <https://orcid.org/0000-0002-1520-2268>) |
| Maintainer: | Johannes Rainer <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 0.97.0 |
| Built: | 2026-05-12 11:24:03 UTC |
| Source: | https://github.com/rformassspectrometry/MsStash |
The alabaster framework provides the methodology to save R objects to on-disk representations/ storage modes which are programming language independent (in contrast to e.g. R's RDS files). By using standard file formats such as JSON and HDF5, alabaster ensures that the data can also be read and imported by other programming languages such as Python or Javascript. This improves interoperability between application ecosystems.
The alabaster package defines the alabaster.base::saveObject() and
alabaster.base::readObject() methods that have to be implemented for
specific data classes to enable saving to or reading from alabaster-based
file formats.
In addition, the MsStash package defines the AlabasterParam which can be
used to write or read MS objects using the saveMsObject() and
readMsObject() methods in alabaster format. This allows additional
configurations and customizations to the export or import process. It is
thus for example possible to specify the path to the original MS data files
for on-disk MS representations such as the Spectra::MsBackendMzR which
enables to import a stored object even if either the object or the original
MS data files have been moved to a different directory or file system.
In order to enable alabaster-based import/export, the respective methods have to be implemented for the class. See the package vignette for examples and details.
AlabasterParam(path = tempdir())AlabasterParam(path = tempdir())
path |
|
Importantly, it is only possible to save one object in one directory. To overwrite an existing stored object in a folder, that folder has to be deleted beforehand.
For AlabasterParam(): an instance of AlabasterParam class. For
readObject() the exported object in the specified path (depending on
the type of object defined in the OBJECT file in the path. For
readMsObject() the exported data object, defined with the function's
first parameter, from the specified path. saveObject() and
saveMsObject() don't return anything.
Johannes Rainer, Philippine Louail
Other MS object export and import formats.:
PlainTextParam
## Create an AlabasterParam object a <- AlabasterParam(path = tempdir()) a ## See the package vignette for example implemetations and usage.## Create an AlabasterParam object a <- AlabasterParam(path = tempdir()) a ## See the package vignette for example implemetations and usage.
The saveMsObject() and readMsObject() methods with the PlainTextParam
option enable users to save/load different type of mass spectrometry (MS)
object as a collections of plain text files in/from a specified folder.
This folder, defined with the path parameter, will be created by the
saveMsObject() function. Writing data to a folder that contains already
exported data will result in an error.
For PlainTextParam all data is expected to be exported to plain text files,
where possible as tabulator delimited text files.
To support writing/reading with PlainTextParam, the saveMsData() and
readMsData() methods have to be implemented for the respective class.
See the package vignette for example implementations and details.
PlainTextParam(path = tempdir())PlainTextParam(path = tempdir())
path |
For |
For PlainTextParam(): a PlainTextParam class. saveMsObject()
does not return anything but saves the object to collections of different
plain text files to a folder. The readMsObject() method returns the
restored data as an instance of the class specified with parameter object.
Philippine Louail, Johannes Rainer
Other MS object export and import formats.:
AlabasterParam
## Create a PlainTextParam object p <- PlainTextParam() p ## For example implementations and details see the package vignette## Create a PlainTextParam object p <- PlainTextParam() p ## For example implementations and details see the package vignette
The saveMsObject() and readMsObject() methods allow serializing and
restoring/importing mass spectrometry (MS) data (or result) objects to and
from language agnostic file formats. The type and configuration of the file
format is defined by the second argument to the method, param.
saveMsObject(object, param): saves the MS data object object to file(s)
in a format defined by param.
readMsObject(object, param): object defines the type of MS object that
should be returned by the function and param the format and file name(s)
from which the data should be restored/imported.
Examples implementations of these methods are presented in the package vignette.
saveMsObject(object, param, ...) readMsObject(object, param, ...)saveMsObject(object, param, ...) readMsObject(object, param, ...)
object |
for |
param |
an object defining and (eventually configuring) the file format and file name or directory to/from which the data object should be exported/imported. |
... |
additional optional arguments. See documentation of respective method for more information. |
saveMsObject() has no return value, readMsObject is expected
to return an instance of the class defined with object.
Philippine Louail, Johannes Rainer, Laurent Gatto