-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod-development-and-validation.html
1298 lines (1117 loc) · 60.1 KB
/
method-development-and-validation.html
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>HILIC UHPLC-MS/MS Method Development & Validation</title>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
</style>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
</style>
<style type="text/css">
/* padding for bootstrap navbar */
body {
padding-top: 51px;
padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar) */
.section h1 {
padding-top: 56px;
margin-top: -56px;
}
.section h2 {
padding-top: 56px;
margin-top: -56px;
}
.section h3 {
padding-top: 56px;
margin-top: -56px;
}
.section h4 {
padding-top: 56px;
margin-top: -56px;
}
.section h5 {
padding-top: 56px;
margin-top: -56px;
}
.section h6 {
padding-top: 56px;
margin-top: -56px;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #ffffff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.parent().addClass('active');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row-fluid">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="method-development-and-validation.html">LC-MS/MS</a>
</li>
<li>
<a href="AIV_profile_analysis.html">AIV amino acids</a>
</li>
<li>
<a href="Machine_learning_Classification.html">Machine learning</a>
</li>
<li>
<a href="ShinyML.html">Interactive Shiny</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">HILIC UHPLC-MS/MS Method Development & Validation</h1>
</div>
<br>
<p>The R code has been developed with reference to <a href="https://r4ds.hadley.nz/">R for Data Science (2e)</a>, and the
official documentation of <a href="https://www.tidyverse.org/">tidyverse</a>, and <a href="https://www.databrewer.co/"><strong>DataBrewer.co</strong></a>.
See breakdown of modules below:</p>
<ul>
<li><p><strong>Data visualization</strong> with <strong>ggplot2</strong> (<a href="https://www.databrewer.co/R/visualization/introduction">tutorial</a>
of the fundamentals; and <a href="https://www.databrewer.co/R/gallery">data
viz. gallery</a>).</p></li>
<li><p><a href="https://www.databrewer.co/R/data-wrangling"><strong>Data
wrangling</strong> </a> with the following packages: <a href="https://www.databrewer.co/R/data-wrangling/tidyr/introduction"><strong>tidyr</strong></a>,
transform (e.g., pivoting) the dataset into tidy structure; <a href="https://www.databrewer.co/R/data-wrangling/dplyr/0-introduction"><strong>dplyr</strong></a>,
the basic tools to work with data frames; <a href="https://www.databrewer.co/R/data-wrangling/stringr/0-introduction"><strong>stringr</strong></a>,
work with strings; <a href="https://www.databrewer.co/R/data-wrangling/regular-expression/0-introduction"><strong>regular
expression</strong></a>: search and match a string pattern; <a href="https://www.databrewer.co/R/data-wrangling/purrr/introduction"><strong>purrr</strong></a>,
functional programming (e.g., iterating functions across elements of
columns); and <a href="https://www.databrewer.co/R/data-wrangling/tibble/introduction"><strong>tibble</strong></a>,
work with data frames in the modern tibble structure.</p></li>
</ul>
<br>
<pre class="r"><code>library(readxl)
library(RColorBrewer)
library(rebus)
library(gtools)
library(gridExtra)
library(cowplot)
library(ggrepel)
library(tidyverse)</code></pre>
<pre class="r"><code>theme_set(theme_bw() +
theme(strip.background = element_blank(),
strip.text = element_text(face = "bold"),
title = element_text(colour = "black", face = "bold"),
axis.text = element_text(colour = "black")))</code></pre>
<pre class="r"><code># All data Excel
path = "/Users/Boyuan/Desktop/My publication/16. HILIC amino acid machine learning to J. Chroma A/Publish-ready files/Method development and validation.xlsx"</code></pre>
<div id="method-development" class="section level1">
<h1><span class="header-section-number">1</span> Method Development</h1>
<div id="mobile-phase-buffer-optimization" class="section level2">
<h2><span class="header-section-number">1.1</span> Mobile phase buffer optimization</h2>
<div id="retention-time" class="section level3">
<h3><span class="header-section-number">1.1.1</span> Retention time</h3>
<pre class="r"><code>## Read and tidy up data
df.buffer = read_excel(path, sheet = "mobile phase buffer") # mobile phase buffer optimization dataset
df.AA = read_excel(path, sheet = "amino acids") # amino acids traits dataset
df.buffer = df.buffer %>% left_join(df.AA, by = "Amino acids") # combine datasets
df.buffer$`Amino acids` %>% unique() # Check all amino acids are properly registered (ensure there is NO datasets mis-match)</code></pre>
<pre><code>## [1] "Alanine" "Arginine" "Asparagine" "Aspartic acid" "Cysteine"
## [6] "Glutamic acid" "Glutamine" "Glycine" "Histidine" "Isoleucine"
## [11] "Leucine" "Lysine" "Methionine" "Phenylalanine" "Proline"
## [16] "Serine" "Threonine" "4-hydroxyproline" "Tryptophan" "Tyrosine"
## [21] "Valine"</code></pre>
<pre class="r"><code>df.buffer$Conc.mM = df.buffer$Conc.mM %>%
factor(levels = rev(unique(df.buffer$Conc.mM)), ordered = T) # convert buffer conc. into factors
## Plot RT over mobile phase buffer concentration
AA.colors = colorRampPalette(c("#333333", brewer.pal(8, "Dark2")))(21) # set up colors for all 21 amino acids, applied for all following amino acids color assignemnt
dodge.RT = 0.5 # data points random scatterness to avoid overlapping
plt.buffer.RT = df.buffer %>%
ggplot(aes(x = Conc.mM, y = RT, color = `Amino acids`, fill = `Amino acids`, group = `Amino acids`)) +
geom_line(alpha = 0.5, position = position_dodge(dodge.RT)) +
geom_label(aes(label = Abbrev.I),
label.padding = unit(0.1, "lines"), color = "white", size = 2.8,
position = position_dodge(dodge.RT)) +
scale_y_continuous(breaks = seq(2, 10, 1)) +
theme(axis.text = element_text(size = 10),
axis.title = element_text(size = 10),
legend.position = "None") +
# labs(x = "Ammonium formate concentration (mM)", y = "Retention time (min)",
# caption = "The column void time is 1 min. \nRetention factor could be calculated accordingly. \nSample solvent was 50:50 ACN:H2O") +
scale_color_manual(values = AA.colors) +
scale_fill_manual(values = AA.colors)
# plt.buffer.RT</code></pre>
</div>
<div id="peak-width" class="section level3">
<h3><span class="header-section-number">1.1.2</span> Peak width</h3>
<pre class="r"><code>## Plot peak width over mobile phase buffer concentration
dodge.width = 0.4
plt.buffer.width = df.buffer %>%
ggplot(aes(x = Conc.mM, y = Width, color = `Amino acids`, fill = `Amino acids`, group = `Amino acids`)) +
geom_line(alpha = 0.2, position = position_dodge(dodge.width)) +
geom_label(aes(label = Abbrev.I), label.padding = unit(0.08, "lines"),
color = "white", position = position_dodge(dodge.width), size = 2.8) +
theme(axis.text = element_text(size = 10),
axis.title = element_text(size = 10),
legend.position = "None") +
scale_color_manual(values = AA.colors) +
scale_fill_manual(values = AA.colors) +
coord_cartesian(ylim = c(0.028, 0.22))
# labs(x = "Ammonium formate concentration (mM)",
# y = "Peak width at half maximum (min)",
# caption = "The column void time is 1 min. \nRetention factor could be calculated accordingly. \nSample solvent was 50:50 ACN:H2O")
# plt.buffer.width</code></pre>
</div>
<div id="peak-area" class="section level3">
<h3><span class="header-section-number">1.1.3</span> Peak area</h3>
<pre class="r"><code>## Plot peak area over mobile phase buffer concentration
dodge.area.perc = 0.5
df.buffer = df.buffer %>% group_by(`Amino acids`) %>%
mutate(Area.percent = Area/max(Area)*100) # normalize to percent of maximum for each amino acids
plt.buffer.area = df.buffer %>%
ggplot(aes(x = Conc.mM, y = Area.percent, fill = `Amino acids`, color = `Amino acids`, group = `Amino acids`)) +
geom_line(alpha = 0.3, position = position_dodge(dodge.area.perc)) +
geom_label(aes(label = Abbrev.I),
label.padding = unit(0.1, "lines"), color = "white", size = 2.8,
position = position_dodge(dodge.RT)) +
scale_y_continuous(breaks = seq(0, 100, 20)) +
theme(axis.text = element_text(size = 10),
axis.title = element_text(size = 10),
legend.position = "None") +
scale_color_manual(values = AA.colors) +
scale_fill_manual(values = AA.colors) +
labs(x = "Ammonium formate concentration (mM)", y = "Area percentage")
# scale_y_log10() + annotation_logticks(sides = "l")
# plt.buffer.area</code></pre>
</div>
<div id="combine-rt-width-response" class="section level3">
<h3><span class="header-section-number">1.1.4</span> Combine RT + width + response</h3>
<pre class="r"><code>## Plot Area & RT & Width together
grid.arrange(plt.buffer.area, plt.buffer.RT, plt.buffer.width, nrow = 1)</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-7-1.png" width="1152" /></p>
</div>
<div id="resolution-of-leu-vs.ile" class="section level3">
<h3><span class="header-section-number">1.1.5</span> Resolution of Leu vs. Ile</h3>
<pre class="r"><code>## Plot resolution of leucine vs. Isoleucine
df.buffer %>% filter(`Amino acids` == "Isoleucine") %>%
mutate(Resolution = as.numeric(Resolution)) %>%
ggplot(aes(x = Conc.mM, y = Resolution, group = `Amino acids`)) +
geom_bar(stat = "identity") +
geom_line() + geom_point()</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-8-1.png" width="960" /></p>
</div>
</div>
<div id="sample-solvent-acidifier-optimization" class="section level2">
<h2><span class="header-section-number">1.2</span> Sample solvent acidifier optimization</h2>
<div id="response-linearity" class="section level3">
<h3><span class="header-section-number">1.2.1</span> Response linearity</h3>
<pre class="r"><code>## Read data and tidy up
df.acid.resp = read_excel(path, sheet = "sample solvent acid_response") # read Exel sheet
df.acid.resp = df.acid.resp %>% gather(-c(solvent, sample), key = compound, value = resp) # gather compounds
df.acid.resp = df.acid.resp[complete.cases(df.acid.resp), ] # remove missing value rows
df.resp.zero = df.acid.resp %>% filter(resp == 0) # mark out resp = 0 rows for deletion in sheet "sample solvent acid_RT" to be analyzed later
df.acid.resp = df.acid.resp %>%
mutate(conc.level =
df.acid.resp$sample %>% str_extract(pattern = "-" %R% one_or_more(DGT)) %>%
str_extract(one_or_more(DGT)) %>% as.integer(), # extract concentration level
conc = 1000 / 2 ^ (conc.level - 1), # set up concentration
day.rep = df.acid.resp$sample %>% str_extract(pattern = or("2nd", "3rd")) %>%
str_extract(DIGIT) %>% na.replace("1") %>% as.character()) %>% # extract day replicate
select(-sample) %>% # remove now useless column
filter(resp > 0) # remove undetected entries (shifted outside dMRM time window due to solvent effect; low level of concentration)</code></pre>
<pre class="r"><code>## Arrange compounds in order of response susceptability to solvent acid composition
df.acid.susceptibility = df.acid.resp %>%
group_by(compound, conc.level) %>%
summarise(resp.var.level.sol = sd(resp)/mean(resp) ) %>%
group_by(compound) %>%
summarise(resp.var.sol = mean(resp.var.level.sol)) %>%
arrange(resp.var.sol)
cmpd.ordered.smpl.acid.susceptable = df.acid.susceptibility$compound</code></pre>
<pre class="r"><code>## Plot peak area vs. different acid composition for ALL compounds
acid.color = c("black", brewer.pal(9, "Set1")[ c(1:2) ], "#009900") # black, (red, blue, from package), and dark green
plt.acid.response.all.compounds = df.acid.resp %>%
mutate(compound = factor(compound, levels = cmpd.ordered.smpl.acid.susceptable, ordered = T)) %>%
filter(day.rep != 3) %>% # remove 3rd day replicate as data is not complete over all calibration range
ggplot(aes(x = conc, y = resp, shape = day.rep, color = solvent)) +
geom_line(size = .2) +
geom_point() +
facet_wrap(~compound, scales = "free_y", nrow = 4) +
theme(legend.position = "bottom", strip.text = element_text( size = 11),
axis.text = element_text(color = "black", size = 10)) +
scale_shape_manual(values = c(16, 17, 18)) +
scale_x_log10() + scale_y_log10() + annotation_logticks() +
scale_color_manual( values = acid.color ) +
labs(caption = "Arranged in order of increasing susceptability to solvent acid composition,
replicated in three days, with injection of the same set of calibration samples stored in 4C autosampler")
plt.acid.response.all.compounds</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-11-1.png" width="1344" /></p>
<pre class="r"><code>## Plot peak area vs. different acid composition for representative compounds (of different susceptability)
acid.cmpd.selected = factor(
c("Histidine", "Lysine", "Arginine", "Tyrosine", "Methionine", "Glutamic acid", "Threonine", "Proline", "Alanine"),
ordered = T)
plt.acid.response.selected.compounds = df.acid.resp %>%
filter(compound %in% acid.cmpd.selected) %>%
mutate(compound = factor(compound, levels = acid.cmpd.selected, ordered = T)) %>%
filter(day.rep != 3) %>% # remove 3rd day replicate as data is not complete over all calibration range
ggplot(aes(x = conc, y = resp, shape = day.rep, color = solvent)) +
geom_line(size = .2) +
geom_point() +
facet_wrap(~compound, scales = "free_y", nrow = 3) +
theme(strip.text = element_text(size = 10.5),
axis.text = element_text(size = 11)) +
scale_shape_manual(values = c(16, 17, 18)) +
scale_x_log10() + scale_y_log10() + annotation_logticks() +
scale_color_manual( values = acid.color ) +
labs(caption = "Replicated in three days (4 °C),
with injection of the same set of calibration samples",
title = "Response linearity with different acidifier in sample solvent")
# plt.acid.response.selected.compounds</code></pre>
<p>To faciliate visualization and examination, the calibration is logarithmically transformed. As y = ax + b, b is usually small and negligible, the calibration may be re-written as logy = log(ax) = loga + logx, i.e., the transformed results remain linearity, with the intercept loga reflecting sensiviity.</p>
</div>
<div id="retention-time-shift" class="section level3">
<h3><span class="header-section-number">1.2.2</span> Retention time shift</h3>
<pre class="r"><code>## Read data and tidy up
df.acid.RT = read_excel(path, sheet = "sample solvent acid_RT")
df.acid.RT = df.acid.RT %>% gather(-c(solvent, sample), key = compound, value = RT)
df.acid.RT = anti_join(df.acid.RT, df.resp.zero, by=c("sample", "compound")) # remove response = zero rows (from prior response dataset)
## RT stats summary
df.acid.RT.summary = df.acid.RT %>%
group_by(compound, solvent) %>%
summarise(RT.mean = mean(RT), RT.std = sd(RT)) %>%
arrange(RT.mean)
df.acid.RT.FA = df.acid.RT.summary %>%
filter(solvent == "0.1% FA") %>%
rename(RT.FA.mean = RT.mean, RT.FA.std = RT.std) %>%
select(-solvent) # 0.1% FA RT as comparison reference
df.acid.RT.summary = df.acid.RT.summary %>%
left_join(df.acid.RT.FA, by = c("compound"))
## RT difference relative to 0.1% FA
df.acid.RT.diff = df.acid.RT.summary %>%
mutate(RT.diff.mean = RT.mean - RT.FA.mean,
RT.diff.std = sqrt(RT.std^2 + RT.FA.std^2)) %>% # var(X + Y) = var(X) + var(Y), X and Y independent
filter(solvent != "0.1% FA")
## Order sequence in RT diff
cmpd.ordered.acid.RT.diff = (
df.acid.RT.diff %>%
group_by(compound) %>%
summarise(overal.diff = mean(RT.diff.mean)) %>%
arrange(overal.diff))$compound</code></pre>
<pre class="r"><code>## Plot RT difference using different sample acids relative to using 0.1% FA
plt.acid.RT.diff = df.acid.RT.diff %>%
ungroup() %>%
mutate(compound = factor(compound, levels = cmpd.ordered.acid.RT.diff, ordered = T)) %>%
ggplot(aes(x = compound, y = RT.diff.mean, fill = solvent, color = solvent)) +
geom_bar(stat = "identity", position = position_dodge(.5), alpha = .6, color = NA) +
coord_flip() +
geom_errorbar(aes(ymin = RT.diff.mean - RT.diff.std, ymax = RT.diff.mean + RT.diff.std),
width = .5, position = position_dodge(.5)) +
theme(axis.text = element_text(size = 10)) +
scale_y_reverse() +
scale_fill_manual(values = acid.color[-1]) +
scale_color_manual(values = acid.color[-1])
# plt.acid.RT.diff</code></pre>
</div>
<div id="combine-rt-width-response-1" class="section level3">
<h3><span class="header-section-number">1.2.3</span> Combine RT + width + response</h3>
<pre class="r"><code>## Plot combined response curve and RT shift
plot_grid(plt.acid.response.selected.compounds + theme(legend.position = "bottom"),
plt.acid.RT.diff + theme(legend.position = "bottom"),
nrow = 1, rel_widths = c(.6, .35)) # 16.7 X 8.3</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-15-1.png" width="1728" /></p>
<p>For plot on the right, some compounds shifted outside dMRM detection range at 100 mM HCl, and thus the RT not reported.</p>
</div>
</div>
</div>
<div id="method-validation" class="section level1">
<h1><span class="header-section-number">2</span> Method Validation</h1>
<div id="calibration-curve" class="section level2">
<h2><span class="header-section-number">2.1</span> Calibration curve</h2>
<div id="residual-analysis" class="section level3">
<h3><span class="header-section-number">2.1.1</span> Residual analysis</h3>
<p>For residual analysis, we use the concept of “calibration accuracy”, which is defined as the back-calculated concentration based on constructed calibration divided by expected concentration.</p>
<pre class="r"><code>#### PART I: CALIBRATION RESIDUAL ANALYSIS (CALIBRATION ACCURACY)
## Import data and tidy up
# Dataset of concentration for each level of each amino acid
df.cal.conc = read_excel(path, sheet = "Calibration conc. ng.mL-1", range = "A1:W61")
df.cal.conc.tidy = df.cal.conc %>%
gather(-c(`sample name`, level), key = compounds, value = exp.content.ng.perML)
# Dataset of lowest level of calibration
df.cal.lowestLevel = read_excel(path, sheet = "Calibration conc. ng.mL-1", range = "C64:W65")
df.cal.lowestLevel.tidy = df.cal.lowestLevel %>% gather(key = compounds, value = lowestLevel)
# Dataset of calibration accuracy for each amino acid at each level
df.cal.accuracy = read_excel(path, sheet = "Calibration_accuracy")
df.cal.accuracy.tidy = df.cal.accuracy %>%
gather(-c(`sample name`, `file name`, level), key = compounds, value = accuracy) %>%
filter(accuracy >0) # remove accuracy = 0 rows (manually zeroed peak areas for calibrator points not included in the calibration range)
## Dataset of calibration response
df.cal.resp = read_excel(path, sheet = "Calibration_response")
df.cal.resp.tidy = df.cal.resp %>%
gather(-c(`sample name`, `file name`, level), key = compounds, value = resp) %>%
filter(resp > 0) # remove area = 0 rows (manually zeroed peak areas for calibrator points not included in the calibration range)
# augment with actual expected concentration and response
df.cal.accuracy.tidy = df.cal.accuracy.tidy %>%
left_join(df.cal.conc.tidy, by = c("compounds", "level", "sample name")) %>%
left_join(df.cal.resp.tidy, by = c("sample name", "file name", "compounds", "level"))</code></pre>
<pre class="r"><code># Statistical analysis and visualizaiton
# Calibration accuracy visualization
plt.cal.accuracy = df.cal.accuracy.tidy %>%
ggplot(aes(x = exp.content.ng.perML, y = accuracy, color = compounds)) +
geom_segment(aes(x = 0, xend = df.cal.accuracy.tidy$exp.content.ng.perML %>% max(),
y = 100, yend = 100),
linetype = "dashed", size = .2, color = "black") +
annotate(geom = "rect", xmin = 0, xmax = df.cal.accuracy.tidy$exp.content.ng.perML %>% max(),
ymin = 90, ymax = 110, fill = "dark green", alpha = .1) +
geom_point(size = .5, alpha = .8) +
scale_x_log10() +
annotation_logticks(sides = "b") +
scale_y_continuous(limits = c(0, 200), breaks = seq(0, 200, 20)) +
theme(legend.position = "None", title = element_text(face = "bold")) +
ggtitle("Calibration accuracy") +
scale_color_manual(values = AA.colors)
# plt.cal.accuracy</code></pre>
</div>
<div id="dilution-error-based-on-residual-analysis" class="section level3">
<h3><span class="header-section-number">2.1.2</span> Dilution error based on residual analysis</h3>
<pre class="r"><code>df.dilutionError = df.cal.accuracy.tidy %>%
group_by(compounds, level) %>%
mutate(error.percent = abs((resp - mean(resp)) / mean(resp)) * 100) %>% # normalize as percent relative to the mean at each level
summarise(error.percent.mean = mean(error.percent)) %>% # normalized response variance
ungroup() %>%
mutate(level = as.numeric(level),
level.max = max(level),
dilutionSteps = level.max -level) # all levels uniformly converted to number of dilution steps
plt.dilutionError = df.dilutionError %>%
ggplot(aes(x = dilutionSteps, y = error.percent.mean, color = compounds)) +
geom_smooth(method = "lm", se = F, aes(group = 1), color = "black",
size = 5, alpha = .05) +
geom_smooth(method = "lm", se = F, aes(group = compounds)) +
geom_point() + geom_line(alpha = .2) +
scale_color_manual(values = AA.colors) +
scale_y_log10() + annotation_logticks(side = "l") +
theme(legend.position = "NA") +
labs(title = "Error propogation in calibration dilution steps",
y = "Error percent", x = "Dilution steps form stock solution (step 0)") +
# add amino acid label
geom_text(data = df.dilutionError %>% filter(dilutionSteps ==0),
aes(x = -0.5, label = compounds), size = 3)
# plt.dilutionError</code></pre>
<pre class="r"><code>StepError = lm(error.percent.mean ~ dilutionSteps, data = df.dilutionError) %>%
summary()
StepError</code></pre>
<pre><code>##
## Call:
## lm(formula = error.percent.mean ~ dilutionSteps, data = df.dilutionError)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.990 -3.417 -1.757 1.511 34.033
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.1999 0.6712 4.767 3.17e-06 ***
## dilutionSteps 0.5224 0.1003 5.208 3.97e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5.787 on 251 degrees of freedom
## Multiple R-squared: 0.09753, Adjusted R-squared: 0.09394
## F-statistic: 27.13 on 1 and 251 DF, p-value: 3.973e-07</code></pre>
</div>
<div id="combine-residual-dilution-error-pattern" class="section level3">
<h3><span class="header-section-number">2.1.3</span> Combine residual + dilution error pattern</h3>
<pre class="r"><code>plot_grid(plt.cal.accuracy, plt.dilutionError, nrow = 1, align = "h")</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-20-1.png" width="1152" /></p>
<p><strong>In plot on the left</strong>: The calibration accuracy is defined as (the back-calculated concentration based on measured peak area and constructed calibration) divided by (expected concentration). Each different color represents one amino acids (color legend not shown), and each amino acid presents two to four (mostly four; significant outliers manually removed) calibrators at each concentration level. For most compounds at majority of levels and most calibrators fall within the ideal 90~110 calibration accuracy range.</p>
<p>At more diluted level, the accuracy fanned out, because: 1) at low conc. the peak area is more susceptabile to integration inconsistency; 2) perhaps more importantly, as four sets of calibration from the same stock solution were separately prepared, more diluted calibrators presented accumulated error incremented along multiple dilution steps. This effect is demonstrated in the following plot.</p>
<p><strong>In plot on the right</strong>: Each different color represents one amino acid, with cooresponding label on the left side of the plot. For each amino acids, the absolute error percent at adjacent levels are connected with faint colored line, and the trend of change in the absolute error percent is approximated using simple linear regression. While the intercept and slope differ for varied amino acids, due to their different chromatographic or mass spectrometric performance, the change in error percent generally follows up an increasing linear trend, approximated by the thick black regression line, which roughly reflects the rate of error accumulation at each dilution step. In this case, it is 0.52%.</p>
<p>The intercept reflects the averaged absolute error percentage measured at the first calibrator, which following calibrators are diluted from. Certain compounds, such as cysteine and glutamic acid has rather high error percentage, due to their degradation occuring between the injections (the injection of each calibrator of the same concentration level was evenly spaced across a total sequence time of 60 hours)</p>
</div>
<div id="linearity-visualization" class="section level3">
<h3><span class="header-section-number">2.1.4</span> Linearity visualization</h3>
<pre class="r"><code># import calibration intercept dataset (with 1/x weight)
df.cal.intercept = read_excel(path, sheet = "Calibration_intercept")
# augment calibration dataset with cal curve intercept with 1/x weighe
df.cal.accuracy.tidy = df.cal.accuracy.tidy %>%
left_join(df.cal.intercept, by = "compounds") %>%
# y = ax + b convert to y-b = ax, for visualization purpose
mutate(resp.subtractIntercept = resp - `intercept.1/x.weight`)
# plot
plt.calibrationCurve = df.cal.accuracy.tidy %>%
ggplot(aes(x = exp.content.ng.perML, y = resp.subtractIntercept, color = compounds)) +
geom_smooth(method = "lm", se = F, size = .5, color = "firebrick") +
geom_point(alpha = .6) +
facet_wrap(~compounds, scales = "free", nrow = 3) +
scale_x_log10() + scale_y_log10() + annotation_logticks() +
labs(caption = "Each level composed of 2~4 calibrators") +
scale_color_manual(values = AA.colors) +
labs(x = "Concentration (ng/mL)", y = "Response with intercept subtracted",
caption = "Intercept with 1/x weight was subtracted from peak response,
Both x and y scales are logarithmically transformed,
That is, what is plotted is not y = ax + b, but log(y-b) = log(ax) = log(a) + log(x)") +
theme(legend.position = "NA")
plt.calibrationCurve</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-21-1.png" width="1152" /></p>
<p>For calibration function, y-b = ax, which is re-written as log (y - b) = log a + log x. Recall that in the previous plot of solvent impact, the intercept b term was ignored; in this case, however, ignoring the b term caused curvature at low level of concentration.</p>
</div>
</div>
<div id="accuracy-and-matrix-effects" class="section level2">
<h2><span class="header-section-number">2.2</span> Accuracy and matrix effects</h2>
<div id="accuracy" class="section level3">
<h3><span class="header-section-number">2.2.1</span> Accuracy</h3>
<pre class="r"><code># measured injecton concentration
df.inj.conc = read_excel(path, sheet = "validation injection conc.", range = "A1:X90")
# Remove a few significantly bad-performing samples after manual check
df.inj.conc = df.inj.conc %>% filter(!Sample %in% c("Accuracy_F_r3.d", "matrix effect_f_r2", "matrix effect_g_r1"))
# standard stock concentration
df.stock.conc = read_excel(path, sheet = "validation spike amount", range = "A1:B22")
# standard stock spike volume
df.spk.volume = read_excel(path, sheet = "validation spike amount", range = "A25:B32")
# Compute background.
# Note the concentration, ng/mL, track back to original extract, i.e., before 100-fold dilution
df.background = df.inj.conc %>% filter(Purpose == "Background") %>%
select(-c(Purpose, Sample, Level)) %>%
gather(key = compounds, value = background) %>%
group_by(compounds) %>%
summarise(
# background / background content mean level and dispersion
background.mean = mean(background * 100),
background.sd = sd(background * 100))
# injection concentration associated with accuracy computation
df.inj.conc.accuracy = df.inj.conc %>% filter(Purpose == "Accuracy") %>%
gather(-c(Purpose, Sample, Level), key = compounds, value = conc.inj)
# df.inj.conc.accuracy</code></pre>
<pre class="r"><code># Compute stats of the quality control sample (QC) spiked with standards
# Compute final concentration expected, and expected deviation from background
df.QC = (x = df.inj.conc.accuracy %>% select(Level, compounds))[!duplicated(x), ] %>% # compound-level combination
left_join(df.spk.volume, by = "Level") %>% # spike volume for different levels
mutate(plantExtractVol.uL = 800, # plant extract volume
# dilute factor after spiking
SpikeDiluteFactor = (plantExtractVol.uL + SpikeVol.uL)/SpikeVol.uL,
BackgroundDiluteFactor = (plantExtractVol.uL + SpikeVol.uL)/plantExtractVol.uL) %>%
left_join(df.background, by = "compounds") %>%
left_join(df.stock.conc, by = "compounds") %>%
mutate(
# the following three lines are the component-wise concentration with correction of dilution effect of spiking
# the concentration is that of QC, prior to 100-fold dilution;
# all three conc. marked as "QC", vs. the original plant extract marked as "background"
QC.background.mean = background.mean / BackgroundDiluteFactor,
QC.background.sd = background.sd/BackgroundDiluteFactor, # the original background deviation shrinks after spike-induced dilution
# spiked amount
QC.Spike.Expected = `Stock.conc.ug/mL` / SpikeDiluteFactor * 1000) # converting concentration to ng/mL
# compute expected component-wise concentration at injection
df.inj.conc.expected = df.QC %>%
# remove some redundant columns
select(-contains("Vol.uL")) %>% # remove spike and plant extract volume columns
select(-c(background.mean, background.sd)) %>% # remove original plant extract mean and deviation (prior to spike)
# all three concentration marked as "inj", after 100-fold dilution
mutate(inj.conc.background.mean = QC.background.mean / 100,
inj.conc.background.sd = QC.background.sd / 100,
inj.conc.Spike.Expected = QC.Spike.Expected / 100)
# df.inj.conc.expected</code></pre>
<pre class="r"><code># compute measured concentration at injection
df.accuracy = df.inj.conc.accuracy %>%
group_by(compounds, Level) %>%
summarise(conc.inj.mean = mean(conc.inj),
conc.inj.sd = sd(conc.inj)) %>%
# combine the expected level
left_join(df.inj.conc.expected, by = c("compounds", "Level")) %>%
# compute stats summary
mutate(Accuracy = (conc.inj.mean - inj.conc.background.mean) / inj.conc.Spike.Expected * 100,
Accuracy.sd = sqrt(conc.inj.sd^2 + inj.conc.background.sd^2) / inj.conc.Spike.Expected * 100 )
df.accuracy</code></pre>
<pre><code>## # A tibble: 147 x 15
## # Groups: compounds [21]
## compounds Level conc.inj.mean conc.inj.sd SpikeDiluteFact… BackgroundDilut… `Stock.conc.ug/… QC.background.m…
## <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4-hydrox… A/a 3403. 62.9 1.8 2.25 570. 12.5
## 2 4-hydrox… B/b 2344. 23.9 2.6 1.62 570. 17.3
## 3 4-hydrox… C/c 1223. 21.4 5 1.25 570. 22.5
## 4 4-hydrox… D/d 681. 9.89 9 1.12 570. 25.0
## 5 4-hydrox… E/e 356. 3.48 17 1.06 570. 26.4
## 6 4-hydrox… F/f 146. 6.83 41 1.02 570. 27.4
## 7 4-hydrox… G/g 78.7 6.90 81 1.01 570. 27.7
## 8 alanine A/a 2189. 59.7 1.8 2.25 350 8782.
## 9 alanine B/b 1625. 20.2 2.6 1.62 350 12159.
## 10 alanine C/c 952. 21.9 5 1.25 350 15807.
## # … with 137 more rows, and 7 more variables: QC.background.sd <dbl>, QC.Spike.Expected <dbl>,
## # inj.conc.background.mean <dbl>, inj.conc.background.sd <dbl>, inj.conc.Spike.Expected <dbl>,
## # Accuracy <dbl>, Accuracy.sd <dbl></code></pre>
<pre class="r"><code># Visualize accuracy
dg.Acc = .6 # position_dodge value
errorBarWidth = 1
plt.accuracy = df.accuracy %>% ggplot(aes(x = compounds, y = Accuracy, color = Level)) +
geom_errorbar(aes(ymin = Accuracy - Accuracy.sd,
ymax = Accuracy + Accuracy.sd),
width = errorBarWidth, position = position_dodge(dg.Acc)) +
geom_point(shape = 21, size = 2.5, fill = "white", position = position_dodge(dg.Acc)) +
coord_flip(ylim = c(50, 150)) +
annotate("rect", xmin = .5, xmax = 21.5, ymin = 80, ymax = 120, alpha = .1, fill = "black") +
annotate("segment", x = .5, xend = 21.5, y = 100, yend = 100, linetype = "dashed", size = .4) +
scale_color_brewer(palette = "Dark2")
# plt.accuracy</code></pre>
</div>
<div id="spike-level-vs.background" class="section level3">
<h3><span class="header-section-number">2.2.2</span> Spike level vs. background</h3>
<pre class="r"><code># spike amount vs. background level
plt.spike.background = df.accuracy %>%
mutate(spike.vs.background = inj.conc.Spike.Expected / inj.conc.background.mean) %>%
ggplot(aes(x = spike.vs.background, y = compounds, color = Level)) +
geom_point(shape = 21, size = 2.5, stroke = 1) +
scale_x_log10() + annotation_logticks(side = "b") +
scale_color_brewer(palette = "Dark2")
plt.spike.background</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-26-1.png" width="672" /></p>
<pre class="r"><code># Accuracy variance vs. (spike amount vs. background) scatter plot
`plt.AccuracyVariance.vs.(spike vs background).scatter` =
df.accuracy %>%
ggplot(aes(x = inj.conc.Spike.Expected / inj.conc.background.mean,
y = Accuracy.sd, color = Level)) +
geom_point(shape = 21, size = 2.5, stroke = 1) +
scale_x_log10() + scale_y_log10() + annotation_logticks() +
scale_color_brewer(palette = "Dark2") +
# accuracy standard deviation line: 10%
geom_segment(aes(x = .1, xend = 30000, y = 20, yend = 20), linetype = "dashed", color = "black", size = .1) +
# 50% spike amount vs background ratio
geom_segment(aes(x = .5, xend = .5, y = .1, yend = 110), linetype = "dashed", color = "black", size = .1) +
theme(legend.position = c(.8, .75), panel.grid = element_blank()) +
geom_text_repel(data = df.accuracy %>% filter(Accuracy.sd > 20),
aes(label = compounds))
# `plt.AccuracyVariance.vs.(spike vs background).scatter`</code></pre>
<pre class="r"><code># Accuracy variance vs. (spike amount vs. background) bar plot
`plt.AccuracyVariance.vs.(spike vs background).barplot` =
df.accuracy %>%
ggplot(aes(x = compounds,
y = inj.conc.Spike.Expected / inj.conc.background.mean,
fill = Level, color = Level)) +
geom_bar(stat = "identity", position = position_dodge(.7), alpha = .6) +
scale_color_brewer(palette = "Dark2") +
scale_fill_brewer(palette = "Dark2") +
scale_y_log10() + coord_flip() +
labs(y = "Spike amount vs. background level ratio")
# `plt.AccuracyVariance.vs.(spike vs background).barplot`</code></pre>
<pre class="r"><code>grid.arrange(`plt.AccuracyVariance.vs.(spike vs background).scatter`,
`plt.AccuracyVariance.vs.(spike vs background).barplot`,
nrow = 1)</code></pre>
<p><img src="method-development-and-validation_files/figure-html/unnamed-chunk-29-1.png" width="1056" /></p>
<pre class="r"><code># Blank measurement contribution to accuracy deviation
plt.accuracy.variance.decomposition = df.accuracy %>%
select(compounds, Level, inj.conc.background.sd, conc.inj.sd) %>%
gather(-c(1:2), key = sd.source, value = sd) %>%
mutate(sd.squared = sd^2) %>%
ggplot(aes(x = compounds, y = sd.squared, fill = sd.source)) +
geom_bar(stat = "identity", position = "fill") +
facet_wrap(~Level, nrow = 1) + coord_flip() +
theme(legend.position = "bottom",
axis.text.x = element_text(angle = 45, vjust = .7),
axis.title.x = element_blank()) +
labs(title = "Accuracy variance partition into background and spiked QC sample")
plt.accuracy.variance.decomposition</code></pre>