R/spectra_functions.R
get_spectra_match_score.Rd
This function computes the similarity score between two mass spectra considering an option to filter out lower fragment intensities.
get_spectra_match_score(
exp.spectrum,
lib.spectrum,
ppm.tol = 30,
mz.ppm.thr = 400,
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. This data frame should contain columns for 'mz' and 'intensity'.
A data frame representing the library spectrum. This data frame should contain columns for 'mz' and 'intensity'.
A numeric value indicating the ppm tolerance.
A numeric value for m/z threshold for ppm calculation.
A numeric value for weight of fraction component in score.
A numeric value for weight of forward dot product component in score.
A numeric value for weight of reverse dot product component in score.
A numeric value specifying the intensity cutoff for filtering out fragments in the spectra. Default is 0, which means no fragments are filtered out based on intensity.
A numeric value representing the similarity score between
exp.spectrum
and lib.spectrum
.
The function scales the intensities of both spectra to a range of 0 to 1, identifies matching peaks, and computes a weighted similarity score using fraction of matching peaks and dot products. Additionally, fragments below the specified intensity cutoff can be removed from the spectra before matching.
exp.spectrum <- data.frame(mz = 1:10, intensity = 1:10)
lib.spectrum <- data.frame(mz = 1:10, intensity = 1:10)
get_spectra_match_score(exp.spectrum, lib.spectrum)
#> [1] 1