Some times we only want to match one peak. We can use identify_single_peak() function to identify single peak.

library(metID)
#>                 _    _____  ___ 
#>  _ __ ___   ___| |_  \_   \/   \
#> | '_ ` _ \ / _ \ __|  / /\/ /\ /
#> | | | | | |  __/ |_/\/ /_/ /_// 
#> |_| |_| |_|\___|\__\____/___,'  
#> 
#> metID,
#> More information can be found at https://jaspershen.github.io/metID/
#> If you use metID in you publication, please cite this publication:
#> Metabolic reaction network-based recursive metabolite annotation for untargeted metabolomics.
#> Authors: Xiaotao Shen (shenxt1990@163.com)
#> Maintainer: Xiaotao Shen.
#> Version 0.4.1 (2020702)
library(tidyverse)
#> ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
#> ✓ ggplot2 3.3.2.9000     ✓ purrr   0.3.4     
#> ✓ tibble  3.0.1          ✓ dplyr   0.8.5     
#> ✓ tidyr   1.0.2          ✓ stringr 1.4.0     
#> ✓ readr   1.3.1          ✓ forcats 0.5.0
#> ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()

Peak information

We need the m/z, rt and MS2 information. MS2 must be a matrix with two columns: mz and intensity.

mz <- 472.3032
rt <- 772.906
ms2 <- data.frame(
  mz = c(81.38455,82.19755,85.02840,86.5934,86.98958,89.48135,90.70250,
         93.03886, 102.09140, 103.03903, 116.01658, 127.98412,
         134.06819, 152.46967, 162.02180, 162.05521, 162.11261),
  intensity = c(1396.341,1488.730,15473.604, 1740.842,2158.014,1351.686,
                1547.099,1325.864,22441.047,76217.016,17809.395,
                1439.743, 1729.786, 1543.765, 2228.743,
                3508.225, 529120.000),
  stringsAsFactors = FALSE
)
ms2 %>% head()
#>         mz intensity
#> 1 81.38455  1396.341
#> 2 82.19755  1488.730
#> 3 85.02840 15473.604
#> 4 86.59340  1740.842
#> 5 86.98958  2158.014
#> 6 89.48135  1351.686

Run identify_single_peak() function

Load database

First we load the database from metID package and then put them in a example folder.

##create a folder named as example
path <- file.path(".", "example")
dir.create(path = path, showWarnings = FALSE)

##get database from metID
database <- system.file("ms2_database", package = "metID")

file.copy(from = file.path(database, "msDatabase_rplc0.0.2"),
          to = path, overwrite = TRUE, recursive = TRUE)
#> [1] TRUE

Now in your ./example, there are one file, namely msDatabase_rplc_0.0.2.

annotation_result <- 
  identify_single_peak(ms1.mz = mz, 
                       ms1.rt = rt, 
                       ms2 = ms2, 
                       ms1.match.ppm = 15, 
                       rt.match.tol = 30,
                       ms2.match.tol = 0.5, 
                       database = "msDatabase_rplc0.0.2",
                       path = path)
#> Use all CE values.
#> 
#> Identifing metabolites with MS/MS database...
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
#> 
#> All done.

annotation_result is a metIdentifyClass object, so you can use all the functions for it to process.