-
Notifications
You must be signed in to change notification settings - Fork 0
/
shot_noise.qmd
275 lines (237 loc) · 6.18 KB
/
shot_noise.qmd
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
---
title: "Shot Noise Analysis"
author: "Kantnerova et al. (2023)"
date: "`r format(Sys.Date(), '%d %b %Y')`"
number-sections: false
toc: true
toc-depth: 2
fig-width: 8
fig-height: 6
df-print: tibble
embed-resources: true
format:
html:
code-tools: true
code-fold: false
code-summary: "Show the code"
toc-float: true
crossref:
fig-prefix: Fig.
tbl-prefix: Table
ref-hyperlink: true
editor: source
editor_options:
chunk_output_type: console
---
# Setup
Using `r R.version.string` , tidyverse version `r packageVersion("tidyverse")`, and isoorbi version `r packageVersion("isoorbi")`.
```{r}
#| label: setup
#| message: false
# load packages
library(isoorbi) # for orbitrap function
library(dplyr) # for mutating data frames
library(forcats) # for recoding factors
library(ggplot2) # for data visualization
library(cowplot) # arrange multipanel plots
```
```{r, include=FALSE}
# global knitting options for code rendering
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>",
dev = c("png", "pdf"), fig.keep = "all",
dev.args = list(pdf = list(encoding = "WinAnsi", useDingbats = FALSE)),
fig.path = sprintf("plots/%s_", gsub("\\.rmarkdown", "", knitr::current_input()))
)
```
# Trifluoroacetate (TFA)
## Data
```{r}
# load, process, and export tfa data
data_tfa <-
"data/shot_noise/tfa" |>
orbi_find_isox() |>
orbi_read_isox() |>
orbi_simplify_isox() |>
orbi_flag_satellite_peaks() |>
orbi_flag_weak_isotopocules(min_percent = 10) |>
orbi_flag_outliers(agc_fold_cutoff = 2) |>
orbi_define_basepeak("M0")
shot_noise_tfa <-
data_tfa |>
orbi_analyze_shot_noise() |>
orbi_export_data_to_excel("output/shot_noise_tfa.xlsx")
```
## Bonus Figure: TFA satellite peaks
```{r}
#| label: fig-bonus-tfa-satellite-peaks
#| fig-cap: Satellite peaks
#| fig-width: 15
#| fig-height: 5
#| warning: false
data_tfa |> orbi_plot_satellite_peaks()
```
## Bonus Figure: TFA isotopocule coverage
```{r}
#| label: fig-bonus-tfa-isotopocule-coverage
#| fig-cap: Isotopocule coverage
#| fig-width: 15
#| fig-height: 3
#| warning: false
data_tfa |> orbi_plot_isotopocule_coverage()
```
## Bonus Figure: TFA ratios
```{r}
#| label: fig-bonus-tfa-ratios
#| fig-cap: Isotopocule ratios vs. M0
#| fig-width: 15
#| fig-height: 5
#| warning: false
data_tfa |> orbi_plot_raw_data(y = ratio)
```
## Figure 10: TFA shotnoise vs counts/time
```{r}
#| label: fig-10-shotnoise-tfa
#| fig-cap: Shot noise vs counts and vs time.
#| fig-width: 10
#| fig-height: 5
#| warning: false
# individual plots
tfa_vs_ions <-
shot_noise_tfa |>
orbi_filter_isox(filename = "TFA_M0_1uscan_15kRes") |>
orbi_plot_shot_noise(x = "n_effective_ions") +
labs(title = "vs counts") +
theme(plot.title = element_text(hjust = 0.5))
tfa_vs_time <-
shot_noise_tfa |>
orbi_filter_isox(filename = "TFA_M0_1uscan_15kRes") |>
orbi_plot_shot_noise(permil_target = 1) +
labs(title = "vs time") +
theme(plot.title = element_text(hjust = 0.5))
# combine
plot_grid(
tfa_vs_ions + theme(legend.position = c(0.85, 0.74)),
tfa_vs_time + theme(legend.position = "none"),
align = "h", nrow = 1, axis = "tb"
)
```
## Extended Data Figure 6: TFA shotnoise at different IT
```{r}
#| label: fig-ext-data-6-shotnoise-tfa-ITs
#| fig-cap: Shot noise at different ITs.
#| fig-width: 10
#| fig-height: 5
#| warning: false
shot_noise_tfa |>
orbi_filter_isox(filename = c("TFA_1E4_AGC", "TFA_M0_1uscan_15kRes")) |>
# change color legend
mutate(
IT_info = filename |>
fct_recode(
"IT = 0.03 ms" = "TFA_1E4_AGC",
"IT = 0.75 ms" = "TFA_M0_1uscan_15kRes"
)
) |>
orbi_plot_shot_noise(color = "IT_info") +
# wrap by the ratio label
facet_wrap(~ratio_label) +
theme(legend.position = c(0.41, 0.75))
```
## Extended Data Figure 7: TFA shotnoise at different resolutions
```{r}
#| label: fig-ext-data-7-shotnoise-tfa-resolution
#| fig-cap: Shot noise at different resolutions.
#| fig-width: 10
#| fig-height: 5
#| warning: false
shot_noise_tfa |>
orbi_filter_isox(filename = c("TFA_M0_1uscan_120kRes", "TFA_M0_1uscan_15kRes")) |>
# change color legend
mutate(
res_info = filename |>
fct_recode(
"res. = 120k" = "TFA_M0_1uscan_120kRes",
"res. = 15k" = "TFA_M0_1uscan_15kRes"
)
) |>
orbi_plot_shot_noise(color = "res_info") +
# wrap by the ratio label
facet_wrap(~ratio_label) +
theme(legend.position = c(0.42, 0.75))
```
# Model Peptide (MRFA)
## Data
```{r}
# load, process, and export mrfa data
data_aas <-
"data/shot_noise/mrfa" |>
orbi_find_isox() |>
orbi_read_isox() |>
orbi_simplify_isox() |>
orbi_flag_satellite_peaks() |>
orbi_flag_weak_isotopocules(min_percent = 10) |>
orbi_flag_outliers(agc_fold_cutoff = 2) |>
orbi_define_basepeak("M0") |>
mutate(
compound = compound |>
fct_recode(
"Alanine" = "Ala_imm",
"Arginine" = "Arg_imm",
"Methionine" = "Met_imm",
"Phenylalanine" = "Phe_imm"
)
)
shot_noise_aas <-
data_aas |>
orbi_analyze_shot_noise() |>
orbi_export_data_to_excel("output/shot_noise_MRFA.xlsx")
```
## Table
```{r}
# example of first few rows
shot_noise_aas |>
arrange(compound, isotopocule, scan.no) |>
select(compound, scan.no, time.min, isotopocule,
ratio, ratio_rel_se.permil, shot_noise.permil) |>
head(10) |>
knitr::kable()
```
## Bonus Figure: Amino Acids satellite peaks
```{r}
#| label: fig-bonus-mrfa-satellite-peaks
#| fig-cap: Satellite peaks
#| fig-width: 10
#| fig-height: 9
#| warning: false
data_aas |> orbi_plot_satellite_peaks()
```
## Bonus Figure: Amino Acids isotopocule coverage
```{r}
#| label: fig-bonus-mrfa-isotopocule-coverage
#| fig-cap: Isotopocule coverage
#| fig-width: 10
#| fig-height: 9
#| warning: false
data_aas |> orbi_plot_isotopocule_coverage()
```
## Bonus Figure: Amino Acids ratios
```{r}
#| label: fig-bonus-mrfa-ratios
#| fig-cap: Isotopocule ratios vs. M0
#| fig-width: 10
#| fig-height: 9
#| warning: false
data_aas |> orbi_plot_raw_data(y = ratio)
```
## Extended Data Figure 8: Amino Acids Shot Noise
```{r}
#| label: fig-ext-data-8-shotnoise-mrfa
#| fig-cap: amino acids shotnoise
#| warning: false
#| fig-width: 8
#| fig-height: 10
shot_noise_aas |>
filter(compound == "Methionine" | isotopocule != "2H") |>
orbi_plot_shot_noise()
```