Skip to contents

This function takes multiple spectra imported with the batch_import_mzxml() function. Then, it parses the argument to detect_mass() function. Briefly, similarly to the mass detection step in the MZmine workflow, detect_mass() filters out low intensity signals. Here, you can opt to detect masses by the raw ion intensity (ion counts), or normalize the spectra to the most abundant ion, and detect as an intensity percentage of that ion. The default is set to include all ions that are at least 1% of the most abundant ion.

Usage

batch_detect_mass(batch_spect, normalize = TRUE, min_int = 1)

Arguments

batch_spect

a list of MS/MS scans imported with batch_import_mzxml() function.

normalize

a boolean indicating if the MS/MS spectra is normalized by the base peak before proceeding to filter out low intensity signals (normalize = TRUE), if normalize = FALSE user has to provide the minimum ion count.

min_int

an integer with the minimum ion intensity

Examples


# Select the csv file name and path
batch_file <- system.file("extdata", "batch_read.csv",
  package = "MS2extract"
)
# Read the data frame
batch_data <- read.csv(batch_file)

# File paths for Procyanidin A2 and Rutin
ProcA2_file <- system.file("extdata",
  "ProcyanidinA2_neg_20eV.mzXML",
  package = "MS2extract"
)
Rutin_file <- system.file("extdata",
  "Rutin_neg_20eV.mzXML",
  package = "MS2extract"
)

# Add file path - User should specified the file path -
batch_data$File <- c(ProcA2_file, Rutin_file)

# Checking batch_data data frame
batch_data
#>             Name   Formula Ionization_mode min_rt max_rt COLLISIONENERGY
#> 1 Procyanidin A2 C30H24O12        Negative    163    180           20 eV
#> 2          Rutin C27H30O16        Negative    162    171           20 eV
#>                                                                              File
#> 1 /home/runner/work/_temp/Library/MS2extract/extdata/ProcyanidinA2_neg_20eV.mzXML
#> 2         /home/runner/work/_temp/Library/MS2extract/extdata/Rutin_neg_20eV.mzXML

# Using batch import to import multiple compounds
batch_compounds <- batch_import_mzxml(batch_data)
#> 
#> ── Begining batch import ───────────────────────────────────────────────────────
#> 
#> ── -- ──
#> 
#> • 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
#> • Compound name: Procyanidin A2_Negative_20
#> 
#> ── -- ──
#> 
#> • Processing: Rutin_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: 609.14002 and 609.15221
#> • Compound name: Rutin_Negative_20
#> 
#> ── End batch import ────────────────────────────────────────────────────────────
# Checking dimension by compound
# Procyanidin A2: 24249 ions
# Rutin: 22096 ions
purrr::map(batch_compounds, dim)
#> $`Procyanidin A2_Negative_20`
#> [1] 17829     6
#> 
#> $Rutin_Negative_20
#> [1] 11475     6
#> 

# Extracting MS2 spec
batch_extracted <- batch_extract_MS2(batch_compounds,
  verbose = TRUE,
  out_list = FALSE
)
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Warning: `position_stack()` requires non-overlapping x intervals.

#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Warning: `position_stack()` requires non-overlapping x intervals.


# Batch detect mass
batch_mass_detected <- batch_detect_mass(batch_extracted, # Compound list
  normalize = TRUE, # Normalize
  min_int = 1
) # Minimum intensity

# Checking dimension by compound
# Procyanidin A2: 38 ions
# Rutin: 4 ions
purrr::map(batch_mass_detected, dim)
#> $`Procyanidin A2_Negative_20`
#> [1] 38  6
#> 
#> $Rutin_Negative_20
#> [1] 4 6
#>