R/17_ms2_plot4mass_dataset.R
ms2_plot_mass_dataset.Rd
This function generates MS2 spectra comparison plots for a single peak in a `mass_dataset` object by comparing experimental MS2 data with reference MS2 data from a spectral database.
ms2_plot_mass_dataset(
object,
variable_id,
variable_index,
polarity = c("positive", "negative"),
ms1.match.ppm = 25,
ms2.match.ppm = 30,
mz.ppm.thr = 400,
database,
interactive_plot = FALSE
)
A `mass_dataset` object containing the peak data.
The ID of the peak to plot. Either `variable_id` or `variable_index` must be provided.
The index of the peak to plot. Either `variable_id` or `variable_index` must be provided.
Character, ionization mode, either `"positive"` or `"negative"`. Defaults to `"positive"`.
Numeric, mass accuracy threshold for MS1 matching in parts per million (ppm). Defaults to `25`.
Numeric, mass accuracy threshold for MS2 matching in ppm. Defaults to `30`.
Numeric, m/z threshold in ppm for matching MS1 and MS2. Defaults to `400`.
A `databaseClass` object containing the reference spectral database for MS2 data.
Logical, if `TRUE`, generates an interactive plot using `plotly`. Defaults to `FALSE`.
A list of MS2 spectra comparison plots for the specified peak, with one plot per matched annotation. If `interactive_plot = TRUE`, the plots are returned as interactive `plotly` plots.
This function retrieves the MS2 spectra for a specified peak and compares them to the reference MS2 spectra from a provided database. It generates a plot for each matched annotation, showing the experimental spectrum and the reference spectrum side by side.
if (FALSE) { # \dontrun{
# Plot MS2 spectra for a peak
ms2_plots <- ms2_plot_mass_dataset(
object = mass_object,
variable_id = "P001",
database = reference_database
)
} # }