writeMSData: Write MS spectrum data to an MS file

writeMSDataR Documentation

Write MS spectrum data to an MS file


writeMSData exports the MS spectrum data provided with parameters header and data to an MS file in mzML or mzXML format.


## S4 method for signature 'list,character'
writeMSData(object, file, header,
    backend = "pwiz", outformat = "mzml", rtime_seconds = TRUE,



list containing for each spectrum one matrix with columns mz (first column) and intensity (second column). See also peaks for the method that reads such data from an MS file.


character(1) defining the name of the file.


data.frame with the header data for the spectra. Has to be in the format as the data.frame returned by the header method.


character(1) defining the backend that should be used for writing. Currently only "pwiz" backend is supported.


character(1) the format of the output file. One of "mzml" or "mzxml".


logical(1) whether the retention time is provided in seconds or minutes (defaults to TRUE).


list of character vectors (or single character vector). Each character vector providing information about the software that was used to process the data with optional additional description of processing steps. The length of each character vector has to be >= 3: the first element being the name of the software, the second string its version and the third element the MS CV ID of the software (or "MS:-1" if not known). All additional elements are optional and represent the MS CV ID of each processing step performed with the software.


Johannes Rainer

See Also

copyWriteMSData for a function to copy general information from a MS data file and writing eventually modified MS data from that originating file.


## Open a MS file and read the spectrum and header information
fl <- system.file("threonine", "threonine_i2_e35_pH_tree.mzXML",
    package = "msdata")
ms_fl <- openMSfile(fl, backend = "pwiz")

## Get the spectra
pks <- spectra(ms_fl)
## Get the header
hdr <- header(ms_fl)

## Modify the spectrum data adding 100 to each intensity.
pks <- lapply(pks, function(z) {
    z[, 2] <- z[, 2] + 100

## Write the data to a mzML file.
out_file <- tempfile()
writeMSData(object = pks, file = out_file, header = hdr)

sneumann/mzR documentation built on June 13, 2022, 3:10 p.m.