This function reads MGF files and extracts the relevant MS2 spectra information. Duplicated peaks and noise can be optionally removed.

read_mgf(file)

Arguments

file

A character vector specifying the path(s) to the MGF file(s).

Value

A list containing processed MS2 spectra information for each provided MGF file. Each element of the list contains two components:

  • info: A named numeric vector containing the m/z and retention time of the precursor ion.

  • spec: A matrix where each row represents a fragment ion peak, with columns for m/z and intensity values.

Empty spectra are removed from the output.

Examples

# Assuming 'sample.mgf' is the path to your MGF file.
# mgf_data <- read_mgf('sample.mgf')