readMsp: Reading MSP files

View source: R/functions-msp.R

readMspR Documentation

Reading MSP files

Description

The readMsp() function imports the data from a file in MGF format reading all specified fields and returning the data as a DataFrame().

Format constraints for MSP files:

  • Comment lines are expected to start with a ⁠#⁠.

  • Multiple spectra within the same MSP file are separated by an empty line.

  • The first n lines of a spectrum entry represent metadata.

  • Metadata is provided as "name: value" pairs (i.e. name and value separated by a ":").

  • One line per mass peak, with values separated by a whitespace or tabulator.

  • Each line is expected to contain at least the m/z and intensity values (in that order) of a peak. Additional values are currently ignored.

Usage

readMsp(
  f,
  msLevel = 2L,
  mapping = spectraVariableMapping(MsBackendMsp()),
  BPPARAM = SerialParam(),
  ...
)

Arguments

f

character(1) with the path to an MSP file.

msLevel

numeric(1) with the MS level. Default is 2. This value will be reported as the spectra's MS level unless the source MSP file defines the MS level.

mapping

named character vector to rename MSP fields to spectra variables (see spectraVariableMapping()). This allows to correctly import also custom fields or data from files with different MSP flavors.

BPPARAM

parallel processing setup. See bpparam() for more details.

...

Additional parameters, currently ignored.

Value

A DataFrame with each row containing the data from one spectrum in the MSP file. m/z and intensity values are available in columns "mz" and "intensity" in a list representation.

Author(s)

Laurent Gatto, Steffen Neumann, Johannes Rainer

Examples


f <- system.file("extdata", "minimona.msp", package = "MsBackendMsp")

readMsp(f)

rformassspectrometry/MsBackendMsp documentation built on April 11, 2024, 7:12 p.m.