1 Introduction

As the RMassBank-workflow is described in the other manual, this document mainly explains how to utilize the XCMS-, MassBank-, and peaklist-readMethods for Step 1 of the workflow.

2 Input files

2.1 LC/MS data

RMassBank handles high-resolution LC/MS spectra in mzML or mzdata format in centroid1 The term “centroid” here refers to any kind of data which are not in profile mode, i.e. don’t have continuous m/z data. It does not refer to the (mathematical) centroid peak, i.e. the area-weighted mass peak. or in profile mode.

Data in the examples was acquired using a QTOF instrument.

In the standard workflow, the file names are used to identify a compound: file names must be in the format xxxxxxxx_1234_xxx.mzXML, where the xxx parts denote anything and the 1234 part denotes the compound ID in the compound list (see below). Advanced and alternative uses can be implemented; consult the implementation of msmsRead, msms_workflow and findMsMsHRperX.direct for more information.

3 Additional Workflow-Methods

The data used in the following example is available as a package RMassBankData, so both libraries have to be installed to run this vignette.

library(RMassBank)
library(RMassBankData)

3.1 Options

In the first part of the workflow, spectra are extracted from the files and processed. In the following example, we will process the Glucolesquerellin spectra from the provided files.

For the workflow to work correctly, we use the default settings, and modify then to match the data acquisition method. The settings have to contain the same parameters as the mzR-method would for the workflow.

RmbDefaultSettings()
rmbo <- getOption("RMassBank")
rmbo$spectraList <- list(
  list(mode="CID", ces="10eV", ce="10eV", res=12000),
  list(mode="CID", ces="20eV", ce="20eV", res=12000)
)

rmbo$multiplicityFilter <- 1
rmbo$annotations$instrument <- "Bruker micrOTOFq"
rmbo$annotations$instrument_type <- "LC-ESI-QTOF"
rmbo$recalibrator$MS1 <- "recalibrate.identity"
rmbo$recalibrator$MS2 <- "recalibrate.identity"
options("RMassBank" = rmbo)

3.2 XCMS-workflow

First, a workspace for the msmsWorkflow must be created:

msmsList <- newMsmsWorkspace()

The full paths of the files must be loaded into the container in the array files:

msmsList@files <- list.files(system.file("spectra.Glucolesquerellin",
                                         package = "RMassBankData"),
                             "Glucolesquerellin.*mzML", full.names=TRUE)

Note the position of the compound IDs in the filenames. Historically, the “pos” at the end was used to denote the polarity; it is obsolete now, but the ID must be terminated with an underscore. If you have multiple files for one compound, you have to give them the same ID, but thanks to the polarity at the end being obsolete, you can just enumerate them.

Additionally, the compound list must be loaded using loadList:

loadList(system.file("list/PlantDataset.csv",package="RMassBankData"))

Basically, the changes to the workflow using XCMS can be described as follows:

The MS2-Spectra(and optionally the MS1-spectrum) are extracted and peakpicked using XCMS. You can pass different parameters for the findPeaks function of XCMS using the findPeaksArgs-argument to detect actual peaks. Then, CAMERA processes the peak lists and creates pseudospectra (or compound spectra). The obtained pseudospectra are stored in the array specs.

Please note that “findPeaksArgs” has to be a list with the list elements named after the arguments that the method you want to use contains, as findPeaks is called by do.call. For example, if you want to use centWave with a peakwidth from 5 to 12 and 25 ppm, findPeaksArgs would look like this:

Args <- list(method="centWave",
                     peakwidth=c(5,12),
                     prefilter=c(0,0),
                     ppm=25, snthr=2)

If you want to utilize XCMS for Step 1 of the workflow, you have to set the readMethod-parameter to “xcms” and - if you don’t want to use standard values for findPeaks - pass on findPeaksArgs to the workflow.

msmsList <- msmsRead(msmsList, files= msmsList@files, 
                     readMethod = "xcms", mode = "mH", Args = Args, plots = TRUE)
## Provided scanrange was adjusted to 1 - 0
## MS2 spectra without precursorScan references, using estimation
## Detecting mass traces at 25 ppm ... OK
## Detecting chromatographic peaks in 40 regions of interest ... OK: 29 found.
## Provided scanrange was adjusted to 1 - 0
## MS2 spectra without precursorScan references, using estimation
## 
## Detecting mass traces at 25 ppm ... OK
## Detecting chromatographic peaks in 32 regions of interest ... OK: 29 found.

msmsList <- msmsWorkflow(msmsList, steps=2:8,
                         mode="mH", readMethod="xcms")

You can of course run the rest of the workflow as usual, by - like here - setting steps to 1:8

3.3 Export the records

To export the records from the XCMS workflow, follow the same procedure as the standard RMassBank workflow, i.e.:

mb <- newMbWorkspace(msmsList)
mb <- resetInfolists(mb)
mb <- loadInfolist(mb,system.file("infolists/PlantDataset.csv",
                                  package = "RMassBankData"))
# Step
mb <- mbWorkflow(mb, steps=1:8)

3.4 peaklist-workflow

The peaklist-workflow works akin to the normal mzR-workflow with the only difference being, that the supplied data has to be in .csv format and contain 2 columns: “mz” and “int”. You can look at an example file in the RMassBankData-package in spectra.Glucolesquerellin. Please note that the naming of the csv has to be similar to the mzdata-files, with the only difference being the filename extension. The readMethod name for this is “peaklist”

msmsPeaklist <- newMsmsWorkspace()
msmsPeaklist@files <- list.files(system.file("spectra.Glucolesquerellin",
                                             package = "RMassBankData"),
                                 "Glucolesquerellin.*csv", full.names=TRUE)
msmsPeaklist <- msmsWorkflow(msmsPeaklist, steps=1:8,
                             mode="mH", readMethod="peaklist")

The records can then be generated and exported with mbWorkflow.

4 Session information

sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.18-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
##  [3] LC_TIME=en_GB                 LC_COLLATE=C                 
##  [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
##  [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
##  [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
## [11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] gplots_3.1.3         RMassBankData_1.39.0 RMassBank_3.12.0    
## [4] Rcpp_1.0.11          BiocStyle_2.30.0    
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3          rstudioapi_0.15.0          
##   [3] jsonlite_1.8.7              MultiAssayExperiment_1.28.0
##   [5] magrittr_2.0.3              magick_2.8.1               
##   [7] MALDIquant_1.22.1           rmarkdown_2.25             
##   [9] fs_1.6.3                    zlibbioc_1.48.0            
##  [11] vctrs_0.6.4                 multtest_2.58.0            
##  [13] RCurl_1.98-1.12             base64enc_0.1-3            
##  [15] xcms_4.0.0                  progress_1.2.2             
##  [17] htmltools_0.5.6.1           S4Arrays_1.2.0             
##  [19] itertools_0.1-3             curl_5.1.0                 
##  [21] Formula_1.2-5               SparseArray_1.2.0          
##  [23] mzID_1.40.0                 sass_0.4.7                 
##  [25] KernSmooth_2.23-22          bslib_0.5.1                
##  [27] htmlwidgets_1.6.2           plyr_1.8.9                 
##  [29] impute_1.76.0               cachem_1.0.8               
##  [31] igraph_1.5.1                lifecycle_1.0.3            
##  [33] iterators_1.0.14            pkgconfig_2.0.3            
##  [35] Matrix_1.6-1.1              R6_2.5.1                   
##  [37] fastmap_1.1.1               GenomeInfoDbData_1.2.11    
##  [39] MatrixGenerics_1.14.0       clue_0.3-65                
##  [41] digest_0.6.33               pcaMethods_1.94.0          
##  [43] rsvg_2.6.0                  colorspace_2.1-0           
##  [45] S4Vectors_0.40.0            Hmisc_5.1-1                
##  [47] GenomicRanges_1.54.0        Spectra_1.12.0             
##  [49] fansi_1.0.5                 httr_1.4.7                 
##  [51] abind_1.4-5                 compiler_4.3.1             
##  [53] doParallel_1.0.17           backports_1.4.1            
##  [55] htmlTable_2.4.1             BiocParallel_1.36.0        
##  [57] DBI_1.1.3                   logger_0.2.2               
##  [59] fingerprint_3.5.7           R.utils_2.12.2             
##  [61] MASS_7.3-60                 MsExperiment_1.4.0         
##  [63] ChemmineR_3.54.0            DelayedArray_0.28.0        
##  [65] rjson_0.2.21                gtools_3.9.4               
##  [67] caTools_1.18.2              mzR_2.36.0                 
##  [69] tools_4.3.1                 foreign_0.8-85             
##  [71] nnet_7.3-19                 R.oo_1.25.0                
##  [73] webchem_1.3.0               glue_1.6.2                 
##  [75] QFeatures_1.12.0            grid_4.3.1                 
##  [77] checkmate_2.2.0             cluster_2.1.4              
##  [79] readJDX_0.6.1               generics_0.1.3             
##  [81] gtable_0.3.4                rcdk_3.8.1                 
##  [83] R.methodsS3_1.8.2           preprocessCore_1.64.0      
##  [85] hms_1.1.3                   MetaboCoreUtils_1.10.0     
##  [87] data.table_1.14.8           xml2_1.3.5                 
##  [89] utf8_1.2.4                  XVector_0.42.0             
##  [91] BiocGenerics_0.48.0         RANN_2.6.1                 
##  [93] foreach_1.5.2               pillar_1.9.0               
##  [95] stringr_1.5.0               limma_3.58.0               
##  [97] robustbase_0.99-0           rJava_1.0-6                
##  [99] splines_4.3.1               dplyr_1.1.3                
## [101] CAMERA_1.58.0               lattice_0.22-5             
## [103] survival_3.5-7              RBGL_1.78.0                
## [105] tidyselect_1.2.0            knitr_1.44                 
## [107] gridExtra_2.3               bookdown_0.36              
## [109] IRanges_2.36.0              ProtGenerics_1.34.0        
## [111] SummarizedExperiment_1.32.0 stats4_4.3.1               
## [113] xfun_0.40                   Biobase_2.62.0             
## [115] statmod_1.5.0               MSnbase_2.28.0             
## [117] matrixStats_1.0.0           DEoptimR_1.1-3             
## [119] DT_0.30                     stringi_1.7.12             
## [121] lazyeval_0.2.2              yaml_2.3.7                 
## [123] evaluate_0.22               codetools_0.2-19           
## [125] data.tree_1.0.0             rcdklibs_2.8               
## [127] MsCoreUtils_1.14.0          tibble_3.2.1               
## [129] graph_1.80.0                BiocManager_1.30.22        
## [131] cli_3.6.1                   affyio_1.72.0              
## [133] rpart_4.1.21                munsell_0.5.0              
## [135] jquerylib_0.1.4             GenomeInfoDb_1.38.0        
## [137] MassSpecWavelet_1.68.0      png_0.1-8                  
## [139] XML_3.99-0.14               parallel_4.3.1             
## [141] ggplot2_3.4.4               assertthat_0.2.1           
## [143] prettyunits_1.2.0           AnnotationFilter_1.26.0    
## [145] bitops_1.0-7                MsFeatures_1.10.0          
## [147] scales_1.2.1                affy_1.80.0                
## [149] ncdf4_1.21                  purrr_1.0.2                
## [151] crayon_1.5.2                rlang_1.1.1                
## [153] vsn_3.70.0                  rvest_1.0.3