addRI: Add retention index information to an msp object

View source: R/addRI.R

addRIR Documentation

Add retention index information to an msp object


Given an msp object and the retention times and indices of a series of reference compounds, the function adds an RI field to every entry of the msp object. This will only be done if there is not already an RI field: existing information will not be overwritten.


addRI(mspobj, RIstandards, isMSP = TRUE)



An msp object.


A two-column matrix containing for the standards defining the RI scale both retention times and retention indices.


Logical: if TRUE, then the spectra are stored in slot pspectrum; otherwise the spectra are simply the list elements of DB - matrices with three columns.


An msp object, now also containing an RI slot.


If the retention time of a compound is outside the range of the RI standards, NA will be used as RI value.


Ron Wehrens


if (require(metaMSdata)) {
  manual.fname <- list.files(system.file("extdata", package = "metaMSdata"),
                             pattern = "msp", full.names = TRUE)
  manual <- read.msp(manual.fname)
  RIstandards <- cbind("rt" = c(1.54, 1.68, 1.99, 2.7, 4.36, 6.81, 9.43,
                                11.88, 14.17, 16.34, 18.39, 20.33, 22.18,
                                23.93, 25.5, 27.18, 28.72, 30.26, 31.75,
                                33.19, 34.58, 35.95),
                       "RI" = (6:27)*100)

  manualRI <- addRI(manual, RIstandards)

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