-
Notifications
You must be signed in to change notification settings - Fork 9
/
Multiple_Ascending_Dose_PKPD_continuous.html
1079 lines (935 loc) · 39.2 KB
/
Multiple_Ascending_Dose_PKPD_continuous.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" />
<meta name="author" content="Alison Margolskee, Fariba Khanshan" />
<title>PK/PD, Exposure-Response - Continuous</title>
<script src="site_libs/header-attrs-2.17/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.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>
<style>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;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<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>
<script src="site_libs/navigation-1.1/codefolding.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">
.visible-sm-block {padding-top: 120px;}
.visible-md-block {padding-top: 60px;}
.visible-lg-block {padding-top: 0px;}
</style>
<span class=visible-sm-block> </span>
<span class=visible-md-block> </span>
<span class=visible-lg-block> </span>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</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">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
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;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.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: #adb5bd;
}
.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 type="text/javascript">
// 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 the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
dropdown.addClass('active');
}
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
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: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.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">
.code-folding-btn { margin-bottom: 4px; }
</style>
<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;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<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-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-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">xGx</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">
<span class="glyphicon glyphicon-home"></span>
</a>
</li>
<li>
<a href="GuidingPrinciples.html">Guiding Principles</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Data
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="Datasets.html">Dataset Specifications</a>
</li>
<li>
<a href="PKPD_Datasets.html">Master PK/PD Datasets used in creating example plots</a>
</li>
<li>
<a href="Data_Checking.html">Data Checking</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dose-PK/Exposure
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="Single_Ascending_Dose_PK.html">Single Ascending Dose - PK</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PK.html">Multiple Ascending Dose - PK</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PK_KeyPlots.html">Example using realistic data</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dose-PD/Efficacy/Safety
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="Multiple_Ascending_Dose_PD_continuous.html">Continuous</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PD_binary.html">Binary Response</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PD_ordinal.html">Ordinal Response</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PD_count.html">Count Data</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PD_time_to_event.html">Time to Event</a>
</li>
<li>
<a href="Oncology_Efficacy_Plots.html">Oncology Efficacy Endpoints (RECIST)</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PD_real_example.html">PD/Efficacy Example using realistic data</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
PK-PD/Efficacy/Safety
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="Multiple_Ascending_Dose_PKPD_continuous.html">Continuous</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PKPD_binary.html">Binary Response</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PKPD_ordinal.html">Ordinal Response</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PKPD_count.html">Count Data</a>
</li>
<li>
<a href="Multiple_Ascending_Dose_PKPD_time_to_event.html">Time to Event</a>
</li>
<li>
<a href="Adverse_Events.html">Adverse Events</a>
</li>
</ul>
</li>
<li>
<a href="Resources.html">Resources</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<style type="text/css">
.visible-sm-block {padding-top: 120px;}
.visible-md-block {padding-top: 60px;}
.visible-lg-block {padding-top: 0px;}
.navbar-image {width: 150px;}
.warning {
font-size: 200% ;
color: red;
padding-top: 200px;
}
}
@media (min-width: 992px) and (max-width: 1200px){
.navbar-image {width: 19%;}
.section h1 {
padding-top: 110px;
margin-top: -110px;
}
.section h2 {
padding-top: 110px;
margin-top: -110px;
}
.section h3 {
padding-top: 110px;
margin-top: -110px;
}
}
@media (min-width: 768px) and (max-width: 991px){
.navbar-image {width: 19%;}
.section h1 {
padding-top: 160px;
margin-top: -160px;
}
.section h2 {
padding-top: 160px;
margin-top: -160px;
}
.section h3 {
padding-top: 160px;
margin-top: -160px;
}
}
@media (max-width: 768px){
.navbar-image {width: 19%;}
}
</style>
<!--[if IE]>
<p/>
<p/>
<p class="warning"> Dear Internet Explorer user: Please ensure compatibility view settings are turned OFF in order to view this website propertly. For best results, use Chrome. <br/>
<p/>
<![endif]-->
<div id="header">
<div class="btn-group pull-right float-right">
<button type="button" class="btn btn-default btn-xs btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" style="min-width: 50px;">
<li><a id="rmd-show-all-code" href="#">Show All Code</a></li>
<li><a id="rmd-hide-all-code" href="#">Hide All Code</a></li>
</ul>
</div>
<h1 class="title toc-ignore">PK/PD, Exposure-Response - Continuous</h1>
<h4 class="author">Alison Margolskee, Fariba Khanshan</h4>
</div>
<div id="overview" class="section level2">
<h2>Overview</h2>
<!--START_EXPLANATION-->
<p>This document contains exploratory plots for continuous PD data as
well as the R code that generates these graphs. The plots presented here
are based on simulated data (<a href="PKPD_Datasets.html">see: PKPD
Datasets</a>). Data specifications can be accessed on <a
href="Datasets.html">Datasets</a> and Rmarkdown template to generate
this page can be found on <a
href="Rmarkdown/Multiple_Ascending_Dose_PKPD_continuous.Rmd">Rmarkdown-Template</a>.
You may also download the Multiple Ascending Dose PK/PD dataset for your
reference (<a href="Data/Multiple_Ascending_Dose_Dataset2.csv">download
dataset</a>). <!--END_EXPLANATION--></p>
</div>
<div id="setup" class="section level2">
<h2>Setup</h2>
<pre class="r"><code>library(ggplot2)
library(dplyr)
library(tidyr)
library(gridExtra)
library(xgxr)
#flag for labeling figures as draft
status = "DRAFT"
## ggplot settings
xgx_theme_set()
#directories for saving individual graphs
dirs = list(
parent_dir= tempdir(),
rscript_dir = "./",
rscript_name = "Example.R",
results_dir = "./",
filename_prefix = "",
filename = "Example.png")</code></pre>
</div>
<div id="load-dataset" class="section level2">
<h2>Load Dataset</h2>
<pre class="r"><code>#load dataset
pkpd_data <- read.csv("../Data/Multiple_Ascending_Dose_Dataset2.csv")
DOSE_CMT = 1
PK_CMT = 2
PD_CMT = 3
SS_PROFDAY = 6 # steady state prof day
PD_PROFDAYS <- c(0, 2, 4, 6)
TAU = 24 # time between doses, units should match units of TIME, e.g. 24 for QD, 12 for BID, 7*24 for Q1W (when units of TIME are h)
#ensure dataset has all the necessary columns
pkpd_data = pkpd_data %>%
mutate(ID = ID, #ID column
TIME = TIME, #TIME column name
NOMTIME = NOMTIME,#NOMINAL TIME column name
PROFDAY = 1 + floor(NOMTIME / 24), #PROFILE DAY day associated with profile, e.g. day of dose administration
LIDV = LIDV, #DEPENDENT VARIABLE column name
CENS = CENS, #CENSORING column name
CMT = CMT, #COMPARTMENT column
DOSE = DOSE, #DOSE column here (numeric value)
TRTACT = TRTACT, #DOSE REGIMEN column here (character, with units),
LIDV_NORM = LIDV/DOSE,
LIDV_UNIT = EVENTU,
DAY_label = ifelse(PROFDAY > 0, paste("Day", PROFDAY), "Baseline")
)
#create a factor for the treatment variable for plotting
pkpd_data = pkpd_data %>%
arrange(DOSE) %>%
mutate(TRTACT_low2high = factor(TRTACT, levels = unique(TRTACT)),
TRTACT_high2low = factor(TRTACT, levels = rev(unique(TRTACT))))
#create pk and pd datasets
pk_data <- pkpd_data %>%
filter(CMT==PK_CMT)
pd_data <- pkpd_data %>%
filter(CMT==PD_CMT)
#create wide pkpd dataset for plotting PK vs PD
pkpd_data_wide <- pd_data %>%
select(ID, NOMTIME, PD = LIDV) %>%
right_join(pk_data) %>%
rename(CONC = LIDV)%>%
filter(!is.na(PD))%>%
filter(!is.na(CONC))
#perform NCA, for additional plots
NCA = pk_data %>%
group_by(ID, DOSE) %>%
filter(!is.na(LIDV)) %>%
summarize(AUC_0 = ifelse(length(LIDV[NOMTIME > 0 & NOMTIME <= TAU]) > 1,
caTools::trapz(TIME[NOMTIME > 0 & NOMTIME <= TAU],
LIDV[NOMTIME > 0 & NOMTIME <= TAU]),
NA),
Cmax_0 = ifelse(length(LIDV[NOMTIME > 0 & NOMTIME <= TAU]) > 1,
max(LIDV[NOMTIME > 0 & NOMTIME <= TAU]),
NA),
AUC_tau = ifelse(length(LIDV[NOMTIME > (SS_PROFDAY-1)*24 &
NOMTIME <= ((SS_PROFDAY-1)*24 + TAU)]) > 1,
caTools::trapz(TIME[NOMTIME > (SS_PROFDAY-1)*24 &
NOMTIME <= ((SS_PROFDAY-1)*24 + TAU)],
LIDV[NOMTIME > (SS_PROFDAY-1)*24 &
NOMTIME <= ((SS_PROFDAY-1)*24 + TAU)]),
NA),
Cmax_tau = ifelse(length(LIDV[NOMTIME > (SS_PROFDAY-1)*24 &
NOMTIME <= ((SS_PROFDAY-1)*24 + TAU)]) > 1,
max(LIDV[NOMTIME > (SS_PROFDAY-1)*24 &
NOMTIME <= ((SS_PROFDAY-1)*24 + TAU)]),
NA),
SEX = SEX[1], #this part just keeps the SEX and WEIGHTB covariates
WEIGHTB = WEIGHTB[1]) %>%
gather(PARAM, VALUE,-c(ID, DOSE, SEX, WEIGHTB)) %>%
ungroup() %>%
mutate(VALUE_NORM = VALUE/DOSE,
PROFDAY = ifelse(PARAM %in% c("AUC_0", "Cmax_0"), 1, SS_PROFDAY))
#add response data at day 1 and steady state to NCA for additional plots
NCA <- pd_data %>% subset(PROFDAY %in% c(1, SS_PROFDAY),) %>%
select(ID, PROFDAY, DAY_label, PD = LIDV, TRTACT_low2high, TRTACT_high2low) %>%
merge(NCA, by = c("ID","PROFDAY"))
#units and labels
time_units_dataset = "hours"
time_units_plot = "days"
trtact_label = "Dose"
dose_units = unique((pkpd_data %>% filter(CMT == DOSE_CMT) )$LIDV_UNIT) %>% as.character()
dose_label = paste0("Dose (", dose_units, ")")
conc_units = unique(pk_data$LIDV_UNIT) %>% as.character()
conc_label = paste0("Concentration (", conc_units, ")")
concnorm_label = paste0("Normalized Concentration (", conc_units, ")/", dose_units)
AUC_units = paste0("h.", conc_units)
pd_units = unique(pd_data$LIDV_UNIT) %>% as.character()
pd_label = paste0("Continuous PD Marker (", pd_units, ")") </code></pre>
</div>
<div id="provide-an-overview-of-the-data" class="section level2">
<h2>Provide an overview of the data</h2>
<!--START_EXPLANATION-->
<p>Summarize the data in a way that is easy to visualize the general
trend of PD over time and between doses. Using summary statistics can be
helpful, e.g. Mean +/- SE, or median, 5th & 95th percentiles.
Consider either coloring by dose or faceting by dose. Depending on the
amount of data one graph may be better than the other.
<!--END_EXPLANATION--></p>
<div
id="pk-and-pd-marker-over-time-colored-by-dose-mean-95-ci-percentiles-by-nominal-time"
class="section level3">
<h3>PK and PD marker over time, colored by Dose, mean (95% CI)
percentiles by nominal time</h3>
<!--START_EXPLANATION-->
<p>Observe the overall shape of the average profiles. Does the effect
appear to increase and decrease quickly on a short time scale, or does
is occur over a longer time scale? Do the PK and PD profiles appear to
be on the same time scale, or does the PD seem delayed compared to the
PK? Is there clear separation between the profiles for different doses?
Does the effect appear to increase with increasing dose? Do you detect a
saturation of the effect? <!--END_EXPLANATION--></p>
<pre class="r"><code>#PK data
gg <- ggplot(data = pk_data,
aes(x = NOMTIME,y = LIDV, color = TRTACT_high2low, fill = TRTACT_high2low))
gg <- gg + xgx_stat_ci(conf_level = .95)
gg <- gg + xgx_annotate_status(status)
gg <- gg + xgx_scale_x_time_units(units_dataset = time_units_dataset,
units_plot = time_units_plot)
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + xgx_scale_y_log10()
gg <- gg + labs(y = conc_label)
print(gg)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-3-1.png" width="960" /></p>
<pre class="r"><code>#PD data
gg %+% (data = pd_data) + scale_y_continuous() + labs(y = pd_label)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-3-2.png" width="960" /></p>
</div>
<div
id="pk-and-pd-marker-over-time-faceted-by-dose-mean-95-ci-by-nominal-time"
class="section level3">
<h3>PK and PD marker over time, faceted by Dose, mean (95% CI) by
nominal time</h3>
<pre class="r"><code>#PK data
gg <- ggplot(data = pk_data,
aes(x = NOMTIME,y = LIDV))
gg <- gg + xgx_stat_ci(conf_level = .95)
gg <- gg + xgx_scale_x_time_units(units_dataset = time_units_dataset,
units_plot = time_units_plot)
gg <- gg + guides(color = guide_legend(""),fill = guide_legend(""))
gg <- gg + facet_grid(~TRTACT_low2high)
gg <- gg + xgx_scale_y_log10()
gg <- gg + labs(y = conc_label)
print(gg)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-4-1.png" width="960" /></p>
<pre class="r"><code>#PD data
gg %+% (data = pd_data %>% subset(DOSE>0)) + scale_y_continuous() + labs(y = pd_label)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-4-2.png" width="960" /></p>
</div>
</div>
<div id="explore-variability" class="section level2">
<h2>Explore variability</h2>
<!--START_EXPLANATION-->
<p>Use spaghetti plots to visualize the extent of variability between
individuals. The wider the spread of the profiles, the higher the
between subject variability. Distinguish different doses by color, or
separate into different panels. If coloring by dose, do the individuals
in the different dose groups overlap across doses? Dose there seem to be
more variability at higher or lower concentrations?
<!--END_EXPLANATION--></p>
<div
id="pk-and-pd-marker-over-time-colored-by-dose-dots-lines-grouped-by-individuals"
class="section level3">
<h3>PK and PD marker over time, colored by Dose, dots & lines
grouped by individuals</h3>
<pre class="r"><code>#PK data
gg <- ggplot(data = pk_data,
aes(x = TIME, y = LIDV,group = ID, color = factor(TRTACT_high2low)))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_line(alpha = 0.5)
gg <- gg + geom_point(alpha = 0.5)
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + xgx_scale_x_time_units(units_dataset = time_units_dataset,
units_plot = time_units_plot)
gg <- gg + geom_point(data = pk_data %>% subset(CENS == 1,), color = "red", shape = 8,alpha = 0.5)
gg <- gg + xgx_scale_y_log10()
gg <- gg + labs(y = conc_label)
print(gg)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-5-1.png" width="960" /></p>
<pre class="r"><code>#PD data
gg %+% (data = pd_data %>% subset(DOSE>0)) + scale_y_continuous() + labs(y = pd_label)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-5-2.png" width="960" /></p>
</div>
<div
id="pk-and-pd-marker-over-time-faceted-by-dose-dots-lines-grouped-by-individuals"
class="section level3">
<h3>PK and PD marker over time, faceted by Dose, dots & lines
grouped by individuals</h3>
<pre class="r"><code>#PK data
gg <- ggplot(data = pk_data, aes(x = TIME, y = LIDV, group = ID))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_line(alpha = 0.5)
gg <- gg + geom_point(alpha = 0.5)
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + xgx_scale_x_time_units(units_dataset = time_units_dataset,
units_plot = time_units_plot)
gg <- gg + facet_grid(~TRTACT_low2high)
gg <- gg + xgx_scale_y_log10()
gg <- gg + labs(y = conc_label)
gg1 <- gg + geom_point(data = pk_data %>% subset(CENS==1,), color="red", shape=8, alpha = 0.5)
print(gg1)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-6-1.png" width="960" /></p>
<pre class="r"><code>#PD data
gg %+% (data = pd_data %>% subset(DOSE>0)) + scale_y_continuous() + labs(y = pd_label)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-6-2.png" width="960" /></p>
</div>
</div>
<div id="explore-exposure-response-relationship" class="section level2">
<h2>Explore Exposure-Response Relationship</h2>
<div
id="pd-marker-by-concentration-for-endpoint-of-interest-mean-95-ci-by-concentration-bins"
class="section level3">
<h3>PD marker by Concentration, for endpoint of interest, mean (95% CI)
by concentration bins</h3>
<!--START_EXPLANATION-->
<p>Plot PD marker against concentration. Do you see any relationship?
Does response increase (decrease) with increasing dose? Are you able to
detect a plateau or emax (emin) on the effect?</p>
<p><strong>Warning:</strong> Even if you don’t see an Emax, that doesn’t
mean there isn’t one. Be very careful about using linear models for
Dose-Response or Exposure-Response relationships. Extrapolation outside
of the observed dose range could indicate a higher dose is always better
(even if it isn’t). <!--END_EXPLANATION--></p>
<pre class="r"><code>gg <- ggplot(data = pkpd_data_wide %>% subset(PROFDAY == SS_PROFDAY,), aes(x = CONC,y = PD))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_point(aes(color = TRTACT_high2low))
gg <- gg + geom_point(data = pkpd_data_wide %>% subset(CENS==1,), color="red", shape = 8)
gg <- gg + labs(x = conc_label , y = pd_label)
gg <- gg + guides(color = guide_legend(""))
gg <- gg + xgx_geom_smooth_emax(color = "black")
## Note: if the above line doesn't work, try modifying the formula,
## initial estimates, or lower bounds in the following code
# gg <- gg + xgx_geom_smooth(color = "black", method = "nlsLM",
# formula = y ~ E0 + Emax*x/(ED50 + x),
# method.args = list(
# start = list(Emax = 1, ED50 = 1, E0 = 1),
# lower = c(-Inf, 0, -Inf)))
gg <- gg + xgx_stat_ci(bins = 4, geom = "point", shape = 0, size = 4)
gg <- gg + xgx_stat_ci(bins = 4, geom = "errorbar")
gg1 <- gg + ggtitle("Concentration on Linear Scale")
gg2 <- gg + xgx_scale_x_log10() + ggtitle("Concentration on Log Scale")
grid.arrange(gg1,gg2,nrow = 1)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-7-1.png" width="768" /></p>
</div>
<div
id="pd-marker-by-concentration-faceted-by-visit-mean-95-ci-by-concentration-bins"
class="section level3">
<h3>PD marker by Concentration, faceted by visit, mean (95% CI) by
concentration bins</h3>
<pre class="r"><code>data_to_plot <- pkpd_data_wide %>% subset(PROFDAY %in% PD_PROFDAYS,)
gg <- ggplot(data = data_to_plot,
aes(x = CONC, y = PD))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_point(aes(color = TRTACT_high2low))
gg <- gg + geom_point(data = data_to_plot %>% subset(CENS==1,), color="red", shape = 8)
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + labs(x = conc_label , y = pd_label)
gg <- gg + xgx_stat_ci(bins = 4, geom = "point", shape = 0, size = 4)
gg <- gg + xgx_stat_ci(bins = 4, geom = "errorbar")
gg <- gg + facet_grid(~DAY_label)
gg1 <- gg + xgx_geom_smooth_emax(color = "black") + ggtitle("Concentration on Linear Scale")
gg2 <- gg + xgx_geom_smooth(color = "black", method = "nlsLM", formula = y ~ E0 + Emax*x/(ED50 + x),
method.args = list(
start = list(Emax = 1, ED50 = 5, E0 = 1),
lower = c(-Inf, 0, -Inf))) +
xgx_scale_x_log10() + ggtitle("Concentration on Log Scale")
grid.arrange(gg1,gg2,nrow = 2)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-8-1.png" width="768" /></p>
<!--START_EXPLANATION-->
<p>Plotting AUC vs response instead of concentration vs response may
make more sense in some situations. For example, when there is a large
delay between PK and PD it would be diffcult to relate the time-varying
concentration with the response. If rich sampling is only done at a
particular point in the study, e.g. at steady state, then the AUC
calculated on the rich profile could be used as the exposure variable
for a number of PD visits. If PK samples are scarce, average Cmin could
also be used as the exposure metric. <!--END_EXPLANATION--></p>
<pre class="r"><code>gg <- ggplot(data = NCA, aes(x = VALUE, y = PD))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_point(aes(color = TRTACT_high2low))
gg <- gg + xgx_geom_smooth_emax(color = "black")
## Note: if the above line doesn't work, try modifying the formula,
## initial estimates, or lower bounds in the following code
# gg <- gg + xgx_geom_smooth(color = "black", method = "nlsLM",
# formula = y ~ E0 + Emax*x/(ED50 + x),
# method.args = list(
# start = list(Emax = 1, ED50 = 1, E0 = 1),
# lower = c(-Inf, 0, -Inf)))
gg <- gg + xgx_stat_ci(bins = 4, geom = "errorbar")
gg <- gg + xgx_stat_ci(bins = 4, geom = "point", shape = 0, size = 4)
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + labs(color = trtact_label, x = "NCA parameter", y = pd_label)
gg <- gg + facet_wrap(~DAY_label + PARAM, scales = "free_x")
print(gg)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-9-1.png" width="768" /></p>
</div>
<div id="explore-covariate-effects-on-exposure-response-relationship"
class="section level3">
<h3>Explore covariate effects on Exposure-Response Relationship</h3>
<!--START_EXPLANATION-->
<p>Stratify exposure-response plots by covariates of interest to explore
whether any key covariates impact response independent of exposure.
<!--END_EXPLANATION--></p>
<pre class="r"><code>gg <- ggplot(data = NCA, aes(x = VALUE, y = PD))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_point(aes(color = SEX))
gg <- gg + xgx_geom_smooth_emax(aes(color = SEX))
## Note: if the above line doesn't work, try modifying the formula,
## initial estimates, or lower bounds in the following code
# gg <- gg + xgx_geom_smooth(aes(color = SEX), method = "nlsLM",
# formula = y ~ E0 + Emax*x/(ED50 + x),
# method.args = list(
# start = list(Emax = 1, ED50 = 1, E0 = 1),
# lower = c(-Inf, 0, -Inf)))
gg <- gg + guides(color = guide_legend(""), fill = guide_legend(""))
gg <- gg + labs(x = AUC_units , y = pd_label)
gg + facet_grid(.~DAY_label) </code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-10-1.png" width="768" /></p>
</div>
<div id="individual-response-vs-exposure-hysteresis-plots"
class="section level3">
<h3>Individual response vs exposure hysteresis plots</h3>
<!--START_EXPLANATION-->
<p>Using geom_path you can create hysteresis plots of response vs
exposure. Including details like arrows or colors can be helpful to
indicate the direction of time.</p>
<p>If most of the arrows point up and to the right or down and to the
left, this indicates a positive relationship between exposure and
response (i.e. increasing exposure -> increasing response). Arrows
pointing down and to the right or up and to the left indicate a negative
relationship.</p>
<p>In a hysteresis plot, you want to determine whether the path is
curving, and if so in what direction. If you detect a curve in the
hysteresis plot, this indicates there is a delay between the exposure
and the response. Normally, a clockwise turn indicates that increasing
exposure is associated with (a delayed) increasing response, while a
counter clockwise turn indicates increasing concentration gives (a
delayed) decreasing response.</p>
<p>In the plots below, most of the hysteresis paths follow a counter
clockwise turn, with most arrows pointing up and to the right or down
and to the left, indicating the effect increases in a delayed manner
with increasing concentration. <!--END_EXPLANATION--></p>
<pre class="r"><code>pkpd_data_wide <- pkpd_data_wide %>% arrange(ID, TIME)
gg <- ggplot(data = pkpd_data_wide, aes(x = CONC, y = PD, color = TIME))
gg <- gg + xgx_annotate_status(status)
gg <- gg + geom_path(arrow = arrow(length = unit(0.15,"cm")))
gg <- gg + labs(x = conc_label , y = pd_label)
gg <- gg + xgx_scale_x_log10()
gg <- gg + xgx_scale_y_log10()
gg <- gg + theme(panel.grid.minor.x = ggplot2::element_line(color = rgb(0.9,0.9,0.9)),
panel.grid.minor.y = ggplot2::element_line(color = rgb(0.9,0.9,0.9)))
gg + facet_wrap(~ID + TRTACT_low2high, ncol = 5)</code></pre>
<p><img src="Multiple_Ascending_Dose_PKPD_continuous_files/figure-html/unnamed-chunk-11-1.png" width="768" /></p>
</div>
</div>
<div id="r-session-info" class="section level2">
<h2>R Session Info</h2>
<pre class="r"><code>sessionInfo()</code></pre>
<pre><code>## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)
##
## Matrix products: default
## BLAS/LAPACK: /CHBS/apps/EB/software/imkl/2019.1.144-gompi-2019a/compilers_and_libraries_2019.1.144/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
## [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] survminer_0.4.9 ggpubr_0.4.0 survival_3.4-0 knitr_1.40 broom_1.0.1 caTools_1.18.2 DT_0.26 forcats_0.5.2 stringr_1.4.1
## [10] purrr_0.3.5 readr_2.1.3 tibble_3.1.8 tidyverse_1.3.2 xgxr_1.1.1 zoo_1.8-11 gridExtra_2.3 tidyr_1.2.1 dplyr_1.0.10
## [19] ggplot2_3.3.6
##
## loaded via a namespace (and not attached):
## [1] googledrive_2.0.0 colorspace_2.0-3 ggsignif_0.6.2 deldir_1.0-6 rio_0.5.27 ellipsis_0.3.2 class_7.3-19
## [8] htmlTable_2.2.1 markdown_1.2 base64enc_0.1-3 fs_1.5.2 gld_2.6.2 rstudioapi_0.14 proxy_0.4-26
## [15] farver_2.1.1 Deriv_4.1.3 fansi_1.0.3 mvtnorm_1.1-3 lubridate_1.8.0 xml2_1.3.3 codetools_0.2-18
## [22] splines_4.1.0 cachem_1.0.6 rootSolve_1.8.2.2 Formula_1.2-4 jsonlite_1.8.3 km.ci_0.5-2 binom_1.1-1
## [29] cluster_2.1.3 dbplyr_2.2.1 png_0.1-7 compiler_4.1.0 httr_1.4.4 backports_1.4.1 assertthat_0.2.1
## [36] Matrix_1.5-1 fastmap_1.1.0 gargle_1.2.1 cli_3.4.1 prettyunits_1.1.1 htmltools_0.5.3 tools_4.1.0
## [43] gtable_0.3.1 glue_1.6.2 lmom_2.8 Rcpp_1.0.9 carData_3.0-4 cellranger_1.1.0 jquerylib_0.1.4
## [50] vctrs_0.5.0 nlme_3.1-160 crosstalk_1.2.0 xfun_0.34 openxlsx_4.2.4 rvest_1.0.3 lifecycle_1.0.3
## [57] rstatix_0.7.0 googlesheets4_1.0.1 MASS_7.3-58.1 scales_1.2.1 hms_1.1.2 expm_0.999-6 RColorBrewer_1.1-3
## [64] curl_4.3.3 yaml_2.3.6 Exact_2.1 KMsurv_0.1-5 pander_0.6.4 sass_0.4.2 rpart_4.1.16
## [71] reshape_0.8.8 latticeExtra_0.6-30 stringi_1.7.8 highr_0.9 e1071_1.7-8 checkmate_2.1.0 zip_2.2.0
## [78] boot_1.3-28 rlang_1.0.6 pkgconfig_2.0.3 bitops_1.0-7 evaluate_0.17 lattice_0.20-45 htmlwidgets_1.5.4
## [85] labeling_0.4.2 tidyselect_1.2.0 GGally_2.1.2 plyr_1.8.7 magrittr_2.0.3 R6_2.5.1 DescTools_0.99.42
## [92] generics_0.1.3 Hmisc_4.7-0 DBI_1.1.3 pillar_1.8.1 haven_2.5.1 foreign_0.8-82 withr_2.5.0
## [99] mgcv_1.8-41 abind_1.4-5 RCurl_1.98-1.4 nnet_7.3-17 car_3.0-11 crayon_1.5.2 modelr_0.1.9
## [106] survMisc_0.5.5 interp_1.1-2 utf8_1.2.2 tzdb_0.3.0 rmarkdown_2.17 progress_1.2.2 jpeg_0.1-9
## [113] grid_4.1.0 readxl_1.4.1 minpack.lm_1.2-1 data.table_1.14.2 reprex_2.0.2 digest_0.6.30 xtable_1.8-4
## [120] munsell_0.5.0 bslib_0.4.0</code></pre>
</div>
</div>
</div>