knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  # fig.width = 7, 
  # fig.height = 5,
  warning = FALSE,
  message = TRUE,
  out.width = "100%"
)

metflow2 also provide some other useful tools.


Metabolite ID convert

Note: This function has been deprecated, try to new function in tinyTools package.

transID() function can be used to convert metabolites in more than 225 databases. It is based on the http://cts.fiehnlab.ucdavis.edu/ and https://www.chemspider.com/InChI.asmx.

Convert chemical ID based on http://cts.fiehnlab.ucdavis.edu/

You can use the databaseName() function to get the databases supported in transID().

library(metflow2)
library(tidyverse)
database <- metflow2::databaseName(server = "http://cts.fiehnlab.ucdavis.edu/service/convert")
database$From
database$To

Then you can convert ID using transID() function.

transID(query = "C00001", from = "KEGG", 
        to = "PubChem SID", top = 2,
        server = "http://cts.fiehnlab.ucdavis.edu/service/convert")

The from and to argument must be from databaseName() function.

transID(query = "C00001", from = "KEGG", 
        to = "Human Metabolome Database", top = 2,
        server = "http://cts.fiehnlab.ucdavis.edu/service/convert")

Convert chemical ID based on https://www.chemspider.com/InChI.asmx

Another databsae https://www.chemspider.com/InChI.asmx also support ID conveter. First please use databaseName() to know which databases are supported in this website.

database <- databaseName(server = "https://www.chemspider.com/InChI.asmx")
database

Here we first use the http://cts.fiehnlab.ucdavis.edu/service/convert convert C00001 to get it's InChIKey ID.

transID(query = "C00010", 
        from = "KEGG", 
        to = "InChIKey", 
        top = 1,
        server = "http://cts.fiehnlab.ucdavis.edu/service/convert")

Then we use InChIKey ID to get its smiles.

inchi <- 
transID(query = "RGJOEKWQDUBAIZ-IBOSZNHHSA-N", 
        from = "inchikey", 
        to = "inchi",
        top = 2,
        server = "https://www.chemspider.com/InChI.asmx")
inchi
smiles <- 
transID(query = inchi,
        from = "inchi", 
        to = "smiles",
        top = 2,
        server = "https://www.chemspider.com/InChI.asmx")
smiles

Get metabolite class

Note: This function has been deprecated, try to new function in tinyTools package.

We can use get_metclass() function to get the metabolite class based on classyfire.

We need the inchikey for get_metclass() function, so if we don't have the inchikey, we can use the transID() function to get their inchikey.

library(metflow2)
inchikey <- 
transID(query = "C00001", 
        from = "KEGG", 
        to = "InChIKey", 
        top = 1,
        server = "http://cts.fiehnlab.ucdavis.edu/service/convert")
inchikey <- inchikey$InChIKey
inchikey
class <- get_metclass(inchikey = inchikey)

class is a classfire class.

class
class@compound_info
class@taxonomy_tree
class@classification_info
class@description
class@external_descriptors

Generate running list

We can use the getWorklist() function in metflow2 to generate a working list.

First, we should creat a batch.xlsx and put it in a folder. We use the demo data in demoData package.

The batch.xlsx is like this:

![](../man/figures/Screen Shot 2020-04-05 at 2.37.02 PM.png)

library(metflow2)
library(demoData)
##creat a folder nameed as example
path <- file.path(".", "example")
dir.create(path = path, showWarnings = FALSE)
##get demo data
demo_data <- system.file("metflow2", package = "demoData")

file.copy(from = file.path(demo_data, "batch.xlsx"), 
          to = path, overwrite = TRUE, recursive = TRUE)

Next, run the getWorklist() function.

getWorklist(
  table.name = "batch.xlsx",
  instrument = c("Thermo", "Agilent", "AB"),
  each.mode.number = 32,
  randommethod = c("no", "position", "injection"),
  samplenumber = NULL,
  QCstep = 8,
  conditionQCnumber = 8,
  qc.index.from = 1,
  dir = "D:\\Liang\\data\\PS4U\\HILIC\\batch3\\",
  method.path = "D:\\Liang\\Method\\urine\\HILIC\\",
  ms1.method.pos = "ZIC-HILIC_MS_pos",
  ms1.method.neg = "ZIC-HILIC_MS_neg",
  ms2.method.pos = c(
    "ZIC-HILIC_MSMS_pos_NCE25",
    "ZIC-HILIC_MSMS_pos_NCE25",
    "ZIC-HILIC_MSMS_pos_NCE25",
    "ZIC-HILIC_MSMS_pos_NCE25"
  ),
  ms2.method.neg = c(
    "ZIC-HILIC_MSMS_neg_NCE25",
    "ZIC-HILIC_MSMS_neg_NCE25",
    "ZIC-HILIC_MSMS_neg_NCE25",
    "ZIC-HILIC_MSMS_neg_NCE25"
  ),
  path = path
)

Then, the worklists will generated in this folder.

![](../man/figures/Screen Shot 2020-04-05 at 4.53.37 PM.png)



jaspershen/metflow2 documentation built on Aug. 15, 2021, 4:38 p.m.