This is a wrapper function that executes the whole workflow with 2 inputs: ms2_files and optional features table.

lipID(ms2_files, libs, features = NULL, ppm_tol = 30,
  intensity_cutoff = 1000, kmd_cutoff = 0.2, mz_window = 1,
  rt_window = 2, collapse = TRUE, odd_chain = FALSE,
  chain_modifs = c("all", "only", "none"), partial_match_cutoff = 1)

Arguments

ms2_files

a character vector of file names or directory containing ms2 files

libs

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

features

CSV file with the first two columns corresponding to m/z and RT. Optional.

ppm_tol

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

intensity_cutoff

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

kmd_cutoff

Maximum tolerated error between the number of double bonds in a matched lipid and the expected number, as caculated from Referenced Kendrick Mass Defect.

mz_window

M/Z window for merging MS2 data with MS1 features. Ignored if features is NULL.

rt_window

Retention time window for merging MS2 data with MS1 features. Ignored if features is NULL.

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.

partial_match_cutoff

Numeric value between 0-1. Allows molecules that satisfied some, but not all of the rules to be retained. Default is 1, returning molecules with 100% match. Set to 0 to include molecules that are MS1 matched as well (i.e no rules are net, only the precursor).

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.

If features table is provided, it is merged with the above columns.

Examples

ms2_file <- system.file("extdata", "ms2file.ms2", package = "lipID") features_file <- system.file("extdata", "features.csv", package = "lipID") libs <- get_libs() annotated <- lipID(ms2_file, libs, features_file)
#> Joining, by = c("mz", "ms2_rt")
#> Joining, by = c("precursor", "ms2_rt")
#> Parsed with column specification: #> cols( #> mz = col_double(), #> rt = col_double(), #> Sample1 = col_double(), #> Sample2 = col_double(), #> Sample3 = col_double(), #> Sample4 = col_double(), #> Sample5 = col_double(), #> Sample6 = col_double() #> )
#> Joining, by = c("mz", "rt")
#> Joining, by = c("precursor", "ms2_rt")
#> Joining, by = "file"
head(annotated)
#> # A tibble: 6 x 33 #> mz rt name ms2_file precursor ms2_rt best_match partial_match confirmed #> <dbl> <dbl> <chr> <fct> <dbl> <dbl> <lgl> <dbl> <lgl> #> 1 747. 33.6 Plas… ms2file 747. 33.5 TRUE 1 TRUE #> 2 747. 33.6 Plas… ms2file 747. 33.5 FALSE 1 TRUE #> 3 809. 31.6 PC(3… ms2file 809. 31.5 TRUE 1 TRUE #> 4 783. 31.1 PC(1… ms2file 783. 31.1 TRUE 1 TRUE #> 5 783. 30.7 PC(1… ms2file 783. 31.1 TRUE 1 TRUE #> 6 783. 30.3 PC(1… ms2file 783. 31.1 TRUE 1 TRUE #> # … with 24 more variables: ions_matched <chr>, fragments_intensity <dbl>, #> # Sample1 <dbl>, Sample2 <dbl>, Sample3 <dbl>, Sample4 <dbl>, Sample5 <dbl>, #> # Sample6 <dbl>, nearest_ms2 <lgl>, 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>, cs_residual <dbl>, cs_matched <lgl>