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

Data preparation

We just use the dataset which are from previous step.

library(tidymass)
load("data_cleaning/POS/object_pos2")
load("data_cleaning/NEG/object_neg2")

Add MS2 spectra data to mass_dataset class

Download the MS2 data here.

Uncompress it.

Positive mode

object_pos2 <-
  mutate_ms2(
    object = object_pos2,
    column = "rp",
    polarity = "positive",
    ms1.ms2.match.mz.tol = 15,
    ms1.ms2.match.rt.tol = 30,
    path = "mgf_ms2_data/POS"
  )
object_pos2
extract_ms2_data(object_pos2)

Negative mode

object_neg2 <-
  mutate_ms2(
    object = object_neg2,
    column = "rp",
    polarity = "negative",
    ms1.ms2.match.mz.tol = 15,
    ms1.ms2.match.rt.tol = 30,
    path = "mgf_ms2_data/NEG"
  )
object_neg2
extract_ms2_data(object_neg2)

Metabolite annotation

Metabolite annotation is based on the metid package.

Download database

We need to download MS2 database from metid website.

Here we download the Michael Snyder RPLC databases, Orbitrap database and MoNA database. And place them in a new folder named as metabolite_annotation.

Positive mode

Annotate features using snyder_database_rplc0.0.3.

load("metabolite_annotation/snyder_database_rplc0.0.3.rda")
snyder_database_rplc0.0.3
object_pos2 <-
  annotate_metabolites_mass_dataset(object = object_pos2, 
                                    ms1.match.ppm = 15, 
                                    rt.match.tol = 30, 
                                    polarity = "positive",
                                    database = snyder_database_rplc0.0.3)

Annotate features using orbitrap_database0.0.3.

load("metabolite_annotation/orbitrap_database0.0.3.rda")
orbitrap_database0.0.3
object_pos2 <- 
  annotate_metabolites_mass_dataset(object = object_pos2, 
                                    ms1.match.ppm = 15, 
                                    polarity = "positive",
                                    database = orbitrap_database0.0.3)

Annotate features using mona_database0.0.3.

load("metabolite_annotation/mona_database0.0.3.rda")
orbitrap_database0.0.3
object_pos2 <- 
  annotate_metabolites_mass_dataset(object = object_pos2, 
                                    ms1.match.ppm = 15, 
                                    polarity = "positive",
                                    database = mona_database0.0.3)

Negative mode

Annotate features using snyder_database_rplc0.0.3.

object_neg2 <- 
  annotate_metabolites_mass_dataset(object = object_neg2, 
                                    ms1.match.ppm = 15, 
                                    rt.match.tol = 30,
                                    polarity = "negative",
                                    database = snyder_database_rplc0.0.3)

Annotate features using orbitrap_database0.0.3.

object_neg2 <- 
  annotate_metabolites_mass_dataset(object = object_neg2, 
                                    ms1.match.ppm = 15, 
                                    polarity = "negative",
                                    database = orbitrap_database0.0.3)

Annotate features using mona_database0.0.3.

object_neg2 <- 
  annotate_metabolites_mass_dataset(object = object_neg2, 
                                    ms1.match.ppm = 15, 
                                    polarity = "negative",
                                    database = mona_database0.0.3)
load("metabolite_annotation/object_pos2")
load("metabolite_annotation/object_neg2")

Annotation result

The annotation result will assign into mass_dataset class as the annotation_table slot.

head(extract_annotation_table(object = object_pos2))
variable_info_pos <- 
extract_variable_info(object = object_pos2)
head(variable_info_pos)
table(variable_info_pos$Level)
table(variable_info_pos$Database)

Use the ms2_plot_mass_dataset() function to get the MS2 matching plot.

ms2_plot_mass_dataset(object = object_pos2, 
                      variable_id = "M86T95_POS", 
                      database = mona_database0.0.3)
ms2_plot_mass_dataset(object = object_pos2, 
                      variable_id = "M86T95_POS", 
                      database = mona_database0.0.3, 
                      interactive_plot = TRUE)
ms2_plot_mass_dataset(object = object_pos2, 
                      variable_id = "M147T54_POS", 
                      database = snyder_database_rplc0.0.3, 
                      interactive_plot = FALSE)

Save data for subsequent analysis.

save(object_pos2, file = "metabolite_annotation/object_pos2")
save(object_neg2, file = "metabolite_annotation/object_neg2")

Session information

sessionInfo()


tidymass/tidymass documentation built on April 5, 2022, 2:10 a.m.