copyWriteMSData {mzR} | R Documentation

## Write MS spectrum data to a MS file copying metadata from the originating file

### Description

Copy general information from the originating MS file and write this, along with the provided spectra data, to a new file. The expected workflow is the following: data is first loaded from an MS file, e.g. using `peaks` and `header` methods, processed in R and then saved again to an MS file providing the (eventually) manipulated spectra and header data with arguments `header` and `data`.

### Usage

      copyWriteMSData(object, file, original_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.
`original_file` | `character(1)` with the name of the original file from which the spectrum data was first read.
`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.

### Note

`copyWriteMSData` supports at present copying data from `mzXML` and `mzML` and exporting to `mzML`. Copying and exporting to `mzXML` can fail for some input files.

The intention of this function is to copy data from an existing file and save it along with eventually modified data to a new file. To write new MS data files use the `writeMSData` function instead.

### Author(s)

Johannes Rainer

### See Also

`writeMSData` for a function to save MS data to a new mzML or mzXML 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
    })

    ## Copy metadata and additional information from the originating file
    ## and save it, along with the modified data, to a new mzML file.
    out_file <- tempfile()
    copyWriteMSData(pks, file = out_file, original_file = fl,
        header = hdr)

[Package mzR version 2.14.0 Index]