PlainTextParam: Store contents of 'MsExperiment' and 'XcmsExperiment' objects...

View source: R/PlainTextParam.R

PlainTextParamR Documentation

Store contents of 'MsExperiment' and 'XcmsExperiment' objects as plain text files

Description

The 'PlainTextParam' class and method enable users to save 'MsExperiment' or 'XcmsExperiment' objects as collections of plain text files in a specified folder. Note that, while for all xcms results within the 'XcmsExperiment' can and will be exported, the full raw MS data (of the object's 'Spectra' object) will currently not be exported in plain text format. For 'Spectra' using the [MsBackendMzR()] backend, the names of the raw data files will however be exported (which enables to *restore* the full 'Spectra' respectively 'MsExperiment' objects).

For an 'MsExperiment' object, the exported files include:

- The [sampleData()] stored as a text file named *sample_data.txt*.

- The [fileNames()] of the *Spectra* object stored in a tabular format in a text file named *spectra_files.txt*.The file names will only be exported if the 'Spectra' object uses a [MsBackendMzR()] backend. For other backends no information on raw spectra data is currently exported with 'PlainTextParam'.

- Processing queue of the 'Spectra' object, ensuring that any spectra data modifications are retained. It is stored in a 'json' file named *spectra_processing_queue.json*.

For an 'XcmsExperiment' object, the exported files are the same as those for an 'MsExperiment' object, with the addition of the following:

- The [processHistory()] information of the object, stored in a 'json' file named *process_history.json*.

- The chromatographic peak information obtained with [chromPeaks()] and [chromPeaksData()], stored in tabular format in the text files *chrom_peaks.txt* and *chrom_peak_data.txt* respectively.

- The retention time information obtained with [adjustedRtime()] stored in the text file named *rtime_adjusted.txt*.

- The [featureDefinitions()] stored in a text file named *feature_definitions.txt*. Additionally, a second file named *feature_peak_index.txt* is generated to connect the features' definitions with their names.

This 'param' class and method are part of the possible dispatch of the generic function 'storeResults'. The folder will be created by calling 'storeResults'. If the folder already exists, previous exports in that folder might get overwritten.

Usage

PlainTextParam(path = tempdir())

## S4 method for signature 'MsExperiment,PlainTextParam'
storeResults(object, param)

## S4 method for signature 'XcmsExperiment,PlainTextParam'
storeResults(object, param)

Arguments

path

for 'PlainTextParam' 'character(1)', defining where the files are going to be stored. The default will be 'tempdir()'.

object

MsExperiment or XcmsExperiment The data object that needs to be saved.

param

The parameter object selecting and configuring the format for saving. It can be one of the following classes: RDataParam, PlainTextParam, or MzTabMParam.

Value

for 'PlainTextParam': a 'PlainTextParam' class. 'storeResults' does not return anything but saves the object to collections of different plain text files to a folder.

Author(s)

Philippine Louail, Johannes Rainer.

See Also

Other xcms result export formats.: RDataParam

Examples

## Load test data set of class `MsExperiment`
library(MsExperiment)
fls <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)
pd <- data.frame(file = basename(fls),
                 sample = c("POOL_1", "POOL_2"),
                 injection_index = c(1, 19),
                group = "POOL")
rownames(pd) <- c("1", "2")
mse <- readMsExperiment(fls, sampleData = pd)

## Define param
pth = file.path(tempdir(), "test")
param <- PlainTextParam(path = pth)

## Save as a collection of plain text files
storeResults(object = mse, param = param)

## Load a test data set with detected peaks, of class `XcmsExperiment`
faahko_sub <- loadXcmsData("faahko_sub2")

## Define param
pth = file.path(tempdir(), "test")
param <- PlainTextParam(path = pth)

## Save as a collection of plain text files
storeResults(object = faahko_sub, param = param)


sneumann/xcms documentation built on April 26, 2024, 3:05 a.m.