Over the past two decades, liquid chromatography coupled to mass spectrometry (LC–MS) has evolved into the method of choice in the field of proteomics. (Cox and Mann 2011; Mallick and Kuster 2010) During a typical LC–MS measurement, a complex mixture of analytes is separated by a liquid chromatography system coupled to a mass spectrometer (MS) through an ion source interface. This interface converts the analytes that elute from the chromatography system over time into a beam of ions. The MS records from this ion beam a series of mass spectra containing detailed information on the analyzed sample. (Savaryn, Toby, and Kelleher 2016) The resulting raw data consist of the mass spectra and their metadata, typically recorded in a vendor-specific binary format. During a measurement the mass spectrometer applies internal heuristics, which enables the instrument to adapt to sample properties, for example, sample complexity and amount of ions in near real time. Still, method parameters controlling these heuristics need to be set prior to the measurement. Optimal measurement results require a careful balancing of instrument parameters, but their complex interactions with each other make LC–MS method optimization a challenging task.
Here we present rawDiag, a platform-independent software tool implemented in the R language (Becker, Chambers, and Wilks 1988) that supports LC–MS operators during the process of empirical method optimization. Our work builds on the ideas of the discontinued software rawMeat (VAST Scientific). Our application is currently tailored toward spectral data acquired on Thermo Fisher Scientific instruments (raw format), with a particular focus on Orbitrap (Zubarev and Makarov 2013) mass analyzers (Exactive or Fusion instruments). These instruments are heavily used in the field of bottom-up proteomics (Aebersold and Mann 2003) to analyze complex peptide mixtures derived from enzymatic digests of proteomes.
rawDiag is meant to run after MS acquisition, optimally as an interactive R shiny application, and produces a series of diagnostic plots visualizing the impact of method parameter choices on the acquired data across injections. If static reports are required then pdf files can be generated using rmarkdown. In this vignette, we present the usage of our tool.
rawDiag gains advantages from being part of the Bioconductor ecosystem, such as its ability to utilize the rawrr package and potentially extend its functionality through interaction with the Spectra infrastructure, particularly with the MsBackendRawFileReader.
rawDiag
proides a wrapper function readRaw
using the rawrr
methods raw::readIndex
, rawrr::readTrailer
,
and rawrr::readChromatogram
to read proprietary mass
spectrometer generated data by invoking third-party managed methods
through a system2
text connection
. The rawrr
package provides the entire stack below, which rawDiag
utilizes.
R>
|
text connection
|
system2
|
Mono Runtime |
Managed Assembly (CIL/.NET code) rawrr.exe |
ThermoFisher.CommonCore.*.dll |
In case you prefer to compile rawrr.exe
from C# source
code, please install the mono compiler and xbuild by installing the
following Linux packages:
To install this package, start R (version “>=4.4”) and enter:
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("rawrr")
assemblies aka Common Intermediate Language bytecode - the download and install can be done on all platforms using the command:
## function ()
## {
## if (isFALSE(requireNamespace("BiocManager", quietly = TRUE)))
## stop("exec", "install.packages('BiocManager')")
## if (isFALSE(requireNamespace("rawrr", quietly = TRUE)))
## stop("exec", "BiocManager::install('rawrr')")
## if (isFALSE(file.exists(rawrr:::.rawrrAssembly())))
## rawrr::installRawrrExe()
## if (isFALSE(rawrr:::.isAssemblyWorking()))
## stop("rawrr assembly is not working. check if mono if available.")
## TRUE
## }
## <bytecode: 0x558ccef1f700>
## <environment: namespace:rawDiag>
## Overwrite sourceUrl to https://fgcz-ms.uzh.ch/~cpanse/rawrr/dotnet//linux-x64/rawrr
## MD5 d842e4ba5fe901cc4dd62e439e7c6b9b /github/home/.cache/R/rawrr/rawrrassembly/linux-x64/rawrr
## [1] TRUE
## NULL
## [1] "/github/home/.cache/R/rawrr/rawrrassembly/linux-x64"
## [1] "rawrr"
for more information please read the INSTALL file in the rawrr package.
fetch example Orbitrap raw files from ExperimentHub’s tartare package.
## Loading required package: BiocGenerics
## Loading required package: generics
##
## Attaching package: 'generics'
## The following objects are masked from 'package:base':
##
## as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
## setequal, union
##
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
## as.data.frame, basename, cbind, colnames, dirname, do.call,
## duplicated, eval, evalq, get, grep, grepl, is.unsorted, lapply,
## mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
## rank, rbind, rownames, sapply, saveRDS, table, tapply, unique,
## unsplit, which.max, which.min
## Loading required package: AnnotationHub
## Loading required package: BiocFileCache
## Loading required package: dbplyr
## Warning: multiple methods tables found for 'union'
## Warning: multiple methods tables found for 'intersect'
## Warning: multiple methods tables found for 'setdiff'
## Warning: multiple methods tables found for 'setequal'
## Warning: multiple methods tables found for 'union'
## Warning: multiple methods tables found for 'intersect'
## Warning: multiple methods tables found for 'setdiff'
## Warning: multiple methods tables found for 'intersect'
## Warning: multiple methods tables found for 'union'
## Warning: multiple methods tables found for 'intersect'
## Warning: multiple methods tables found for 'setdiff'
## Warning: multiple methods tables found for 'setequal'
## see ?tartare and browseVignettes('tartare') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## see ?tartare and browseVignettes('tartare') for documentation
## downloading 1 resources
## retrieving 1 resource
## loading from cache
## [1] "/github/home/.cache/R/ExperimentHub/18af63ffdf48_3238.raw"
## [1] TRUE
## [1] "/github/home/.cache/R/ExperimentHub/18af7e3d4e64_4590.raw"
## [1] TRUE
Of note, the proprietary .Net assemblies (Shofstahl 2018) require a file extentention of
.raw
. Therfore we have to rename the EH files and add the
.raw
suffix.
list meta data of the raw files.
## [[1]]
## [[1]]$`RAW file`
## [1] "18af63ffdf48_3238.raw"
##
## [[1]]$`RAW file version`
## [1] "66"
##
## [[1]]$`Creation date`
## [1] "7/16/2019 5:56:24 PM"
##
## [[1]]$Operator
## [1] "lumos"
##
## [[1]]$`Number of instruments`
## [1] 2
##
## [[1]]$Description
## [1] ""
##
## [[1]]$`Instrument model`
## [1] "Orbitrap Fusion Lumos"
##
## [[1]]$`Instrument name`
## [1] "Orbitrap Fusion Lumos"
##
## [[1]]$`Instrument method`
## [1] "C:/Xcalibur/methods/p3181/methMelt_GT20_RT35.meth"
##
## [[1]]$`Serial number`
## [1] "FSN20583"
##
## [[1]]$`Software version`
## [1] "3.1.2412.25"
##
## [[1]]$`Firmware version`
## [1] ""
##
## [[1]]$Units
## [1] "None"
##
## [[1]]$`Mass resolution`
## [1] "0.500"
##
## [[1]]$`Number of scans`
## [1] 8742
##
## [[1]]$`Number of ms2 scans`
## [1] 2346
##
## [[1]]$`Scan range`
## [1] 1 8742
##
## [[1]]$`Time range`
## [1] 0.00 35.01
##
## [[1]]$`Mass range`
## [1] 91 2000
##
## [[1]]$`Scan filter (first scan)`
## [1] "FTMS + c ESI Full ms [350.0000-2000.0000]"
##
## [[1]]$`Scan filter (last scan)`
## [1] "FTMS + c ESI Full ms [350.0000-2000.0000]"
##
## [[1]]$`Total number of filters`
## [1] "2205"
##
## [[1]]$`Sample name`
## [1] ""
##
## [[1]]$`Sample id`
## [1] "1:A,5"
##
## [[1]]$`Sample type`
## [1] "Unknown"
##
## [[1]]$`Sample comment`
## [1] ""
##
## [[1]]$`Sample vial`
## [1] "1:B,1"
##
## [[1]]$`Sample volume`
## [1] "0"
##
## [[1]]$`Sample injection volume`
## [1] "2"
##
## [[1]]$`Sample row number`
## [1] "0"
##
## [[1]]$`Sample dilution factor`
## [1] "1"
##
## [[1]]$`Sample barcode`
## [1] ""
##
## [[1]]$`User text 0`
## [1] ""
##
## [[1]]$`User text 1`
## [1] ""
##
## [[1]]$`User text 2`
## [1] ""
##
## [[1]]$`User text 3`
## [1] ""
##
## [[1]]$`User text 4`
## [1] ""
##
##
## [[2]]
## [[2]]$`RAW file`
## [1] "18af7e3d4e64_4590.raw"
##
## [[2]]$`RAW file version`
## [1] "66"
##
## [[2]]$`Creation date`
## [1] "11/16/2018 9:58:53 AM"
##
## [[2]]$Operator
## [1] "QexactiveHF"
##
## [[2]]$`Number of instruments`
## [1] 2
##
## [[2]]$Description
## [1] ""
##
## [[2]]$`Instrument model`
## [1] "Q Exactive HF Orbitrap"
##
## [[2]]$`Instrument name`
## [1] "Q Exactive HF Orbitrap"
##
## [[2]]$`Instrument method`
## [1] "C:/Xcalibur/methods/__QCloud/current_method/forward trap elute/autoQC01_TRAP_GT20min_RT35min.meth"
##
## [[2]]$`Serial number`
## [1] "Exactive Series slot #2496"
##
## [[2]]$`Software version`
## [1] "2.9-290204/2.9.2.2947"
##
## [[2]]$`Firmware version`
## [1] "rev. 1"
##
## [[2]]$Units
## [1] "None"
##
## [[2]]$`Mass resolution`
## [1] "0.500"
##
## [[2]]$`Number of scans`
## [1] 21881
##
## [[2]]$`Number of ms2 scans`
## [1] 20885
##
## [[2]]$`Scan range`
## [1] 1 21881
##
## [[2]]$`Time range`
## [1] 0 35
##
## [[2]]$`Mass range`
## [1] 100 1805
##
## [[2]]$`Scan filter (first scan)`
## [1] "FTMS + c NSI Full ms [350.0000-1800.0000]"
##
## [[2]]$`Scan filter (last scan)`
## [1] "FTMS + c NSI Full ms2 [email protected] [100.0000-1205.0000]"
##
## [[2]]$`Total number of filters`
## [1] "22"
##
## [[2]]$`Sample name`
## [1] "autoQC01"
##
## [[2]]$`Sample id`
## [1] "NA"
##
## [[2]]$`Sample type`
## [1] "Unknown"
##
## [[2]]$`Sample comment`
## [1] ""
##
## [[2]]$`Sample vial`
## [1] "1:F,8"
##
## [[2]]$`Sample volume`
## [1] "0"
##
## [[2]]$`Sample injection volume`
## [1] "2"
##
## [[2]]$`Sample row number`
## [1] "0"
##
## [[2]]$`Sample dilution factor`
## [1] "0"
##
## [[2]]$`Sample barcode`
## [1] ""
##
## [[2]]$`User text 0`
## [1] "1000"
##
## [[2]]$`User text 1`
## [1] ""
##
## [[2]]$`User text 2`
## [1] "FGCZ"
##
## [[2]]$`User text 3`
## [1] ""
##
## [[2]]$`User text 4`
## [1] ""
readRaw
- read Orbitrap raw fileread the two instrument raw files by using the rawDiag package.
## reading index for 18af63ffdf48_3238.raw...
## determining ElapsedScanTimesec ...
## reading trailer AGC ...
## reading trailer Orbitrap Resolution ...
## reading trailer Ion Injection Time (ms) ...
## reading TIC ...
## reading BasePeakIntensity ...
## reading took 5.486 seconds.
## reading index for 18af7e3d4e64_4590.raw...
## determining ElapsedScanTimesec ...
## reading trailer LM m/z-Correction (ppm) ...
## reading trailer AGC ...
## reading trailer AGC PS Mode ...
## reading trailer FT Resolution ...
## reading trailer Ion Injection Time (ms) ...
## reading TIC ...
## reading BasePeakIntensity ...
## reading took 11.502 seconds.
This package provides several plot functions tailored toward MS data. The following list shows all available plot methods.
library(rawDiag)
ls("package:rawDiag") |>
grep(pattern = '^plot', value = TRUE) -> pm
pm |>
knitr::kable(col.names = "package:rawDiag plot functions")
package:rawDiag plot functions |
---|
plotChargeState |
plotCycleLoad |
plotCycleTime |
plotInjectionTime |
plotLockMassCorrection |
plotMassDistribution |
plotMzDistribution |
plotPrecursorHeatmap |
plotScanTime |
plotTicBasepeak |
An inherent problem of visualizing data is the fact that depending on the data at hand, specific visualizations lose their usefulness, e.g., overplotting in a scatter plot if too many data points are present. To address this problem, we implemented most of the plot functions in different versions inspired by the work of Cleveland (1993), Sarkar (2008), and Wickham (2009). The data can be displayed in trellis plot manner using the faceting functionality of ggplot2. Alternatively, overplotting using color coding or violin plots based on descriptive statistics values can be chosen, which allows the user to interactively change the appearance of the plots based on the situation at hand. For instance, a large number of files are best visualized by violin plots, giving the user an idea about the distribution of the data points. On the basis of this, a smaller subset of files can be selected and visualized with another technique.
The code snippet below applies all plot methods on the example data.
pm |>
lapply(FUN = function(plotFUN) {
lapply(c('trellis'), function(method) {
message("plotting", plotFUN, "using method", method, "...")
do.call(plotFUN, list(x, method))
})
})
## plottingplotChargeStateusing methodtrellis...
## plottingplotCycleLoadusing methodtrellis...
## plottingplotCycleTimeusing methodtrellis...
## plottingplotInjectionTimeusing methodtrellis...
## plottingplotLockMassCorrectionusing methodtrellis...
## plottingplotMassDistributionusing methodtrellis...
## plottingplotMzDistributionusing methodtrellis...
## plottingplotPrecursorHeatmapusing methodtrellis...
## plottingplotScanTimeusing methodtrellis...
## plottingplotTicBasepeakusing methodtrellis...
## [[1]]
## [[1]][[1]]
##
##
## [[2]]
## [[2]][[1]]
## `geom_smooth()` using formula = 'y ~ x'
##
##
## [[3]]
## [[3]][[1]]
##
##
## [[4]]
## [[4]][[1]]
##
##
## [[5]]
## [[5]][[1]]
## Warning: Removed 6164 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 6164 rows containing missing values or values outside the scale range
## (`geom_line()`).
##
##
## [[6]]
## [[6]][[1]]
##
##
## [[7]]
## [[7]][[1]]
##
##
## [[8]]
## [[8]][[1]]
##
##
## [[9]]
## [[9]][[1]]
##
##
## [[10]]
## [[10]][[1]]
The appearance of each plot depends on the instrument, sample, and method used to acquire the data. Therefore, it is hard to say what each ideal plot should look like. In particular, in the example above, we use data generated on an Orbitrap Fusion Lumos, 18af63ffdf48_3238.raw and Q Exactive HF Orbitrap, 18af7e3d4e64_4590.raw instrument using data-independent acquisition (DIA) (Bruderer et al. 2017) and data-dependent acquisition (DDA) methods. For more information on the plot methods and its application, please read the package man pages and the application examples in the manuscript (Trachsel et al. 2018).
The package provides a simple interactive shiny-based graphical user interface for exploring Thermo Fisher Scientific raw data.
If you have a directory containing raw files, you can create a shiny application as follows:
The shiny runApp function launches the app in our browser.
By default, the application lets you choose the raw files in the provided directory and provides the visualizations of the raw data as output. The user can interactively change the by the rawDiag the package provided plot functions and arguments.
Additionally, the application provides PDF generation and download buttons. Optionally height and width can be changed in the user interface.
Of note, the rawDiag::rawDiagServer
module can be
integrated into an existing shinydashboard
application, e.g., https://shiny-ms.fgcz.uzh.ch/fgczmsqc-dashboard/.
consider all raw files of your working directory, e.g.,
~/Downloads
and load them.
file.path(Sys.getenv("HOME"), "Downloads") |>
setwd()
list.files() |>
grep(pattern = '*.raw$', value = TRUE) |>
lapply(FUN = rawDiag::readRaw) |>
Reduce(f = rbind) -> x
as alternative to lapply
you can utilize the BiocParallel
package bplapply
function.
## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 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=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] rawDiag_1.3.4 tartare_1.20.0 ExperimentHub_2.15.0
## [4] AnnotationHub_3.15.0 BiocFileCache_2.15.0 dbplyr_2.5.0
## [7] BiocGenerics_0.53.2 generics_0.1.3 BiocStyle_2.35.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.1 dplyr_1.1.4 farver_2.1.2
## [4] blob_1.2.4 filelock_1.0.3 Biostrings_2.75.1
## [7] fastmap_1.2.0 promises_1.3.0 digest_0.6.37
## [10] mime_0.12 lifecycle_1.0.4 KEGGREST_1.47.0
## [13] RSQLite_2.3.7 magrittr_2.0.3 compiler_4.4.2
## [16] rlang_1.1.4 sass_0.4.9 tools_4.4.2
## [19] utf8_1.2.4 yaml_2.3.10 knitr_1.49
## [22] labeling_0.4.3 bit_4.5.0 curl_6.0.0
## [25] plyr_1.8.9 BiocParallel_1.41.0 withr_3.0.2
## [28] purrr_1.0.2 sys_3.4.3 grid_4.4.2
## [31] stats4_4.4.2 fansi_1.0.6 xtable_1.8-4
## [34] colorspace_2.1-1 ggplot2_3.5.1 scales_1.3.0
## [37] cli_3.6.3 rmarkdown_2.29 crayon_1.5.3
## [40] httr_1.4.7 reshape2_1.4.4 rawrr_1.15.7
## [43] DBI_1.2.3 cachem_1.1.0 stringr_1.5.1
## [46] zlibbioc_1.52.0 splines_4.4.2 parallel_4.4.2
## [49] AnnotationDbi_1.69.0 BiocManager_1.30.25 XVector_0.47.0
## [52] vctrs_0.6.5 Matrix_1.7-1 jsonlite_1.8.9
## [55] IRanges_2.41.0 S4Vectors_0.45.1 bit64_4.5.2
## [58] maketools_1.3.1 fontawesome_0.5.2 jquerylib_0.1.4
## [61] hexbin_1.28.4 glue_1.8.0 codetools_0.2-20
## [64] stringi_1.8.4 gtable_0.3.6 BiocVersion_3.21.1
## [67] later_1.3.2 GenomeInfoDb_1.43.0 UCSC.utils_1.3.0
## [70] munsell_0.5.1 tibble_3.2.1 pillar_1.9.0
## [73] rappdirs_0.3.3 htmltools_0.5.8.1 GenomeInfoDbData_1.2.13
## [76] R6_2.5.1 evaluate_1.0.1 shiny_1.9.1
## [79] lattice_0.22-6 Biobase_2.67.0 png_0.1-8
## [82] memoise_2.0.1 httpuv_1.6.15 bslib_0.8.0
## [85] Rcpp_1.0.13-1 nlme_3.1-166 mgcv_1.9-1
## [88] xfun_0.49 buildtools_1.0.0 pkgconfig_2.0.3