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
)

Arguments

exp.spectrum

A data frame representing the experimental spectrum. This data frame should contain columns for 'mz' and 'intensity'.

lib.spectrum

A data frame representing the library spectrum. This data frame should contain columns for 'mz' and 'intensity'.

ppm.tol

A numeric value indicating the ppm tolerance.

mz.ppm.thr

A numeric value for m/z threshold for ppm calculation.

fraction.weight

A numeric value for weight of fraction component in score.

dp.forward.weight

A numeric value for weight of forward dot product component in score.

dp.reverse.weight

A numeric value for weight of reverse dot product component in score.

remove_fragment_intensity_cutoff

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.

Value

A numeric value representing the similarity score between

exp.spectrum and lib.spectrum.

Details

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.

Examples

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