Skip to contents

This function reads .mzXML and .mzML files containing MS/MS. This function is inspired on masstools::read_mzxml()which imports the data as a list. Then, each element in a list represents one scan. Also, each scans contains two sub-lists that contain (1) the scan information and (2) the spectra per scan.

Usage

import_mzxml(file = NULL, met_metadata = NULL, ppm = 10)

Arguments

file

file name and path of the .mzXML or .mzML MS/MS data

met_metadata

a data frame with the following columns.

Required:

Formula

A character string specifying the metabolite formula

Ionization_mode

The ionization mode employed in data collection. It can be only Positive or Negative

Ionization_mode

The ionization mode set in data collection (only Positive and Negative mode allowed).

File

The filename of the mzXML file inluding the path

COLLISIONENERGY

Collision energy applied in MS/MS fragmentation

These two columns are mandatory since the formula is used by the Rdisop package to calculate the exact mass and the ionization mode determine whether the the mass of the a proton is added or subtracted to calculate the charged mass.

Additionally, you can provide the minimum and maximum retention times to look for a peak only within a given area by including the following columns:

min_rt

numeric, with the minimum retention time to keep

max_rt

numeric, with the minimum retention time to keep

These two columns are highly recommended to be included to narrow down the search window and ensure the peak you want is selected. This is especially important if you have multiple peaks in the same data file.

ppm

the mass error in ppm. 10 ppm is the default value.

Value

data.frame in a tidy format for MS/MS spectra in a tidy format.

mz

ion m/z value

intensity

ion intensity count

mz_precursor

precursor ion

rt

retention time (in seconds)

Formula

Chemical formula provided in met_metada

Examples

# \donttest{
# Importing the Spectrum of Procyanidin A2 in negative ionization mode
# and 20 eV as the collision energy
ProcA2_file <- system.file("extdata",
  "ProcyanidinA2_neg_20eV.mzXML",
  package = "MS2extract"
)
# Compound metadata without ROI information
ProcA2_data <- data.frame(Formula = "C30H24O12", Ionization_mode = "Negative")
ProcA2_raw <- import_mzxml(ProcA2_file, met_metadata = ProcA2_data)
#> • Processing: ProcyanidinA2_neg_20eV.mzXML
#> • Found 1 CE value: 20
#> • Remember to match CE velues in spec_metadata when exporting your library
#> • m/z range given 10 ppm: 575.11376 and 575.12526

# 26731 ions detected in total
dim(ProcA2_raw)
#> [1] 26731     6

# Region of interest table (rt in seconds)
ProcA2_data <- data.frame(
  Formula = "C30H24O12", Ionization_mode = "Negative",
  min_rt = 163, max_rt = 180
)
ProcA2_roi <- import_mzxml(ProcA2_file, met_metadata = ProcA2_data)
#> • Processing: ProcyanidinA2_neg_20eV.mzXML
#> • Found 1 CE value: 20
#> • Remember to match CE velues in spec_metadata when exporting your library
#> • m/z range given 10 ppm: 575.11376 and 575.12526

# 24249 ions detected in ROI
dim(ProcA2_roi)
#> [1] 24249     6
# }