Create a S4 Spectra object in R Environment from .ms
files located in a specified folder.
Files must be in .ms
format. The first three lines must be 1) compound name, 2) precursor mass, and 3) collision energy.
Current version excludes files that contain adduct information. In this case, change fragment information from 1:3 to 1:4 (line 23-24) to parse mz and intensity information correctly.
Spectra objects can then be compared with MassBank records using the matchSpectra
(MetaboAnnotation) or compareSpectra
(MsCoreUtils) functions from their respective packages.
library(tidyverse)
library(Spectra)
msToSpectra(folder = "<path to .ms files>")
Path to folder containing one or more .ms
files.
Returns a S4 Spectra object including:
A character of the sample ID given in the .ms
file.
An integer of the precursor ion mass to charge ratio (assuming charge = +1).
An integer of the collision energy.
A list of mass to charge ratios given in the MS2 mass spectrum.
A list of intensities for each m/z ion present in mass spectrum.
A list of intensities, relative to the highest MS2 peak, out of 1000.
Drew Szabo
GitHub: drewszabo
ORCID: 0000-0002-0089-9218
©️ KruveLab 2022. Stockholm University, Sweden 114 18.