This function reads MGF files and extracts the relevant MS2 spectra information. Duplicated peaks and noise can be optionally removed.
read_mgf(file)
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.
# Locate the example mgf file in the installed package
file_path <- system.file("extdata", "example.mgf", package = "masstools")
# Then use it in your function
result <- read_mgf(file_path)
#> Reading mgf data...
#> Warning: incomplete final line found on 'D:/R-4.4.3/library/masstools/extdata/example.mgf'