-
Notifications
You must be signed in to change notification settings - Fork 0
/
MSnbaseBoxCar.Rmd
146 lines (110 loc) · 3.4 KB
/
MSnbaseBoxCar.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
title: "A prototype to process BoxCar data with MSnbase"
output:
BiocStyle::html_document:
toc_float: true
package: MSnbaseBoxCar
abstract: >
This package describes a simple prototype to process BoxCar
data using the MSnbase package. Is is meant as an illustration
of how to use `MSnbase` to prototype and develop computational
mass spectrometry methods and not to replace the reference
MaxQuant implementation.
vignette: >
%\VignetteIndexEntry{A prototype to process BoxCar data with MSnbase}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
%\VignettePackage{MSnbaseBoxCar}
%\VignetteDepends{MSnbase,BiocStyle,ggplot2}
---
```{r style, echo = FALSE, results = 'asis', message=FALSE}
BiocStyle::markdown()
```
# Preparation
Load required packages and functions.
```{r pkgs, message = FALSE}
library("MSnbase")
library("MSnbaseBoxCar")
library("ggplot2")
```
Read a small dataset composed of 16 MS1 spectra as an `MSnExp`:
```{r data}
f <- dir(system.file("extdata", package = "MSnbaseBoxCar"),
pattern = "boxcar.mzML",
full.names = TRUE)
basename(f)
x <- readMSData(f, mode = "onDisk")
x
```
# Define boxcar groups
Define boxcar groups based on the `filterString` metadata variable:
full scans are encoded as `"FTMS + p NSI Full ms
[375.0000-1800.0000]"` while their respective Boxcar scans reflect the
provide adjacent m/z segments `"FTMS + p NSI SIM msx ms
[299.0000-1701.0000, 299.0000-351.0000, ...]"`
```{r filterStrings}
fData(x)$filterString[1:4]
```
The `bc_groups` function identifies full (noted `NA`) and BoxCar
spectra and groups the latter:
```{r bc_groups}
x <- bc_groups(x)
fData(x)$bc_groups
```
# Keep only BoxCar spectra
The next filter BoxCar spectra, as defined above.
```{r bc_is_boxcar}
xbc <- filterBoxCar(x)
fData(xbc)$bc_groups
```
```{r bc_plot1, fig.cap = "Beginning of the first adjacent BoxCar segments."}
bc_plot(xbc[1:3]) +
xlim(440, 510)
```
# Combine BoxCar spectra
Remove any peaks outside of the BoxCar segments.
```{r bc_zero_out_box}
xbc <- bc_zero_out_box(xbc, offset = 0.5)
xbc
```
```{r bc_plot2, fig.cap = "Peaks outside of the BoxCar segments have been removed."}
bc_plot(xbc[1:3]) +
xlim(440, 510)
```
Combine BoxCar spectra to reconstitute the full scan and coerce result
back to an `MSnExp` object containing 4 spectra.
```{r combineSpectra}
res <- combineSpectra(xbc,
fcol = "bc_groups",
method = boxcarCombine)
res
```
```{r plot, fig.cap = "Reconstructed full spectrum."}
plot(res[[1]])
```
The above steps can also be piped into a single command.
```{r pipe, eval=FALSE}
library("magrittr")
res <- x %>%
bc_groups() %>%
filterBoxCar() %>%
bc_zero_out_box(offset = 0.5) %>%
combineSpectra(fcol = "groups",
method = boxcarCombine)
```
The processed data can also be written to a new mzML file.
```{r write, eval=FALSE}
writeMSData(res, "boxcar_processed.mzML")
```
# References
- [BoxCar acquisition method enables single-shot proteomics at a depth
of 10,000 proteins in 100
minutes](https://www.nature.com/articles/s41592-018-0003-5).
- [`MSnbase` - an R/Bioconductor package for isobaric tagged mass
spectrometry data visualization, processing and
quantitation](https://pubmed.ncbi.nlm.nih.gov/22113085/).
- `MSnbase` [webpage](http://lgatto.github.io/MSnbase/).
# Session information
```{r si}
sessionInfo()
```