-
Notifications
You must be signed in to change notification settings - Fork 0
/
NLME_Analysis_Full Code.Rmd
3666 lines (2769 loc) · 138 KB
/
NLME_Analysis_Full Code.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
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
---
title: "**THE UTILITY OF MIXED-EFFECT MODELS IN THE EVALUATION OF COMPLEX GENOMIC TRAITS IN-VITRO**"
author:
- Nathan Alade, M.S.^[University of Washington, Department of Pharmaceutics]
- Abhinav Nath, Ph.D.^[University of Washington, Department of Medicinal Chemistry]
- Nina Isoherannen, Ph.D.*
- Kenneth Thummel, Ph.D.*
date: "Last compiled on: `r format(Sys.time(), '%B %d, %Y')`"
output:
bookdown::pdf_document2:
toc: yes
number_sections: yes
highlight: kate
citation_package: natbib
latex_engine: xelatex
bookdown: default
subtitle: |
| **Supplementary Data:** Complete R Code
bibliography: packages.bib
csl: American_Chemical_Society.csl
include-before:
- '`\newpage{}`{=latex}'
---
\newpage
# **Correspondence**
**Corresponding Author:** Nathan Alade, M.S.
**Address:**
- University of Washington School of Pharmacy
- Department of Pharmaceutics
- H-272 Health Sciences Building, Box 357610
- Seattle, Washington 98195
**Email:** [alade\@uw.edu](mailto:alade@uw.edu){.email}
**Phone:** 206-543-9434
**Fax:** 206-543-3204
### **Data Availability:**
R Scripts and data necessary to reproduce our analysis are available and can be cloned using the following public repository. (<http://nathanalade.github.io/In-Vitro-NLME/>)
\newpage
# **Introduction**
## Abstract
The use of human liver microsomes as a model system to evaluate the impact of complex genomic traits (i.e., linkage-disequilibrium patterns, coding, and non-coding variation, etc.) on drug metabolism remains challenging. To overcome these challenges, we propose the use of non-linear mixed effect models (NLME) as an unconventional approach to evaluate the impact of complex genomic traits on the metabolism of xenobiotics in vitro. In this in-silico study, we present a practical use case for such an approach using previously published in-vitro CYP2D6 data and explore the impact of sparse sampling, and experimental error on known kinetic parameter of CYP2D6 mediated formation of 4-hydroxy-atomoxetine in human liver microsomes.
## Objective
This supplement provides the `R` code used to conduct the *in-silico* portion of the study, as well as useful functions for evaluating/visualizing results.
# **R Libraries and Packages**
```{r setup, include=FALSE, warning=FALSE}
# Setup ------
knitr::opts_chunk$set(echo = TRUE, cache = F,
results = "hide",
warning = FALSE,
message = F,
eval = FALSE)
```
```{r Packages, eval=T}
# R Packages -----
library(nlme) # Non-Linear Mixed Effect Modeling
library(tidyverse) # Data Manipulation and Visualization
library(ggeasy) # Wrapper for Plot Manipulation
library(ggpubr) # Additional Tools for Plot Configuration
library(scales) # Additional Tools for Adjusting Plot Scales
library(cowplot) # Data Visualization Themes and Tools
library(kableExtra) # Additional Tools for Creating Custom Tables
# Package References -------
knitr::write_bib(c(.packages()), "References/packages.bib")
```
Citation information for R packages [@R-base; @R-cowplot; @R-dplyr; @R-ggeasy; @R-ggplot2; @R-ggpubr; @R-kableExtra; @R-nlme; @R-readr; @R-scales; R-tibble; @R-tidyr; @R-tidyverse; @ggplot22016; @nlme2000; @tidyverse2019] used for data can be found in the *References* section.
\newpage
# **R Session Information**
```{r results='markup', eval=T}
# Session Information ------
sessionInfo()
```
\newpage
# **Importing Data**
CYP2D6 mean estimates and frequencies (Dinh et. al., 2016) were imported and summarized by genotype (***referred to as diplotype in R script***). Additionally, an Eta table and parameter estimate table were also generated to be reference later on in the data analysis.
-------------------------------------------------------
```{r Data Import}
# Atomoxetine Dataset (Dinh et al., 2016)
atx.data <- readxl::read_xlsx("Input Data/Atomoxetine Data - 2016.xlsx")
# Summary of Atomoxetine Data by genotype ----
diplotype.data <- atx.data %>%
group_by(Diplotype) %>%
# Summarize mean estimates of the data
summarise(Vmax = mean(Vmax),
Km = mean(Km),
Score = unique(`Activity Score`),
n = n()) %>%
ungroup() %>%
mutate(Freq = n/sum(n),
Vmax.Eta = ifelse(Diplotype != "1/1",
round(Vmax-Vmax[Diplotype == "1/1"],
digits = 2),
round(Vmax, digits = 2)),
Km.Eta = ifelse(Diplotype != "1/1",
round(Km-Km[Diplotype == "1/1"],
digits = 2),
round(Km, digits = 2))) %>%
select(-n)
# Eta Table (Deviations from the reference group) -----
actual.eta <- diplotype.data %>%
select(Diplotype, Vmax.Eta, Km.Eta) %>%
rename("Vmax" = "Vmax.Eta",
"Km" = "Km.Eta") %>%
pivot_longer(Vmax:Km, names_to = "Parameter",
values_to = "Actual") %>%
arrange(desc(Parameter))
# mean estimates of Vmax and Km for each genotype -----
actual.est <- diplotype.data %>%
select(Diplotype, Vmax, Km) %>%
pivot_longer(Vmax:Km, names_to = "Parameter",
values_to = "Actual") %>%
mutate(Actual = round(Actual, digits = 2)) %>%
arrange(desc(Parameter))
```
\newpage
# **Virtual Population**
## Population Simulation Function
A custom simulation function `population.sim()` was scripted to generate a virtual population with a pre-defined distribution of *CYP2D6* genotypes, and to simulate Michaelis-Menten kinetics for each individual. The inputs for the function the `population.sim()` include the following:
- **n** - number of subjects per genotype group (default = 10).
- **CV%\_D** - Average standard deviation for each genotype group as a percentage of the true estimate for Vmax and Km (between subject variability for each genotype group) (default = 25).
- **CV%\_V** - Average coefficient of variation across all points for simulated Michaelis-Menten kinetics for each individual (residual error).
- **Start** - Starting concentration from Michaelis-Menten simulation (default = 0).
- **End** - Ending concentration for Michaelis menten Kinetics (default = 100 uM).
- **By** - Simulated concentration increment (default = 0.5).
- **pop_freq** - TRUE or FALSE argument indicating whether to use true population frequency (default is FALSE).
- **seed** - Random number generator seed (for reproducibility, default = 23457).
- **data** - Dataframe to be used as reference for population averages. Must include genotype, Vmax, Km, and Frequency columns (default = `diplotype.data`).
Within-group between subject variability was set at 25% CV for each genotype (one standard deviation = 0.25 x mean of true value). Below is a simulated population containing 9000 individuals (1000 per diplotype groups) with mean and standard deviations for each group parameter.
-------------------------------------------------------
```{r Simulation Function}
population.sim <- function(
# Pre-define number of subjects per diplotype group
n = 10,
`CV%_D` = 25,
`CV%_V` = 0,
# Pre-define Michaelis Menten Kinetic Settings
Start = 0,
End = 100,
By = 0.5,
# Turn off or on use of true population frequency
## If set to true "n" will equal total population number
pop_freq = FALSE,
# Pre-define reference data, and set seed
data = diplotype.data,
seed = 23456){
# ======== Create Data Containers ========
datasets <- list()
pop.data <- tibble()
# ======== Create Datasets by Diplotype ========
for (i in seq_along(data[[1]])){
# Setting Population Specific Frequency
n_pop <- if_else(pop_freq == FALSE, n,
ifelse(pop_freq == TRUE,
round(n*data[[i, c("Freq")]]), 0))
# Specify Diplotype for current loop
Diplotype = rep(data[[i,1]], n_pop)
# Random assignment of Vmax values N(0,sigma)
set.seed(seed)
Vmax_eta <- rnorm(n_pop, sd = `CV%_D`)
Vmax = data[[i,2]] + (Vmax_eta/100)*data[[i,2]]
# Random assignment of Km values N(0,sigma)
set.seed(seed)
Km_eta <- rnorm(n_pop, sd = `CV%_D`)
Km = data[[i,3]] + (Km_eta/100)*data[[i,3]]
# Store each diplotype group in a list container
temp <- tibble(Diplotype, Vmax, Km)
datasets[[i]] <- temp
}
# ======== Combine Diplotype Datasets ========
for (i in seq_along(data[[1]])){
pop.data <- rbind(pop.data, datasets[[i]])
}
# ======== Simulate Michaelis Menten ========
set.seed(seed)
pop.data <- pop.data %>%
mutate(ID = factor(seq_along(Diplotype),
levels = seq_along(Diplotype))) %>%
relocate(ID) %>%
expand_grid(S = seq(Start, End, By)) %>%
mutate(V = round((Vmax*S)/(Km+S), digits = 2))%>%
group_by(ID) %>%
# Additon of Residual Error ------------
mutate(resid_pct = round(rnorm(n = length(S),sd = `CV%_V`),
digits = 3),
V_adj = V+(V*resid_pct/100)) %>%
ungroup()
return(pop.data)
}
```
## Distribution of Virtual Population Parameters
```{r Vmax and Km Distribution, fig.asp=1.2, fig.keep='last'}
dist.plot <- ggplot(
data = population.sim(n=1000,`CV%_D` = 25, Start = 0.5,
By = 5, pop_freq = F) %>%
group_by(ID) %>%
filter(S == min(S)),
aes(x = Vmax))+
geom_histogram(aes(fill = Diplotype), color = "black", bins = 100)+
ggeasy::easy_remove_legend_title()+
theme_bw(base_size = 14)+
xlab(bquote(V[Max]))+
ylab("Population (n)")
dist.grb <- dist.plot +
ggeasy::easy_remove_legend() +
scale_x_log10()+
xlab("Log Scale")+
ylab("Count (n)")
dist.plot2 <- ggplot(
data = population.sim(n=1000,`CV%_D` = 25, Start = 0.5,
By = 5, pop_freq = F) %>%
group_by(ID) %>%
filter(S == min(S)),
aes(x = Km))+
geom_histogram(aes(fill = Diplotype), color = "black", bins = 100)+
ggeasy::easy_remove_legend_title()+
theme_bw(base_size = 14)+
xlab(bquote(K[M](uM)))+
ylab("Population (n)")+
scale_x_log10()
dist.grb2 <- dist.plot +
ggeasy::easy_remove_legend() +
scale_x_log10()+
xlab("Log Scale")+
ylab("Count (n)")
## Vmax and Km Distribution Plots
ggpubr::ggarrange(dist.plot +
annotation_custom(ggplotGrob(dist.grb),
xmin = 1000, xmax = 2500,
ymin = 250, ymax = 1250),
dist.plot2, ncol = 1, common.legend = T, legend = "right")
```
## Virtual Population Vmax and Km Distribution Table
```{r Vmax and Km Distribution Table}
population.sim(n = 1000, End = 0,`CV%_D` = 25) %>%
group_by(Diplotype) %>%
summarise(Vmax_mean = round(mean(Vmax),2),
Vmax_sd = round(sd(Vmax),2),
Km_mean = round(mean(Km),2),
Km_sd = round(sd(Km),2),
`n` = length(Vmax),
Vmax = paste0(Vmax_mean," ± ",Vmax_sd),
Km = paste0(Km_mean," ± ",Km_sd)) %>%
ungroup() %>%
left_join(diplotype.data %>%
mutate(across(where(is.numeric), round, 2)) %>%
select(Diplotype, Vmax, Km) %>%
rename("Actual (Vmax)" = "Vmax", "Actual (Km)" = "Km"),
by = "Diplotype") %>%
select(Diplotype,`Actual (Vmax)`, Vmax, `Actual (Km)`,Km, n) %>%
rename("Simulated." = "Vmax",
"Simulated" = "Km",
"Actual." = "Actual (Vmax)",
"Actual" = "Actual (Km)") %>%
kbl(table.attr = "style='width:60%;'",
caption = "Simulated Population Parameter Estimates") %>%
kable_classic("striped", full_width = T) %>%
add_header_above(c(" ", "Vmax Estimate" = 2, "Km Estimate" = 2, " "))
```
## Incorporation of Experimental Error
Residual error was added to simulated data using a constant coefficient of variation structure, where the observed metabolic rate (*V~obs~*)for the *i*^th^individual at the *j*^th^ substrate incubation concentration. The residual errors (*ε~i~*) were normally distributed with a mean of 0 and a standard deviation (*σ*) set at the following values: 0, 0.05, 0.10, or 0.2; corresponding to a coefficient of variation (CV%) of 0%, 5%, 10%, and 20%.
-------------------------------------------------------
```{r fig.asp=0.9}
# Error Design Datatable -------
error_design.data <- rbind(population.sim(n=3, Start = 0, By = 0.1, `CV%_V` = 0) %>%
filter(Diplotype == "1/1") %>% mutate(Condition = "0% CV"),
population.sim(n=3, Start = 0, By = 0.1, `CV%_V` = 5) %>%
filter(Diplotype == "1/1") %>% mutate(Condition = "5% CV"),
population.sim(n=3, Start = 0, By = 0.1, `CV%_V` = 10) %>%
filter(Diplotype == "1/1") %>% mutate(Condition = "10% CV"),
population.sim(n=3, Start = 0, By = 0.1, `CV%_V` = 20) %>%
filter(Diplotype == "1/1") %>% mutate(Condition = "20% CV")) %>%
filter(S %in% c(0.1, 0.5, 1, 2, 5, 10, 15, 25, 40, 55, 70, 85, 100)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Rich Design (9 pts)")
# Assigning Condition as Ordered Factor -----------
error_design.data$Condition <- factor(error_design.data$Condition,
levels = c("0% CV","5% CV","10% CV","20% CV"))
# Simulation Grid ---------
error.nls <- nls(formula = V ~ (Vmax*S)/(Km + S), data = error_design.data,
start = list(Vmax = 350, Km = 2))
error.grid <- tibble(S = seq(0,100,0.1),
V = (coef(error.nls)[[1]]*S)/(coef(error.nls)[[2]]+S))
# Experimental Error Scenarios Plot -----------
ggplot(error_design.data %>% filter(S %in% c(0.1, 0.5, 1, 2.5, 5, 10, 25, 50, 100)),
aes(x = S, y = V))+
geom_line(data = error.grid, size = 1, alpha = 0.75)+
geom_point(aes(y = V_adj, group = ID2, color = ID2, shape = ID2), size = 2.5)+
facet_wrap(~Condition, ncol = 2, scales = "free")+
theme_bw(base_size = 14)+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.7)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.9,0.11), legend.box = "horizontal",
legend.background = element_rect(color = "grey"))+
labs(title = "Experimental Error Scenarios")
```
\newpage
# ***In-Silico*** **Experiments**
## Strategic Sampling Approach
A custom function, `update_data()`, was created to generate experimental data *in-silico* according to the specified experimental design and conditions. Two in-silico experimental designs (rich design, and sparse design) for two experimental conditions (UM/EM and IM/PM conditions) were incorporated into the function. Rich design experiments were conducted using 9 overlapping atomoxetine (ATX) incubation concentrations per subject, while sparse design experiments used 3-4 staggered incubation concentrations per subject , with both designs covering similar concentration ranges according to their experimental condition (UM/EM range: 0.10 - 100 uM, IM/PM range: 1-2000 uM). Additionally, each experimental design can subjected to variable degrees of experimental error using the `CV%` input. The inputs for the function the `update_data()` function include the following:
- **n_indiv** - number of subjects per diplotype group (default = 10).
- **CV%\_D** - Average standard deviation for each diplotype group as a percentage of the true estimate for Vmax and Km (between subject variability for each diplotype group) (default = 25).
- **CV%** - Average coefficient of variation across all points for simulated Michaelis-Menten kinetics for each individual (residual error).
- **start** - Starting concentration from Michaelis-Menten simulation (default = 0).
- **end** - Ending concentration for Michaelis-Menten kinetics (default = 100 uM).
- **by** - Simulated concentration increment (default = 0.5).
- **Pop_freq** - TRUE or FALSE argument indicating whether to use true population frequency (default is FALSE).
- **Seed** - Random number generator seed (for reproducibility, default = 23457).
- **type** - Experimental design to be simulated (options: rich sampling (9pt) = **"rich"**, sparse sampling (3pt) = **"sparse3pt"**, sparse sampling (4pt) = **"sparse4pt"**, rich sampling for poor metabolizers (16 pt) = **"PM"**, sparse sampling for poor metabolizer (3pt) = **"PM_3pt"**, sparse sampling for poor metabolizer (4pt) = **"PM_4pt"**.
-------------------------------------------------------
```{r Stategic Sampling Function}
update_data <-function(`CV%`, type, n_indiv = 10, `CV%.D` = 25, by = 0.1,
start = 0, end = 100, Seed = 23457, Pop.freq = FALSE){
# Sampling Information --------------
# Full Range Set
full_set <- c(0.1, 0.5, 1, 2.5, 5, 10, 25, 50, 100)
PM_range <- c(1, 5, 10, 15, 25, 30, 50, 60, 90, 100, 250, 500, 800, 1000, 1600, 2000)
# Strategic Sampling Sets ----
sparse3pt_set1 <- c(0.1, 2.5, 50)
sparse3pt_set2 <- c(1, 10, 100)
sparse4pt_set1 <- c(0.1, 2.5, 25, 50)
sparse4pt_set2 <- c(1, 10, 50, 100)
PM_3pt_set1 <- c(10,100,1000)
PM_3pt_set2 <- c(25,250,2000)
PM_4pt_set1 <- c(1,10,100,1000)
PM_4pt_set2 <- c(5,25,250,2000)
PM_range_set1 <- c(1,10,25,50,100,400,1000,2000)
PM_range_set2 <- c(5,15,30,60,90,200,800,1600)
# Rich Sampling Simulation ----------------
Rich <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = end, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% full_set) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
# Sparse Sampling Simulation (3 point) ------------
Sparse3pt <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = end, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% full_set) %>%
mutate(Set = if_else(as.numeric(ID) %% 2 == 0, "Set 2", "Set 1")) %>%
filter(if_else(Set == "Set 1", S %in% sparse3pt_set1, S %in% sparse3pt_set2)) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
# Sparse Sampling Simulation (4 point) --------------
Sparse4pt <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = end, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% full_set) %>%
mutate(Set = if_else(as.numeric(ID) %% 2 == 0, "Set 2", "Set 1")) %>%
filter(if_else(Set == "Set 1", S %in% sparse4pt_set1, S %in% sparse4pt_set2)) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
PM <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = 2000, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% c(PM_range)) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
PM_3pt <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = 2000, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% c(PM_range)) %>%
mutate(Set = if_else(as.numeric(ID) %% 2 == 0, "Set 2", "Set 1")) %>%
filter(if_else(Set == "Set 1", S %in% PM_3pt_set1, S %in% PM_3pt_set2)) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
PM_4pt <- population.sim(n = n_indiv, `CV%_D` = `CV%.D`, `CV%_V` = `CV%`, By = by,
Start = start, End = 2000, seed = Seed, pop_freq = Pop.freq) %>%
filter(S %in% c(PM_range)) %>%
mutate(Set = if_else(as.numeric(ID) %% 2 == 0, "Set 2", "Set 1")) %>%
filter(if_else(Set == "Set 1", S %in% PM_4pt_set1, S %in% PM_4pt_set2)) %>%
mutate(Diplotype = as_factor(Diplotype),
V = round(V_adj, digits = 3)) %>%
select(ID, Diplotype, S, V)
# Output Selection ----------
switch(type,
"rich" = Rich,
"sparse3pt" = Sparse3pt,
"sparse4pt" = Sparse4pt,
"PM" = PM,
"PM_3pt" = PM_3pt,
"PM_4pt" = PM_4pt)
}
```
## Representative Experimental Design Plots
Strategic sampling was accomplished by evenly dividing individuals falling under the same CYP2D6 genotype into two groups (Group 1 and Group 2). Each group was designated a pre-defined set of incubation concentrations to be used for the *in-silico* experiment with the total range of incubation concentrations dependent on the type of CYP2D6 metabolizer (as described in the *Strategic Sampling Approach* section above). Note: strategic sampling was not used for rich sample designs, meaning all subject were subjected to the same set of incubations concentrations.
**Extensive and Ultra-Rapid Metabolizers**
*Incubation Concentrations - Rich (9pt)*
- Set: 0.1, 0.5, 1, 2.5, 5, 10, 25, 50, and 100 uM
*Incubation Concentrations - Sparse (3pt)*
- Set 1: 0.1, 2.5, and 50 uM
- Set 2: 1, 10, and 100 uM
*Incubation Concentrations - Sparse (4pt)*
- Set 1: 0.1, 2.5, 25, and 50 uM
- Set 2: 1, 10, 50, and 100 uM
**Intermediate and Poor Metabolizers**
*Incubation Concentrations - Rich (16pt)*
- Set: 1, 5, 10, 15, 25, 30, 50, 60, 90, 100, 250, 500, 800, 1000, 1600, and 2000 uM
*Incubation Concentrations - Sparse (3pt)*
- Set 1: 10,100, and 1000 uM
- Set 2: 25, 250, and 2000 uM
*Incubation Concentrations - Sparse (4pt)*
- Set 1: 1,10,100, and 1000 uM
- Set 2: 5,25,250, and 2000 uM
-------------------------------------------------------
```{r Design Strategies Datasets}
# Generating Representative Data sets =========
## Representative data comes from 2 wild-type subjects.
rich_design.data <- update_data(`CV%` = 0, type = "rich") %>%
filter(Diplotype == "1/1", ID %in% c(1,2)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Rich Design (9 pts)")
sparse_3pt_design.data <- update_data(`CV%` = 0, type = "sparse3pt")%>%
filter(Diplotype == "1/1", ID %in% c(1,2)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Sparse Design (3 pts)")
sparse_4pt_design.data <- update_data(`CV%` = 0, type = "sparse4pt")%>%
filter(Diplotype == "1/1", ID %in% c(1,2)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Sparse Design (4 pts)")
PM_design.data <- update_data(`CV%` = 0, type = "PM") %>%
filter(Diplotype == "4/5", ID %in% c(81,82)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Rich Design (16 pts)")
PM3pt_design.data <- update_data(`CV%` = 0, type = "PM_3pt") %>%
filter(Diplotype == "4/5", ID %in% c(81,82)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Sparse Design (3 pts)")
PM4pt_design.data <- update_data(`CV%` = 0, type = "PM_4pt") %>%
filter(Diplotype == "4/5", ID %in% c(81,82)) %>%
mutate(ID2 = paste("Subject",ID),
`Study Design` = "Sparse Design (4 pts)")
# Solution Grid
design.nls <- nls(formula = V ~ (Vmax*S)/(Km + S), data = rich_design.data,
start = list(Vmax = 350, Km = 2))
grid <- tibble(S = seq(0,100,0.1),
V = (coef(design.nls)[[1]]*S)/(coef(design.nls)[[2]]+S))
design_PM.nls <- nls(formula = V ~ (Vmax*S)/(Km + S), data = PM_design.data,
start = list(Vmax = 20, Km = 50))
grid_pm <- tibble(S = seq(0,2000,0.1),
V = (coef(design_PM.nls)[[1]]*S)/(coef(design_PM.nls)[[2]]+S))
```
```{r Design Plots, fig.asp=1}
# UM/EM STRATEGIC SAMPLING DESIGN FIGURE ================
## Representative plots contain data for 2 wild-type subjects.
# Rich Design--------
D1<- ggplot(rich_design.data, aes(x = S, y = V))+
geom_line(data = grid, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "Conventional")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# Sparse Design (3pt)----------
D2<- ggplot(sparse_3pt_design.data, aes(x = S, y = V))+
geom_line(data = grid, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "Strategic Scenario (2)")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# Sparse Design (4pt)------------
D3 <- ggplot(sparse_4pt_design.data, aes(x = S, y = V))+
geom_line(data = grid, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "Strategic Scenario (1)")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# IM/PM STRATEGIC SAMPLING DESIGN FIGURE ================
## Representative plots contain data for 2 wild-type subjects.
# PM Sparse Design (4pt)---------
D4 <- ggplot(PM4pt_design.data, aes(x = S, y = V))+
geom_line(data = grid_pm, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# Extensize metabolizer model---------
D5 <- D3 + labs(title = "") #4pt
D6 <- D2 + labs(title = "") #3pt
D7 <- D1 + labs(title = "Extensive Metabolizer") #9pt
# PM Sparse Design (3pt)---------
D8 <- ggplot(PM3pt_design.data, aes(x = S, y = V))+
geom_line(data = grid_pm, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# PM Rich Design (16pt)---------
D9 <- ggplot(PM_design.data, aes(x = S, y = V))+
geom_line(data = grid_pm, size = 1.5, alpha = 0.75)+
geom_point(aes(color=ID2, shape = ID2), size = 3.5)+
theme_bw(base_size = 14)+
ggeasy::easy_remove_legend_title()+
theme(legend.position = c(0.7,0.2))+
facet_wrap(~`Study Design`, ncol = 1)+
labs(title = "Poor Metabolizers")+
xlab("[Substrate](uM)")+
ylab("Reaction Rate (V)\n")+
scale_color_viridis_d(option = "A", begin = 0.2, end = 0.6)
# Combined Plots -----------
## Extensive Metabolizers
ggpubr::ggarrange(D7,D5,D6,ncol = 2, nrow = 2, labels = "AUTO")
## Poor Metabolizers
ggpubr::ggarrange(D9,D4,D8, ncol = 2, nrow = 2, labels = "AUTO")
```
\newpage
# **Population Michaelis-Menten Modeling (UM/EM)**
## Generation of Experimental Data (Base Model - 0% CV)
```{r Base Model Experimental Data}
# Population Datasets (CV = 0%)
rich.data <- update_data(`CV%` = 0, type = "rich") %>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse3pt.data <- update_data(`CV%` = 0, type = "sparse3pt") %>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse4pt.data <- update_data(`CV%` = 0, type = "sparse4pt") %>%
filter(!Diplotype %in% c("4/41", "4/5"))
```
## Individual-Fits of Experimental Data (Base Model - 0% CV)
A grouped data frame was created for each experiment where reaction rate (V) is predicted by substrate concentration (S) according to subject (ID). Individual fits (un-weighted) and parameter estimates for the data sets were obtained using non-linear least squares function `nlsList()`. Values obtained from the `nlsList()` were used as initial estimates for the non-linear mixed effect model.
-------------------------------------------------------
```{r Base Model NLS Fit}
# Grouped Data frame -------------
rich_data.grp <- groupedData(V~S|ID, rich.data)
sparse3pt.grp <- groupedData(V~S|ID, sparse3pt.data)
sparse4pt.grp <- groupedData(V~S|ID, sparse4pt.data)
# Fit Model ((Non-Linear Least Squares) ------------
rich_fit.nls <- nlsList(V~SSmicmen(S,Vmax,Km), data = rich_data.grp)
sparse3pt_fit.nls <- nlsList(V~SSmicmen(S,Vmax,Km), data = sparse3pt.grp)
sparse4pt_fit.nls <- nlsList(V~SSmicmen(S,Vmax,Km), data = sparse4pt.grp)
```
## Non-Linear Mixed Effect Modeling (Base Model - 0% CV)
Non-linear mixed effect modeling was conducted using the `nlme()` package version 3.1 (Bates et al., 2000). The `nlsList()` fits were used as initial estimates for the NLME model. Individual level random effects were applied to both Vmax and Km. A diagonal variance-covariance structure was assigned to each model using the `pdDiag()` function.
-------------------------------------------------------
```{r Base Model NLME Fit}
# Fit Model ((Non-Linear Mixed-Effect) ------------
rich.nlme <- nlme(rich_fit.nls, random = pdDiag(Vmax + Km ~ 1))
sparse3pt.nlme <- nlme(sparse3pt_fit.nls, random = pdDiag(Vmax + Km ~ 1))
sparse4pt.nlme <- nlme(sparse4pt_fit.nls, random = pdDiag(Vmax + Km ~ 1))
# Model Fixed Effect comparisons
fixef.table <- rbind(fixef(rich.nlme),
fixef(sparse3pt.nlme),
fixef(sparse4pt.nlme)) %>%
as_tibble() %>%
mutate(Model = c("Rich","Sparse (3pt)","Sparse (4pt)")) %>%
relocate(Model)
fixef.table %>%
mutate(across(where(is.numeric), round, 2)) %>%
kbl( table.attr = "style='width:60%;'",
caption = "Base Model: Mixed Effect Michaelis-Menten") %>%
kable_classic("striped")
```
## Non-Linear Mixed Effect Modeling (Covariate Model - 0% CV)
*CYP2D6* genotype was incorporated as a categorical covariate in the model by adding it as a fixed effect that impacts both Vmax and Km. The extracted population level fixed effects for Vmax and Km from the base model (described in the previous section) were used as initial estimates for the covariate model.
-------------------------------------------------------
```{r Inclusion of Genotype as Covariate}
#Models with genotype as a Covariate -----
rich.fxf <- fixef.table[1,2:3]
sparse3pt.fxf <- fixef.table[2,2:3]
sparse4pt.fxf <- fixef.table[3,2:3]
rich_covar.nlme <- update(rich.nlme, fixed = Vmax + Km ~ Diplotype,
start = c(rich.fxf[[1]], rep(0,6),
rich.fxf[[2]], rep(0,6)))
sparse3pt_covar.nlme <- update(sparse3pt.nlme, fixed = Vmax + Km ~ Diplotype,
start = c(sparse3pt.fxf[[1]], rep(0,6),
sparse3pt.fxf[[2]], rep(0,6)))
sparse4pt_covar.nlme <- update(sparse4pt.nlme, fixed = Vmax + Km ~ Diplotype,
start = c(sparse4pt.fxf[[1]], rep(0,6),
sparse4pt.fxf[[2]], rep(0,6)))
```
## Base Model and Covariate Model Evaluation (0% CV)
The impact of adding CYP2D6 genotype as a (covariate on both Vmax and Km) and the whether adding covariates to the model improved fit compared to baseline was assessed using analysis of variance `anova()`.
### Overall Impact of adding covariates to base model
```{r Base vs Covariate Model ANOVA, eval=FALSE}
anova(rich.nlme, rich_covar.nlme)
anova(sparse3pt.nlme, sparse3pt_covar.nlme)
anova(sparse4pt.nlme, sparse4pt_covar.nlme)
```
### Impact of adding covariate to Vmax and Km
```{r Covariate Model ANOVA, warning = F, eval=FALSE}
anova(rich_covar.nlme) %>%
kbl(caption = "Rich Model (w/Covariates)",
table.attr = "style='width:60%;'") %>%
kable_classic(full_width = T, "striped")
anova(sparse3pt_covar.nlme)%>%
kbl(caption = "Sparse 3pt Model (w/Covariates)",
table.attr = "style='width:60%;'") %>%
kable_classic(full_width = T, "striped")
anova(sparse4pt_covar.nlme)%>%
kbl(caption = "Sparse 4pt Model (w/Covariates)",
table.attr = "style='width:60%;'") %>%
kable_classic(full_width = T, "striped")
```
## Summary Tables of Fixed Effects Estimates (Covariate Model - 0% CV)
### Table of Covariate Model Estimates
```{r}
# Covariate Analysis Summary Table ------------
covaref.table <- rbind(fixef(rich_covar.nlme),
fixef(sparse3pt_covar.nlme),
fixef(sparse4pt_covar.nlme)) %>%
as_tibble() %>%
mutate(`Covariate Model` = c("Rich","Sparse (3pt)","Sparse (4pt)")) %>%
pivot_longer(`Vmax.(Intercept)`:`Km.Diplotype2/4`,
names_to = "Parameter",
values_to = "Value") %>%
pivot_wider(names_from = `Covariate Model`, values_from = Value) %>%
separate(Parameter, sep = "\\.", into = c("Parameter","Diplotype"), remove = T) %>%
mutate(Diplotype = recode(Diplotype, "(Intercept)" = "Reference (1/1)"),
across(where(is.numeric), round, 2))
```
### Reference Group (\*1/\*1) Parameter Estimates
```{r}
# Reference Estimates -----------
covaref.table %>%
filter(Diplotype == "Reference (1/1)")%>%
kbl(caption = "Reference Population Estimates",
table.attr = "style='width:60%;'") %>%
kable_classic(full_width = T, "striped")
```
### Variant Group ETAs Table
```{r}
# CYP2D6 Genotype Effects --------
covaref.table%>%
kbl(caption = "Michaelis Menten Mixed-Effect Model (w/Covariates)",
table.attr = "style='width:60%;'") %>%
kable_classic(full_width = T, "striped") %>%
pack_rows("Vmax Estimate (Population)", 1,1) %>%
pack_rows("Covariate (Vmax Eta)", 2, 7)%>%
pack_rows("Km Estimate (Population)", 8,8) %>%
pack_rows("Covariate (Km Eta)", 9, 14)
```
### Covariate Model 95% Confidence Interval Table (0% CV)
```{r }
# Function to Extract Confidence Interval Info ----------
extract_CI <- function(int.data, name){
temp <- int.data$fixed %>%
as_tibble() %>%
mutate(across(where(is.numeric), round, 2),
`CI (95%)` = paste0("(",lower,", ",upper,")")) %>%
select(est., `CI (95%)`)
colnames(temp) <- c(paste(name, " Estimate"), paste(name, " CI (95%)"))
temp
}
# Confidence Interval by Sampling Scenario -------
rich_covar.intervals <- intervals(rich_covar.nlme, which = "fixed")
sparse3pt_covar.intervals <- intervals(sparse3pt_covar.nlme, which = "fixed")
sparse4pt_covar.intervals <- intervals(sparse4pt_covar.nlme, which = "fixed")
# Summary Table of Confidence Intervals by Diplotype and Scenario -----------
covar_ci.table <- cbind(extract_CI(rich_covar.intervals, name = "Rich"),
extract_CI(sparse3pt_covar.intervals, name = "Sparse 3pt"),
extract_CI(sparse4pt_covar.intervals, name = "Sparse 4pt")) %>%
mutate(Parameter = rownames(rich_covar.intervals$fixed)) %>%
relocate(Parameter) %>%
separate(Parameter, remove = T, sep = "\\.", into = c("Parameter", "Diplotype"))%>%
mutate(Diplotype = recode(Diplotype, "(Intercept)" = "Reference (1/1)"))
colnames(covar_ci.table)<- c("Parameter", "Diplotype",
"Estimate","CI (95%)",
"Estimate", "CI (95%)",
"Estimate", "CI (95%)")
covar_ci.table%>%
kbl(caption = "Michaelis Menten Mixed-Effect Model (w/Covariates)") %>%
kable_classic(full_width = T, "striped")%>%
pack_rows("Vmax Estimate (Population)", 1,1) %>%
pack_rows("Covariate (Vmax Eta)", 2, 7)%>%
pack_rows("Km Estimate (Population)", 8,8) %>%
pack_rows("Covariate (Km Eta)", 9, 14) %>%
add_header_above(c(" ", " ",
"Rich (9pt)" = 2,
"Sparse (3pt)" = 2,
"Sparse (4pt)" = 2))
```
\newpage
# **Population Modeling w/Residual Error (UM/EM)**
Data sets with include increasing degrees of residual error (5, 10, and 20% CV) were generated using the `update_data()` function described earlier (see *In-Silico Experiments* section for full description). Additonally, the same methodology for model analysis used in the the previous section (*Population Michaelis-Menten Modeling (UM/EM)*) was applied here to evaluate the impact of increasing experimental error on parameter estimates.
## Generation of Experimental Data (Base Model - 5-20% CV)
```{r}
# Population Data sets (CV = 5%) ----------------
rich_CV5.data <- update_data(`CV%` = 5, type = "rich")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse3pt_CV5.data <- update_data(`CV%` = 5, type = "sparse3pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse4pt_CV5.data <- update_data(`CV%` = 5, type = "sparse4pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
# Population Data sets (CV = 10%) ----------------
rich_CV10.data <- update_data(`CV%` = 10, type = "rich")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse3pt_CV10.data <- update_data(`CV%` = 10, type = "sparse3pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse4pt_CV10.data <- update_data(`CV%` = 10, type = "sparse4pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
# Population Data sets (CV = 20%) ----------------
rich_CV20.data <- update_data(`CV%` = 20, type = "rich")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse3pt_CV20.data <- update_data(`CV%` = 20, type = "sparse3pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
sparse4pt_CV20.data <- update_data(`CV%` = 20, type = "sparse4pt")%>%
filter(!Diplotype %in% c("4/41", "4/5"))
```
## Inidividual-Fits of Experimental Data (Base Model - 5-20% CV)
```{r}
# Grouped Data frame =============================
rich_CV5_data.grp <- groupedData(V~S|ID, rich_CV5.data)
sparse3pt_CV5.grp <- groupedData(V~S|ID, sparse3pt_CV5.data)
sparse4pt_CV5.grp <- groupedData(V~S|ID, sparse4pt_CV5.data)
rich_CV10_data.grp <- groupedData(V~S|ID, rich_CV10.data)
sparse3pt_CV10.grp <- groupedData(V~S|ID, sparse3pt_CV10.data)
sparse4pt_CV10.grp <- groupedData(V~S|ID, sparse4pt_CV10.data)
rich_CV20_data.grp <- groupedData(V~S|ID, rich_CV20.data)