This function generates plots comparing MS2 spectra from experimental data with spectra from a reference database. It matches based on a set of user-specified parameters and provides visualizations with either static or interactive plots.

plot_ms2_matching(
  object,
  variable_id,
  variable_index,
  database,
  polarity = c("positive", "negative"),
  ms1.match.ppm = 25,
  ms2.match.ppm = 30,
  mz.ppm.thr = 400,
  remove_fragment_intensity_cutoff = 0,
  interactive_plot = FALSE
)

Arguments

object

A `mass_dataset` object that contains MS2 data and annotations.

variable_id

Optional. A vector of variable IDs to be plotted.

variable_index

Optional. A vector of variable indices to be plotted. Either `variable_id` or `variable_index` must be provided.

database

A `databaseClass` object containing reference MS2 spectra for matching.

polarity

Character. The ionization mode, either "positive" or "negative". Default is "positive".

ms1.match.ppm

Numeric. The mass-to-charge (m/z) tolerance in parts per million (ppm) for MS1 matching. Default is 25.

ms2.match.ppm

Numeric. The mass-to-charge (m/z) tolerance in parts per million (ppm) for MS2 matching. Default is 30.

mz.ppm.thr

Numeric. The m/z threshold for fragment matching. Default is 400.

remove_fragment_intensity_cutoff

Numeric. The intensity cutoff for removing low-intensity fragments. Default is 0.

interactive_plot

Logical. If TRUE, an interactive plot using plotly is returned. Default is FALSE.

Value

A list of plots (either static or interactive) comparing experimental and reference MS2 spectra.

Details

The function compares MS2 spectra from the experimental data (provided by the `mass_dataset` object) to those in the reference `database`. It generates matching plots for each of the specified variables and annotations. Users can specify either the `variable_id` or `variable_index` for plotting. The function supports both static and interactive visualizations.

Examples

if (FALSE) { # \dontrun{
# Example usage:
all_plots <- plot_ms2_matching(
  object = my_mass_dataset,
  variable_id = c("pRPLC_1112", "pRPLC_1860"),
  database = my_database
)
} # }