Rule-based matching of lipid molecules in the provided libraries libs using MS2 data (fragments).

match_ms2(ms2, libs, ppm_tol = 30, intensity_cutoff = 1000,
  collapse = TRUE, odd_chain = FALSE, chain_modifs = c("all", "only",
  "none"))

Arguments

ms2

MS2 data frame. Should be the result of read_ms2.

libs

Which libraries to match against. Should be the output of [get_lib] or [create_lib]

ppm_tol

Mass error tolerance between acquired fragments and library. Default tolerance is 30 ppm.

intensity_cutoff

Minimum intensity value for fragments to be taken into account when matching. Default is 1000

collapse

Whether to collapse ambiguous molecules if they have the same sum composition. TRUE by default.

odd_chain

Whether to include molecules with odd chain fatty acids.

chain_modifs

Whether to include / exclude molecules with modified chain fatty acids. FALSE by default, since odd chains are unlikely in mammals.

Value

A data frame with these columns:

  • ms2_file, precursor, ms2_rt File, precursor M/Z, precursor RT

  • name Name of the matching molecules

  • partial_match Numeric value between 0-1, indicating the percentage of rules satisfied. 1 indicates matching all required fragments and at least one optional fragment. 0 indicates the molecule was matched based on MS1 only.

  • confirmed Whether all matching rules were satisfied.

This returned values contain all molecules that have a matching precursor regardless of whether the rules are met or not. If you want only molecules that met the rules, filter the dataframe with confirmed == TRUE.

Examples

ms2_file <- system.file("extdata", "ms2file.ms2", package = "lipID") ms2_data <- read_ms2(ms2_file) libs <- get_libs() confirmed_molecules <- match_ms2(ms2_data, libs)
#> Joining, by = c("mz", "ms2_rt")
#> Joining, by = c("precursor", "ms2_rt")
head(confirmed_molecules)
#> # A tibble: 6 x 22 #> ms2_file precursor ms2_rt name confirmed ions_matched fragments_inten… #> <fct> <dbl> <dbl> <chr> <lgl> <chr> <dbl> #> 1 ms2file 761. 32.3 PC(1… TRUE [M+H]+;MH-P… 28804189. #> 2 ms2file 735. 31.8 PC(1… TRUE [M+H]+;MH-P… 25209814. #> 3 ms2file 733. 30.2 PC(3… TRUE [M+H]+;MH-P… 24422286. #> 4 ms2file 787. 32.8 PC(1… TRUE [M+H]+;MH-P… 24075173. #> 5 ms2file 707. 29.5 PC(1… TRUE [M+H]+;MH-P… 22843936. #> 6 ms2file 761. 32.2 PC(1… TRUE [M+H]+;MH-P… 22693128. #> # … with 15 more variables: partial_match <dbl>, file <chr>, class_name <chr>, #> # sum_composition <chr>, odd_chain <lgl>, modifs <chr>, total_cl <dbl>, #> # total_cs <dbl>, n_and <int>, n_or <int>, n_and_true <int>, n_or_true <int>, #> # and_cols <lgl>, or_cols <lgl>, best_match <lgl>
# Get only the molecules that satisfied all the rules. confirmed_molecules %>% dplyr::filter(confirmed)
#> # A tibble: 122 x 22 #> ms2_file precursor ms2_rt name confirmed ions_matched fragments_inten… #> <fct> <dbl> <dbl> <chr> <lgl> <chr> <dbl> #> 1 ms2file 761. 32.3 PC(1… TRUE [M+H]+;MH-P… 28804189. #> 2 ms2file 735. 31.8 PC(1… TRUE [M+H]+;MH-P… 25209814. #> 3 ms2file 733. 30.2 PC(3… TRUE [M+H]+;MH-P… 24422286. #> 4 ms2file 787. 32.8 PC(1… TRUE [M+H]+;MH-P… 24075173. #> 5 ms2file 707. 29.5 PC(1… TRUE [M+H]+;MH-P… 22843936. #> 6 ms2file 761. 32.2 PC(1… TRUE [M+H]+;MH-P… 22693128. #> 7 ms2file 733. 30.2 PC(3… TRUE [M+H]+;MH-P… 19348695. #> 8 ms2file 763. 33.8 PC(1… TRUE [M+H]+;MH-P… 18853109. #> 9 ms2file 763. 33.8 PC(1… TRUE [M+H]+;MH-P… 18797276. #> 10 ms2file 787. 32.8 PC(1… TRUE [M+H]+;MH-P… 18405277. #> # … with 112 more rows, and 15 more variables: partial_match <dbl>, file <chr>, #> # class_name <chr>, sum_composition <chr>, odd_chain <lgl>, modifs <chr>, #> # total_cl <dbl>, total_cs <dbl>, n_and <int>, n_or <int>, n_and_true <int>, #> # n_or_true <int>, and_cols <lgl>, or_cols <lgl>, best_match <lgl>