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

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
data("snyder_database_rplc0.0.3", package = "metid")
save(snyder_database_rplc0.0.3, file = file.path(path, "snyder_database_rplc0.0.3"))

Now in your ./example, there are one file, namely snyder_database_rplc0.0.3.

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 = "snyder_database_rplc0.0.3",
                       path = path)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%

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

Session information

sessionInfo()
#> R version 4.2.1 (2022-06-23)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur ... 10.16
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] tinytools_0.9.1    forcats_0.5.1.9000 stringr_1.4.0      dplyr_1.0.9       
#>  [5] purrr_0.3.4        readr_2.1.2        tidyr_1.2.0        tibble_3.1.7      
#>  [9] tidyverse_1.3.1    ggplot2_3.3.6      massdataset_1.0.5  magrittr_2.0.3    
#> [13] masstools_0.99.13  metid_1.2.16      
#> 
#> loaded via a namespace (and not attached):
#>   [1] backports_1.4.1             readxl_1.4.0               
#>   [3] circlize_0.4.15             systemfonts_1.0.4          
#>   [5] plyr_1.8.7                  lazyeval_0.2.2             
#>   [7] BiocParallel_1.30.3         listenv_0.8.0              
#>   [9] GenomeInfoDb_1.32.2         Rdisop_1.56.0              
#>  [11] digest_0.6.29               foreach_1.5.2              
#>  [13] yulab.utils_0.0.5           htmltools_0.5.2            
#>  [15] fansi_1.0.3                 memoise_2.0.1              
#>  [17] cluster_2.1.3               doParallel_1.0.17          
#>  [19] tzdb_0.3.0                  openxlsx_4.2.5             
#>  [21] limma_3.52.2                ComplexHeatmap_2.12.0      
#>  [23] globals_0.15.1              modelr_0.1.8               
#>  [25] matrixStats_0.62.0          pkgdown_2.0.5              
#>  [27] prettyunits_1.1.1           colorspace_2.0-3           
#>  [29] rvest_1.0.2                 haven_2.5.0                
#>  [31] textshaping_0.3.6           xfun_0.31                  
#>  [33] crayon_1.5.1                RCurl_1.98-1.7             
#>  [35] jsonlite_1.8.0              impute_1.70.0              
#>  [37] iterators_1.0.14            glue_1.6.2                 
#>  [39] gtable_0.3.0                zlibbioc_1.42.0            
#>  [41] XVector_0.36.0              GetoptLong_1.0.5           
#>  [43] DelayedArray_0.22.0         shape_1.4.6                
#>  [45] BiocGenerics_0.42.0         scales_1.2.0               
#>  [47] vsn_3.64.0                  DBI_1.1.3                  
#>  [49] Rcpp_1.0.8.3                mzR_2.30.0                 
#>  [51] viridisLite_0.4.0           progress_1.2.2             
#>  [53] clue_0.3-61                 gridGraphics_0.5-1         
#>  [55] preprocessCore_1.58.0       stats4_4.2.1               
#>  [57] MsCoreUtils_1.8.0           htmlwidgets_1.5.4          
#>  [59] httr_1.4.3                  RColorBrewer_1.1-3         
#>  [61] ellipsis_0.3.2              pkgconfig_2.0.3            
#>  [63] XML_3.99-0.10               dbplyr_2.2.1               
#>  [65] sass_0.4.1                  utf8_1.2.2                 
#>  [67] ggplotify_0.1.0             tidyselect_1.1.2           
#>  [69] rlang_1.0.3                 munsell_0.5.0              
#>  [71] cellranger_1.1.0            tools_4.2.1                
#>  [73] cachem_1.0.6                cli_3.3.0                  
#>  [75] generics_0.1.3              broom_1.0.0                
#>  [77] evaluate_0.15               fastmap_1.1.0              
#>  [79] mzID_1.34.0                 yaml_2.3.5                 
#>  [81] ragg_1.2.2                  knitr_1.39                 
#>  [83] fs_1.5.2                    zip_2.2.0                  
#>  [85] ncdf4_1.19                  pbapply_1.5-0              
#>  [87] future_1.26.1               xml2_1.3.3                 
#>  [89] compiler_4.2.1              rstudioapi_0.13            
#>  [91] plotly_4.10.0               png_0.1-7                  
#>  [93] affyio_1.66.0               reprex_2.0.1               
#>  [95] bslib_0.3.1                 stringi_1.7.6              
#>  [97] desc_1.4.1                  MSnbase_2.22.0             
#>  [99] lattice_0.20-45             ProtGenerics_1.28.0        
#> [101] Matrix_1.4-1                ggsci_2.9                  
#> [103] vctrs_0.4.1                 pillar_1.7.0               
#> [105] lifecycle_1.0.1             furrr_0.3.0                
#> [107] BiocManager_1.30.18         jquerylib_0.1.4            
#> [109] MALDIquant_1.21             GlobalOptions_0.1.2        
#> [111] data.table_1.14.2           bitops_1.0-7               
#> [113] GenomicRanges_1.48.0        R6_2.5.1                   
#> [115] pcaMethods_1.88.0           affy_1.74.0                
#> [117] IRanges_2.30.0              parallelly_1.32.0          
#> [119] codetools_0.2-18            MASS_7.3-57                
#> [121] assertthat_0.2.1            SummarizedExperiment_1.26.1
#> [123] rprojroot_2.0.3             rjson_0.2.21               
#> [125] withr_2.5.0                 S4Vectors_0.34.0           
#> [127] GenomeInfoDbData_1.2.8      parallel_4.2.1             
#> [129] hms_1.1.1                   grid_4.2.1                 
#> [131] rmarkdown_2.14              MatrixGenerics_1.8.1       
#> [133] lubridate_1.8.0             Biobase_2.56.0