R/53_ms2_spectra_matching_scores.R
calculate_ms2_matching_score.Rd
This function computes the matching score between experimental and library MS2 spectra using the dot product method. The function allows for fragment matching based on mass-to-charge ratio (m/z) tolerance and intensity comparison, and calculates the score based on forward and reverse dot product and the fraction of matched fragments.
calculate_ms2_matching_score(
experimental.spectrum,
library.spectrum,
ms2.match.ppm = 30,
mz.ppm.thr = 400,
method = c("dotproduct"),
fraction.weight = 0.2,
dp.forward.weight = 0.7,
dp.reverse.weight = 0.1,
remove_fragment_intensity_cutoff = 0
)
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. Threshold for m/z to use in ppm calculation. Default is 400.
Character. The method to calculate the matching score. Currently, only "dotproduct" is supported. Default is "dotproduct".
Numeric. The weight of the fraction of matched fragments in the overall score. Default is 0.2.
Numeric. The weight for the forward dot product score in the overall score. Default is 0.7.
Numeric. The weight for the reverse dot product score in the overall score. Default is 0.1.
Numeric. A cutoff value to remove low-intensity fragments from both experimental and library spectra. Default is 0.
A numeric value representing the MS2 matching score, which is a weighted combination of the forward dot product score, reverse dot product score, and the fraction of matched fragments.
The function normalizes the intensities of both the experimental and library spectra and filters out fragments below the specified intensity cutoff. It then calculates the matching score based on the dot product method. The forward dot product score is calculated using all matched fragments, while the reverse dot product score is computed using only the fragments that have non-zero intensity in the library spectrum.
experimental.spectrum <- data.frame(mz = 1:10, intensity = 1:10)
library.spectrum <- data.frame(mz = 1:10, intensity = 1:10)
get_spectra_match_score(experimental.spectrum, library.spectrum)
#> [1] 1