knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
In this document we are presenting a workflow of retention-time alignment across multiple Targeted-MS (e.g. DIA, SWATH-MS, PRM, SRM) runs using DIAlignR. This tool requires MS2 chromatograms and provides a hybrid approach of global and local alignment to establish correspondence between peaks.
if(!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("DIAlignR")
library(DIAlignR)
Mass-spectrometry files mostly contains spectra. Targeted proteomics workflow identifyies analytes from their chromatographic elution profile. DIAlignR extends the same concept for retention-time (RT) alignment and, therefore, relies on MS2 chromatograms. DIAlignR expects raw chromatogram file (.chrom.sqMass) and FDR-scored features (.osw) file.
Example files are available with this package and can be located with this command:
dataPath <- system.file("extdata", package = "DIAlignR")
| (Optional) To obtain files for alignment, following three steps are needed (Paper):
bash
commands to be used: ```{bash, eval=FALSE} OpenSwathWorkflow -in Filename.mzML.gz -tr library.pqp -tr_irt iRTassays.TraML -out_osw Filename.osw -out_chrom Filename.chrom.mzML OpenSwathMzMLFileCacher -in Filename.chrom.mzML -out Filename.chrom.sqMass -lossy_compression false
| Output files **Filename.osw** and **Filename.chrom.sqMass** are required for next steps. Note: If you prefer to use chrom.mzML instead of chrom.sqMass, some chromatograms are stored in compressed form and currently inaccesible by `mzR`. In such cases `mzR` would throw an error indicating `Invalid cvParam accession "1002746"`. To avoid this issue, uncompress chromatograms using OpenMS. ```{bash, eval=FALSE} FileConverter -in Filename.chrom.mzML -in_type 'mzML' -out Filename.chrom.mzML
```{bash, eval=FALSE} pyprophet merge --template=library.pqp --out=merged.osw *.osw pyprophet score --in=merged.osw --classifier=XGBoost --level=ms1ms2 pyprophet peptide --in=merged.osw --context=experiment-wide
| Congrats! Now we have raw chromatogram files and associated scored features in merged.osw files. Move all .chrom.sqMass files in `xics` directory and merged.osw file in `osw` directory. The parent folder is given as `dataPath` to DIAlignR functions. ## Performing alignment on DIA runs There are three modes for multirun alignment: star, MST and Progressive. The functions align proteomics or metabolomics DIA runs. They expect two directories "osw" and "xics" at `dataPath`, and output an intensity table where rows specify each analyte and columns specify runs. ```r runs <- c("hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt", "hroest_K120809_Strep10%PlasmaBiolRepl2_R04_SW_filt") params <- paramsDIAlignR() params[["context"]] <- "experiment-wide"
# For specific runs provide their names. alignTargetedRuns(dataPath = dataPath, outFile = "test", runs = runs, oswMerged = TRUE, params = params) # For all the analytes in all runs, keep them as NULL. alignTargetedRuns(dataPath = dataPath, outFile = "test", runs = NULL, oswMerged = TRUE, params = params)
For MST alignment, a precomputed guide-tree can be supplied.
tree <- "run2 run2\nrun1 run0" mstAlignRuns(dataPath = dataPath, outFile = "test", mstNet = tree, oswMerged = TRUE, params = params) # Compute tree on-the-fly mstAlignRuns(dataPath = dataPath, outFile = "test", oswMerged = TRUE, params = params)
Similar to previous approach, a precomputed guide-tree can be supplied.
text1 <- "(run1:0.08857142857,(run0:0.06857142857,run2:0.06857142857)masterB:0.02)master1;" progAlignRuns(dataPath = dataPath, outFile = "test", newickTree = text1, oswMerged = TRUE, params = params) # Compute tree on-the-fly progAlignRuns(dataPath = dataPath, outFile = "test", oswMerged = TRUE, params = params)
In a large-scale study, the pyprophet merge
would create a huge file that can't be fit in the memory. Hence, scaling-up of pyprophet based on subsampling is recommended. Do not run the last two
commands pyprophet backpropagate
and pyprophet export
, as these commands
copy scores from model_global.osw
to each run, increasing the size unnecessarily.
Instead, use oswMerged = FALSE
and scoreFile=PATH/TO/model_global.osw
.
We can plot the chromatograms as well. First we fetch chromatograms which is a list of matrices.
dataPath <- system.file("extdata", package = "DIAlignR") runs <- c("hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt", "hroest_K120809_Strep10%PlasmaBiolRepl2_R04_SW_filt") XICs <- getXICs(analytes = 4618L, runs = runs, dataPath = dataPath, oswMerged = TRUE)
Then we plot the XICs:
plotXICgroup(XICs[["hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt"]][["4618"]])
For getting alignment object which has aligned indices of XICs getAlignObjs
function can be used. Like previous function, it expects two directories "osw" and "xics" at dataPath
. It performs alignment for exactly two runs. In case of refRun
is not provided, m-score from osw files is used to select reference run.
runs <- c("hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt", "hroest_K120809_Strep10%PlasmaBiolRepl2_R04_SW_filt") AlignObjLight <- getAlignObjs(analytes = 4618L, runs = runs, dataPath = dataPath, objType = "light", params = params) # First element contains names of runs, spectra files, chromatogram files and feature files. AlignObjLight[[1]][, c("runName", "spectraFile")] obj <- AlignObjLight[[2]][["4618"]][[1]][["AlignObj"]] slotNames(obj) names(as.list(obj)) AlignObjMedium <- getAlignObjs(analytes = 4618L, runs = runs, dataPath = dataPath, objType = "medium", params = params) obj <- AlignObjMedium[[2]][["4618"]][[1]][["AlignObj"]] slotNames(obj)
Alignment object has slots * indexA_aligned aligned indices of reference chromatogram. * indexB_aligned aligned indices of experiment chromatogram * score cumulative score of the alignment till an index. * s similarity score matrix. * path path of the alignment through similarity score matrix.
We can visualize aligned chromatograms using plotAlignedAnalytes
. The top figure is experiment unaligned-XICs, middle one is reference XICs, last figure is experiment run aligned to reference.
runs <- c("hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt", "hroest_K120809_Strep10%PlasmaBiolRepl2_R04_SW_filt") AlignObj <- getAlignObjs(analytes = 4618L, runs = runs, dataPath = dataPath, params = params) plotAlignedAnalytes(AlignObj, annotatePeak = TRUE)
We can also visualize the alignment path using plotAlignemntPath
function.
library(lattice) runs <- c("hroest_K120809_Strep0%PlasmaBiolRepl2_R04_SW_filt", "hroest_K120809_Strep10%PlasmaBiolRepl2_R04_SW_filt") AlignObjOutput <- getAlignObjs(analytes = 4618L, runs = runs, params = params, dataPath = dataPath, objType = "medium") plotAlignmentPath(AlignObjOutput)
Gupta S, Ahadi S, Zhou W, Röst H. "DIAlignR Provides Precise Retention Time Alignment Across Distant Runs in DIA and Targeted Proteomics." Mol Cell Proteomics. 2019 Apr;18(4):806-817. doi: https://doi.org/10.1074/mcp.TIR118.001132
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.