annotate
is the MS2ID function that annotates MS/MS query spectra.
Every query spectrum is compared with a reference library
(MS2ID object) using as criteria different distance metrics;
the function returns query and reference spectra (and their compounds) that
beat a determined threshold.
annotate( QRYdata, QRYmsLevel = 2L, MS2ID, metrics = "cosine", metricsThresh = 0.8, metricFUN = NULL, metricFUNThresh = NULL, massErrMs1 = 5, massErrMsn = 20, noiseThresh = 0.01, cmnPrecMass = FALSE, cmnNeutralMass = TRUE, cmnFrags = c(2, 5), cmnPolarity = TRUE, predicted = NULL, consens = TRUE, consCos = 0.8, consComm = 2/3, ... )
QRYdata | Query spectra. |
---|---|
QRYmsLevel | integer(1). This argument filters the query spectra loaded from mzML files according their msLevel. |
MS2ID | MS2ID object with the in-house database to use in the annotation. |
metrics | character(n) that defines which metrics use to compare query
and reference spectra ( |
metricsThresh | numeric(n) defining the n threshold values of the n metrics. A reference spectrum is considered a hit and listed in the return object when at least one of the metrics fulfills its threshold; note that to fulfill a threshold value has a different meaning depending on the metric: topsoe and squared_chord metrics return a lower number when the spectra are more similar so, unlike the rest, a hit will occur when the returned value is lower than its threshold. Recommended values to start with are cosine=0.8, topsoe=0.6, fidelity=0.6 and squared_chord=0.8. |
metricFUN | function(1) defined by the user to be used as metric. This function must accept a two-row matrix as a parameter; each row must contain the intensity of a spectrum, and each column must refer to the same m/z value (considering the massErrMsn parameter as the mass error). Finally, the function must return a numeric(1). See example. |
metricFUNThresh | numeric(1) with the threshold value of the metric
defined by the |
massErrMs1 | numeric(1). Mass error to consider in operations with first spectrometer measures (MS1), e.g. grouping spectra according its precursor mass (in consensus formation) or evaluating precursor and neutral masses similarities (in reference spectra prefiltering), |
massErrMsn | numeric(1) Mass error to consider in operations with non-first spectrometer measures (typically MS2). e.g. matching fragments, for consensus formation or distance similarity measures. |
noiseThresh | numeric(1) defining the threshold used in the noise filtering of the query spectra. It is expressed as % intensity relative to base peak. e.g. noiseThresh=0.01 eliminates peaks with an intensity of less than 1% of the base peak. |
cmnPrecMass | -Reference spectra filter- Boolean(1) that limits the reference spectra to those that have the precursor mass of the query spectrum. |
cmnNeutralMass | -Reference spectra filter- Boolean filtering the reference spectra to those with a neutral mass plausible with the query precursor (considering all possible adducts). |
cmnFrags | -Reference spectra filter- vector with two integers (m, n) limiting the reference spectra so that both query and reference spectra have at least m peaks in common among their top n most intense peaks. |
cmnPolarity | -Reference spectra filter- Boolean(1) that limits the reference spectra to those with the same polarity than the query spectrum. |
predicted | -Reference spectra filter- Boolean(1) filtering the reference spectra according its experimental nature (in-silico or predicted). A NULL value does not apply filter. |
consens | boolean(1) indicating if the query spectra must be consensued or not. |
consCos | numeric(1) with the minimum cosine similarity two contiguous spectra must have to consens a spectrum. |
consComm | numeric(1) During the consensus formation, minimum presence of m/z in the query spectra in order to be part of the final consensus spectrum. |
... | other arguments passed to function |
an Annot object with the results of the annotation
Annot class and the post annotation tools
MS2IDgui
and export2xlsx
.
Josep M. Badia josepmaria.badia@urv.cat
## LOAD MS2ID LIBRARY --- ## Decompress the MS2ID library that comes with MS2ID MS2IDzipFile <- system.file("extdata/MS2IDLibrary.zip", package = "MS2ID", mustWork = TRUE) library(utils) MS2IDFolder <- dirname(unzip(MS2IDzipFile, exdir = tempdir()))[1] ## SELECT QUERY SPECTRA --- ## Decompress the query mzML files that come with MS2ID queryFile <- system.file("extdata/QRYspectra.zip", package = "MS2ID", mustWork = TRUE) queryFolder <- file.path(tempdir(), "QRYspectra") library(utils) unzip(queryFile, exdir = queryFolder) ## ANNOTATE --- ## 3.1 Simple annotation library(MS2ID) MS2IDlib <- MS2ID(MS2IDFolder) annotResult <- annotate(QRYdata = queryFolder, MS2ID = MS2IDlib)#>#>#>#>## 3.2 Annotation with different metrics ## external function to annotate foo <- function(finalMatrix){ vector1 <- finalMatrix[1, ] vector2 <- finalMatrix[2, ] CosplusOne <- 1 + suppressMessages( philentropy::distance(rbind(vector1, vector2), method = "cosine") ) names(CosplusOne) <- "CosplusOne" return(CosplusOne) } annotResult <- annotate( QRYdata = queryFolder, MS2ID = MS2IDlib, metrics = c("cosine", "fidelity", "topsoe"), metricsThresh = c(0.8, 0.6, 0.6), metricFUN = foo, metricFUNThresh = 1.8)#>#>#>#>