msp: Functions to handle msp-type objects (GC-MS)

mspR Documentation

Functions to handle msp-type objects (GC-MS)


Functions to construct, read, write and filter so-called msp objects, collections of spectra with additional information. This other information is of free format, but typically contains fields like “Name”, “CAS”, “ChemspiderID”, and “rt”.


read.msp(file, = FALSE,
         org.set = c("C", "H", "D", "N", "O", "P", "S"), noNumbers = NULL)
filter.msp(msp, rtrange = NULL, mzrange = NULL, minintens = 0, minPeaks = 0)
write.msp(msp, file, newFile = TRUE)
xset2msp(xsetList, settings)
to.msp(object, file = NULL, settings = NULL, ndigit = 0, 
       minfeat, minintens, intensity = c("maxo", "into"),
       secs2mins = TRUE)
SearchNIST(mspfile=NULL, savepath=NULL)



a list of two-column or three-column numerical matrices. Two-column matrices only contain mz and intensity information, three-column matrices have a third column that gives retention times for the individual peaks.

a nested list containing all other slots that should be included in the msp object. The length of this list should be equal to the number of spectra in the first argument.


name of input or output file containing data in msp format. If NULL in function to.msp, the input object is returned as an msp object. If non-null, the information will be written to the file with this name.

logical: if TRUE this will skip all entries that have non-organical elements in the “Formula” field.


List of elements to be considered as organic.


Optional argument, indicating which fields are not to be converted into numeric entries. If not given, this currently defaults to the following fields: Name, CAS, stdFile, date, validated, ChemspiderID, SMILES, InChI, Class, comment, csLinks.


msp object.

rtrange, mzrange, minfeat, minintens, minPeaks

restrictions to what constitutes genuine pseudospectra in terms of minimal numbers of features, minimum feature intensity, and the intensity measure used (peak area or peak height).


the measure to use for the intensity of a peak: either the peak height ("maxo") or area ("into").


number of digits for the mz values - use 0 for nominal mass data.


logical: if TRUE starts a new file, otherwise appends.


a list of xcmsSet objects.


list containing settings.


either an object of class "xsAnnotate" or a peaktable containing mz, rt and I information. Function to.msp will convert this object into a list that can be written as an msp file.


logical: if TRUE converts retention times to minutes (otherwise seconds).


a msp file generated by to.msp function


Path to the directory were NIST MSsearch program results will be saved


Even though the msp format handled by these functions is quite flexible, there are a couple of requirements that are not always satisfied by msp files generated by other software, the most important one being that one line may only contain one keyword. If more than one keyword is present, the second will likely not be read. Furthermore, the current implementation assumes that peaks in pseudospectra are represented in the form mz1, I1; mz2, I2;, etcetera - in other cases these are in brackets. To solve such issues, the most easy fix for the moment is to edit the msp file and change things globally.

Other issues may arise with the keywords. While read.msp will be able to read msp files with non-standard keywords, the metaMS package expects at least the following list to be present (case-sensitive): “Name”, “validated”, “CAS”, “rt”, “monoMW”, and “Class”. The final keyword is always “Num Peaks”, and should be followed by the list of mz-I combinations.


Most of the functions here create msp files.


Ron Wehrens


## Not run: 
write.msp(DB, file = "huhn.msp")
DB2 <- read.msp("huhn.msp")

## End(Not run)

rwehrens/metaMS documentation built on Feb. 27, 2023, 5:13 a.m.