Skip to contents

Perform consensus structural classification for molecular formulas assigned to m/z features from electrospray ionisation mass spectrometry approaches.

Usage

construction(
  x,
  library_path = tempdir(),
  db = "kegg",
  organism = character(),
  threshold = 66,
  adduct_rules_table = adduct_rules(),
  classyfireR_cache = NULL
)

# S4 method for tbl_df
construction(
  x,
  library_path = paste0(tempdir(), "/construction_library"),
  db = "kegg",
  organism = character(),
  threshold = 66,
  adduct_rules_table = adduct_rules(),
  classyfireR_cache = NULL
)

# S4 method for Assignment
construction(
  x,
  library_path = tempdir(),
  db = "kegg",
  organism = character(),
  threshold = 66,
  classyfireR_cache = NULL
)

Arguments

x

The molecular formulas and adducts to search. This should either be a tibble containing two character columns named MF and Adduct or and S4 object of class Assignment.

library_path

the target file path for the classification library in which to store consensus classification data

db

the databases to search. This can either be kegg and/or pubchem.

organism

the KEGG organism ID. This is Ignored if argument db is set to pubchem

threshold

the percentage majority threshold for consensus classification

adduct_rules_table

a data frame containing the adduct formation rules. The defaults is mzAnnotation::adduct_rules().

classyfireR_cache

the file path for a classyfireR cache. See the documentation of classyfireR::get_classification for more details.

Value

If argument x is a tibble, then a tibble is returned containing the consensus structural classifications. If argument x is an object of S4 class Assignment, and object of S4 class Construction is returned.

Examples

x <- tibble::tibble(MF = c('C12H22O11','C4H6O5'),
                    Adduct = c('[M+Cl]1-','[M-H]1-'))
structural_classifications <- construction(x)
#> 2 MFs to retrieve out of 2
#> 
#> C12H22O11
#> Searching KEGG...
#> 36 hits returned
#> Retrieving classifications for 36 InChIKeys...
#> ✔ CZMRCDWAGMRECN-UGDNZRGBSA-N
#> ✔ GUBGYTABKSRVRQ-CUHNMECISA-N
#> ✔ GUBGYTABKSRVRQ-PICCSMPSSA-N
#> ✔ GUBGYTABKSRVRQ-QKKXKWKRSA-N
#> ✔ DLRVVLDZNNYCBX-RTPHMHGBSA-N
#> ✔ GUBGYTABKSRVRQ-ASMJPISFSA-N
#> ✔ HDTRYLNUVZCQOY-LIZSDCNHSA-N
#> ✔ VCWMRQD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KEGG...
#> 8 hits returned
#> Retrieving classifications for 7 InChIKeys...
#> ✔ BJEPYKJPYRNKOW-REOHCLBHSA-N
#> ✔ BJEPYKJPYRNKOW-UWTATZPHSA-N
#> ✔ BJEPYKJPYRNKOW-UHFFFAOYSA-N
#> ✔ SCSGVVIUUUPOOJ-GSVOUGTGSA-N
#> ✔ SCSGVVIUUUPOOJ-VKHMYHEASA-N
#> ✔ CODPBKJMVNZFKR-REOHCLBHSA-N
#> ✔ CODPBKJMVNZFKR-UWTATZPHSA-N
#> 7 classifications returned
#> Exporting to /tmp/RtmpLxTJ8Q/construction_library
#> 
#> Complete!

structural_classifications
#> # A tibble: 2 × 10
#>   mf    adduct total `consensus (%)` kingdom superclass class subclass `level 5`
#>   <chr> <chr>  <int>           <dbl> <chr>   <chr>      <chr> <chr>    <chr>    
#> 1 C12H… [M+Cl…    36            83.3 Organi… Organic o… Orga… Carbohy… Glycosyl…
#> 2 C4H6… [M-H]…     8           100   Organi… Organic a… NA    NA       NA       
#> # ℹ 1 more variable: `level 6` <chr>