This function matches MS2 spectra from experimental data against MS2 spectra in a database. It calculates MS2 matching scores for each compound in the database, and selects the best matches based on the provided matching parameters.
match_ms2_temp(
idx,
ms2.info,
pre_match_result,
spectra.data,
ms2.match.ppm = 30,
mz.ppm.thr = 400,
ms2.match.tol = 0.5,
candidate.num = 3,
fraction.weight = 0.3,
dp.forward.weight = 0.6,
dp.reverse.weight = 0.1,
remove_fragment_intensity_cutoff = 0,
masstplus_method_cutoff = 100,
...
)
Numeric. The index of the current MS2 spectrum in the `ms2.info` list.
A list of MS2 spectra, where each element is a matrix with two columns (`mz` and `intensity`).
A data frame containing the preliminary match results from MS1 or RT matching, including compound identifiers (`Lab.ID`).
A list of MS2 spectra from the database, where each element is a matrix with two columns (`mz` and `intensity`).
Numeric. Mass tolerance in parts per million (ppm) for MS2 peak matching. Default is 30.
Numeric. m/z threshold for ppm calculation. Default is 400.
Numeric. Score threshold for MS2 matches. Only matches with scores above this value are retained. Default is 0.5.
Numeric. The number of top candidate annotations to retain per MS2 spectrum. Default is 3.
Numeric. Weight for the fraction of matched fragments in the total MS2 score calculation. Default is 0.3.
Numeric. Weight for the forward dot product score in the total MS2 score calculation. Default is 0.6.
Numeric. Weight for the reverse dot product score in the total MS2 score calculation. Default is 0.1.
Numeric. Intensity cutoff to remove low-intensity MS2 fragments from matching. Default is 0.
Additional arguments to pass to internal functions.
A data frame containing the top candidate matches for the given MS2 spectrum. The output includes:
The database compound ID.
The collision energy used in the MS2 spectrum.
The matching score for the compound.
The ID of the experimental MS2 spectrum.
The function takes an MS2 spectrum from the experimental data and matches it against MS2 spectra in a reference database. It computes matching scores based on the provided mass tolerance (`ms2.match.ppm`), fragment matching weight parameters (`fraction.weight`, `dp.forward.weight`, `dp.reverse.weight`), and intensity cutoff. The best-matching spectra from the database are retained and returned as candidates.
If preliminary MS1/RT matches are provided (`pre_match_result`), the function only considers those compounds for MS2 matching. Otherwise, all compounds in the database are considered.