Match Ions by M/Z and Retention Time
match_mz_rt.RdMatches two lists of ions based on mass-to-charge ratio (m/z) and retention time (RT). Returns all matched pairs including multiple matches, with error values for each match.
Arguments
- mz1
Numeric vector of m/z values for the first ion list.
- rt1
Numeric vector of retention times for the first ion list. Default is NA values of same length as mz1.
- mz2
Numeric vector of m/z values for the second ion list.
- rt2
Numeric vector of retention times for the second ion list. Default is NA values of same length as mz2.
- mz.ppm
Numeric tolerance for m/z matching in parts per million (ppm). Default is 10.
- rt.tol
Numeric tolerance for retention time matching. Default is Inf (no RT filtering).
Value
A data.table with columns: ion1 (index in first list),
ion2 (index in second list), mz.error (relative m/z error),
and rt.error (absolute RT difference).
Details
Matching is done in two steps for efficiency:
match_mz_foverlapsfinds m/z candidate pairs withinmz.ppmusingdata.table::foverlaps()on ppm-expanded intervals (denominatormz1).In
data.table, absolute RT differences are computed and rows withrt.error < rt.tol(orNART error) are kept.
mz.error is the relative m/z error abs(mz1 - mz2) / mz1
(i.e. abs(mz.ppm) / 1e6 from match_mz_foverlaps), not ppm units.
This function returns all surviving pairs; callers decide how to pick one
match per ion (e.g. closest RT then m/z in get_Spectra_ms2_feature_id).
See also
match_mz_foverlaps, match_mz,
get_Spectra_ms2_feature_id