writeMSData {mzR} | R Documentation

## Write MS spectrum data to an MS file

### Description

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

### Usage

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

### Arguments

`object` | `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.
`file` | `character(1)` defining the name of the file.
`header` | `data.frame` with the header data for the spectra. Has to be in the format as the `data.frame` returned by the `header` method.
`backend` | `character(1)` defining the backend that should be used for writing. Currently only `"pwiz"` backend is supported.
`outformat` | `character(1)` the format of the output file. One of `"mzml"` or `"mzxml"`.
`rtime_seconds` | `logical(1)` whether the retention time is provided in seconds or minutes (defaults to `TRUE`).
`software_processing` | `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.

### Author(s)

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.

### Examples

    ## Open a MS file and read the spectrum and header information
    library(msdata)
    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
        z
    })

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

[Package mzR version 2.26.1 Index]