R/53_ms2_spectra_matching_scores.R
match_ms2_fragments.Rd
This function matches MS2 fragments between an experimental spectrum and a library spectrum based on m/z values, using a specified mass tolerance (ppm). It returns a matrix of matched fragments, including their m/z values and intensities.
match_ms2_fragments(
experimental.spectrum,
library.spectrum,
ms2.match.ppm = 30,
mz.ppm.thr = 400,
direction = c("reverse", "forward"),
remove.noise = TRUE
)
A data frame representing the experimental spectrum, with columns `mz` for mass-to-charge ratios and `intensity` for corresponding intensities.
A data frame representing the library spectrum, with columns `mz` for mass-to-charge ratios and `intensity` for corresponding intensities.
Numeric. The mass tolerance in parts per million (ppm) for matching MS2 fragments. Default is 30.
Numeric. A threshold for mass-to-charge ratio (m/z) to use in ppm calculation. Default is 400.
A data frame with matched MS2 fragments, containing the following columns:
The index of the fragment in the library spectrum.
The index of the matched fragment in the experimental spectrum.
The m/z value of the fragment in the library spectrum.
The intensity of the fragment in the library spectrum.
The m/z value of the matched fragment in the experimental spectrum.
The intensity of the matched fragment in the experimental spectrum.
The function first removes noisy fragments from both the experimental and library spectra based on the provided mass tolerance (ppm). It then performs matching by comparing the m/z values of the fragments. If multiple experimental fragments match a library fragment, the one with the highest intensity is selected. Any unmatched fragments are added with NA values for the respective library or experimental fragment.