knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  out.width = "100%"
)

In version 0.9.2, I just modified the database argument in identify_metabolites() and identify_metabolite_alls functions. Now you can put the database in the work directory and then give the database name, and you can also directory provide the database (databaseClass) to it.

Load demo data

First we load the MS1 peak and database from metID package and then put them in a example folder.

library(metID)
library(tidyverse)
##create a folder named as example
path <- file.path(".", "example")
dir.create(path = path, showWarnings = FALSE)

##get MS1 peak table from metID
ms1_peak <- system.file("ms1_peak", package = "metID")
file.copy(from = file.path(ms1_peak, "ms1.peak.table.csv"), 
          to = path, overwrite = TRUE, recursive = TRUE)

##get database from metID
database <- system.file("ms2_database", package = "metID")

file.copy(from = file.path(database, "msDatabase_rplc0.0.2"), 
          to = path, overwrite = TRUE, recursive = TRUE)

Now in your ./example, there are two files, namely ms1.peak.table.csv and msDatabase_rplc_0.0.2, respectively.

Use database name

annotate_result1 <- 
  identify_metabolites(ms1.data = "ms1.peak.table.csv", 
                       ms1.match.ppm = 15, 
                       rt.match.tol = 1000000, 
                       polarity = "positive", 
                       column = "rp", 
                       path = path, 
                       candidate.num = 3,
                       database = "msDatabase_rplc0.0.2", 
                       threads = 5)

Use databaseClass object

load(file.path(path, "msDatabase_rplc0.0.2"))
msDatabase_rplc0.0.2

Then we can directory provide this database to identify_metabolites():

annotate_result2 <- 
  identify_metabolites(ms1.data = "ms1.peak.table.csv", 
                       ms1.match.ppm = 15, 
                       rt.match.tol = 1000000, 
                       polarity = "positive", 
                       column = "rp", 
                       path = path, 
                       candidate.num = 3,
                       database = msDatabase_rplc0.0.2, 
                       threads = 5)

But what should be noticed is that it have different name for database in the final result:

annotate_result1@database
annotate_result2@database

It is because that if you give the databaseClass, so identify_metabolites can know the name of database, if just use the source and version as the name for database.

paste(msDatabase_rplc0.0.2@database.info$Source,
      msDatabase_rplc0.0.2@database.info$Version, 
      sep = "_")



jaspershen/metID documentation built on July 31, 2022, 11:31 p.m.