This function extracts the MS2 spectrum data for a specific metabolite from a `databaseClass` object based on the provided Lab ID, polarity, and collision energy (CE).
get_ms2_spectrum(
lab.id,
database,
polarity = c("positive", "negative"),
ce = "30"
)
A character string representing the Lab ID of the metabolite whose MS2 spectrum is to be retrieved.
A `databaseClass` object that contains the MS2 spectra data.
A character string specifying the polarity mode for the spectrum. It can be either `"positive"` or `"negative"`. Defaults to `"positive"`.
A character string specifying the collision energy (CE) to retrieve. Defaults to `"30"`.
A list containing the MS2 spectrum for the specified metabolite, polarity, and collision energy.
The function retrieves the MS2 spectrum for a given Lab ID from the provided `databaseClass` object. The user can specify the polarity mode (positive or negative) and the collision energy (CE) value to retrieve the correct spectrum. If the `database` is not a valid `databaseClass` object, the function stops with an error.
The example and demo data of this function can be found https://tidymass.github.io/metid/articles/metid.html
if (FALSE) { # \dontrun{
# Assuming `db_instance` is an instance of `databaseClass`
spectrum <- get_ms2_spectrum(lab.id = "M123",
database = db_instance, polarity = "positive", ce = "30")
} # }