-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.Rmd
More file actions
159 lines (123 loc) · 5.09 KB
/
Copy pathindex.Rmd
File metadata and controls
159 lines (123 loc) · 5.09 KB
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
---
title: ""
output: html_document
---
<br>
### Rapid detection of glycoalkaloids in ***Solanum. scabrum*** and ***S. nigrum*** berries using ultra-high performance liquid chromatography with pathway-specified in-source fragmentation tandem mass spectrometry
<br>
**Lyu Weiting, Bo Yuan ** *Updated on Jan 6, 2020*
<br>
```{r, message=F, warning=F}
library(readxl)
library(rebus)
library(broom)
library(RColorBrewer)
library(viridis)
library(gridExtra)
library(cowplot)
library(scales)
library(plotly)
library(circlize)
library(ggrepel)
library(tidyverse)
```
```{r, message=F, warning=F}
theme_set(theme_bw() +
theme(axis.text = element_text(size = 13, color = "black"),
axis.title = element_text(size =13, face = "bold", color = "black"),
legend.text = element_text(size = 13, color = "black"),
legend.title = element_text(size = 13, color = "black")))
```
### ESI Optimization by CCD
```{r, message=F, warning=F}
path = "/Users/Boyuan/Desktop/My publication/N.S. fruit alkaloid quant QqQ/Publish ready files/ALL DATA.xlsx"
d = read_excel(path, sheet = "ESI Central composite design")
a = seq(from = -1, to = 1, by = .02)
x = rep( a , each = 101)
y = rep( a, 101)
p = data.frame(x,y)
p1 <- p %>%
mutate(`Gas temp` = 250 + 50 * p$x) %>%
mutate(`Sheath temp` = 250 + 50 * p$y) %>%
mutate(
`253.1 transition` = -5.08e+02 + 1.827 * `Gas temp` + 3.43 * `Sheath temp` + -1.57e-03 * `Gas temp` * `Gas temp` + -1.57e-03 * `Sheath temp` * `Sheath temp` + -6.00e-03 * `Gas temp` * `Sheath temp`,
percent.253 = `253.1 transition` / max(`253.1 transition`) * 100,
`271.2 transition` = -2.02e+02 + 3.99e-01 * `Gas temp` + 1.61 * `Sheath temp` + 2.00e-04 * `Gas temp` * `Gas temp` + -1.20e-03 * `Sheath temp` * `Sheath temp` + -2.600e-03 * `Gas temp` * `Sheath temp`,
percent.271 = `271.2 transition` / max(`271.2 transition`) * 100,
`396.4 transition` = -2.78e+02 + 2.49e-01 * `Gas temp` + 2.72e+00 * `Sheath temp` + 1.03e-03 * `Gas temp` * `Gas temp` + -7.65e-04 * `Sheath temp` * `Sheath temp` + -4.90e-03 * `Gas temp` * `Sheath temp`,
percent.396 = `396.4 transition` / max(`396.4 transition`) * 100)
# tidy up
p1 = p1 %>% select(-contains("transition")) %>%
gather(-c(1:4), key = transition, value = percent)
```
```{r, message=F, warning=F}
# plot countour plot
plt.countour = p1 %>%
ggplot(aes(`Gas temp`, `Sheath temp`, z = percent)) +
geom_tile(aes(fill = percent)) +
scale_fill_viridis(option = "A") +
stat_contour(color = "white", size = 0.2) +
facet_wrap(~transition, nrow = 3) +
coord_fixed() +
theme(strip.background = element_blank(),
strip.text = element_blank()) +
labs(x = ("Gas Temperature (??C)"),
y = ("Sheath Temperature(??C)") )
# plt.countour
```
### Fragmentor voltage optimization
```{r, message=F, warning=F}
# frgamentor test plot
f = read_excel(path, sheet = "Fragmentor voltage")
plt.fragmentor = f %>% gather(-1, key = transition, value = "response") %>%
ggplot(aes(x = fragmentor, y = response)) +
geom_line(color = "steelblue" , size = 1) +
geom_point(size = 3, shape = 21, fill = "white", color = "steelblue", stroke = 1) +
geom_text_repel(aes(label = `fragmentor`),
color = "firebrick", nudge_y = +5, size = 3.6 )+
facet_wrap(~transition, nrow = 3, scales = "free_y") +
ylab(" Peak area ") +
xlab(" Fragmentor(V) ") +
theme(strip.background = element_blank(),
strip.text = element_blank())
# plt.fragmentor
```
### Collision energy optimization
```{r, message=F, warning=F}
CE = read_excel(path, sheet = "Collision energy")
plt.CE = CE %>% gather(-1, key = "transition", value = "response.CE") %>%
ggplot(aes(x = `collison energy`, y = response.CE )) +
facet_wrap(~transition, scales = "free_y", nrow = 3) +
geom_line(color = "steelblue" , size = 1) +
geom_point(size = 3, shape = 21, fill = "white", color = "steelblue", stroke = 1) +
geom_text_repel(aes(label = `collison energy`),
nudge_y = +5, color = "firebrick", size = 3.6) +
theme(strip.background = element_blank(),
strip.text = element_blank()) +
ylab(" Peak area ")
# plt.CE
```
### Optimization plots
```{r, message=F, warning=F, fig.width=12, fig.height=8}
# facet wrap all plot
plot_grid(plt.countour, plt.fragmentor, plt.CE,
nrow = 1, rel_widths = c(4, 3, 3))
```
### MRM statistics
```{r, message=F, warning=F}
m = read_excel(path, sheet = "MRMs")
m = m %>%
mutate(`peak width (sec)` = factor(`peak width (sec)`),
`dwell time (ms)` = factor(`dwell time (ms)`),
group = str_c("PW ", `peak width (sec)`, "; ", "DT ", `dwell time (ms)`))
m %>%
ggplot(aes(x = `transition number`, y = `data points collected`,
color = `dwell time (ms)`, shape = `peak width (sec)`)) +
geom_point(size = 3) +
geom_line(aes(group = group)) +
scale_y_log10() + annotation_logticks(sides = "l") +
scale_color_brewer(palette = "Set1") +
theme(legend.position = c(.8, .75)) +
labs(y = "Data points collected across a chromatographic peak",
x = "MRM transition numbers")
```