match_ms2_temp: Match MS2 Spectra to Library Compounds

match_ms2_tempR Documentation

Match MS2 Spectra to Library Compounds

Description

Matches an experimental MS2 spectrum against a library of reference spectra, computing similarity scores.

Usage

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,
  ...
)

Arguments

idx

Integer, index of the MS2 spectrum to be matched.

ms2.info

List, containing experimental MS2 spectra with m/z and intensity values.

pre_match_result

Data frame, pre-matching results containing 'Lab.ID' and 'ms2_spectrum_id'. Default is 'NULL'.

spectra.data

List, reference MS2 spectra library, with compound IDs as names.

ms2.match.ppm

Numeric, mass tolerance in parts per million (ppm) for fragment matching. Default is '30'.

mz.ppm.thr

Numeric, minimum m/z threshold for ppm-based error calculation. Default is '400'.

ms2.match.tol

Numeric, minimum score threshold for a valid MS2 match. Default is '0.5'.

candidate.num

Integer, number of top candidates to retain based on match scores. Default is '3'.

fraction.weight

Numeric, weighting factor for the fraction of matched peaks in the similarity score. Default is '0.3'.

dp.forward.weight

Numeric, weight for the forward dot product score in similarity calculation. Default is '0.6'.

dp.reverse.weight

Numeric, weight for the reverse dot product score in similarity calculation. Default is '0.1'.

remove_fragment_intensity_cutoff

Numeric, intensity threshold for filtering out low-intensity fragments. Default is '0'.

masstplus_method_cutoff

Integer, maximum number of library compounds to process using standard matching. Default is '100'.

...

Additional arguments (not currently used).

Details

This function performs MS2 spectrum matching by comparing a given experimental spectrum to a reference database.

- If 'pre_match_result' is provided, only the compounds in 'pre_match_result$Lab.ID' are considered. - If no pre-matched compounds are found, the function searches across all compounds in 'spectra.data'. - If the number of candidate compounds is below 'masstplus_method_cutoff', the function calculates MS2 matching scores using 'calculate_ms2_matching_score()'. - The function filters and retains the top 'candidate.num' matches with scores above 'ms2.match.tol'.

Value

A data frame containing the top candidate matches with the following columns:

Lab.ID

Compound ID from the reference library.

CE

Collision energy setting from the reference spectrum (if applicable).

SS

Similarity score between the experimental and library spectrum.

ms2_spectrum_id

ID of the experimental spectrum.

If no matches are found, 'NULL' is returned.

Author(s)

Xiaotao Shen xiaotao.shen@outlook.com


tidymass/metid documentation built on June 1, 2025, 10:04 p.m.