
Spec2Annot is an R package which implement different ways to annotate and query mass spectra.
You can install the development version of Spec2Annot from GitHub with:
# install.packages("devtools")
devtools::install_github("odisce/Spec2Annot")Spec2Annot has built-in tables containings useful
informations on:
- common adducts: Spec2Annot::Adduct_db
- common losses: Spec2Annot::Losses_db
- common isotopes: Spec2Annot::Isotopes_db
- common charges: Spec2Annot::db_monocharge
- a pre-computed list combining the above:
Spec2Annot::ions_database
- atomic elements: Spec2Annot::Element
Those tables are used to search as chemical-knowledge to annotate
ions, but the package contains a set of functions to calculate mass from
strings, like:
- Chemical formula:
Spec2Annot::mz_from_string("C6H12O3")
- Chemical loss or adducts:
Spec2Annot::mz_from_string("C6H12O3-H2O+H")
- Chemical notation as described by Damont et al. (2019):
Spec2Annot::mz_from_string("[C6H2O3-H2O+H]+")
- And isotopes:
Spec2Annot::mz_from_string("C6H12O3_13C2")
Calculate mass:
- range using ppm:
Spec2Annot::mz_range(120.2532, ppm = 10)
- ppm from range:
Spec2Annot::mz_ppm(120.2532, 120.2540)
- ion from mass:
Spec2Annot::mz_calc_ion(120.2532, form = "-H")
Very fast mZ/rt search between two tables:
Spec2Annot::search_db_cpp() this function written in C++
use a combination of sequential moving search range + a binary search
algorithm implemented in std::lower/upper_bound.
{r} ## Exemple on simulated exemple data, normally the function is used to search between two different tables. require(Spec2Annot) search_db_cpp( in_db = spectra_full[, .(id = paste0("Database_", seq_len(.N)), mz, rt = rnorm(.N, 10, 10))], in_exp = spectra_full[sample(seq_len(.N), .N, replace = TRUE), .(id = paste0("Experimental_", seq_len(.N)), mz, rt = rnorm(.N, 10, 10))], ppmtol = 5, rttol = 5 )
Spec2Annot contains also more advanced function like
a combinatory-search algorithm in C++ to find any elemental
composition from an exact mass. This algorithm can find common element
but also any isotops or isotopologs. By default it will use the “seven
golden rules” from Kind & Fiehn (2007) and the most common atomic
element found in organic compounds, but any composition can be used.
{r} Spec2Annot::find_compo_from_mass( mass_target = 120.25325, ppm = 5, use_golden_ratio = TRUE, elements_vc = NULL )
For more advanced usage you can access the underlying function here:
Spec2Annot::brute_force_const().
Spec2Annot contains a wrapper to calculate the elemental composition of a mass spectra by adding restriction of a known formula (useful with MS2 spectra of known precursor) or not. It will also add some chemical scores/metrics like the Double Bond Equivalent (DBE), Nitrogen rule (nrule) or Senior score (adapted from Morikawa and Newbold, 2003).
{r} Spec2Annot::annotate_mz( input_spectrum = spectra_ms2, ppm = 3, polarity = 1, compo = "C10H12N5O6P1" )