-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvalidation.Rmd
241 lines (189 loc) · 8.63 KB
/
validation.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
---
title: Validation of Noncompartmental Analysis Performed by NonCompart R package
author: Sungpil Han <shan@acp.kr>
date: "`r Sys.Date()`"
bibliography: ['manual.bib', 'packages.bib']
always_allow_html: yes
output:
bookdown::pdf_document2: default
pdf_document: default
html_document: default
header-includes:
- \usepackage{textcomp}
---
```{r setup, include = FALSE}
# knitr::write_bib(file='Test.bib')
library(knitr)
library(kableExtra) # devtools::install_github("haozhu233/kableExtra")
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
```
------
# Introduction
NonCompart R package [@R-NonCompart; @Kim_2018] can conduct a noncompartmental analysis as similar as possible to the most widely used commercial software for pharmacokinetic analysis, i.e. [Phoenix^®^ WinNonlin^®^](https://www.certara.com/software/pkpd-modeling-and-simulation/phoenix-winnonlin/) [@wnl].
This document provides validation of noncompartmental analysis performed by NonCompart R package version `r packageVersion("NonCompart")` as compared to the results from the commercial software, WinNonlin^®^ version 6.3 and 7.0.
# Results
A function, `Equal()` will return `TRUE` if there is no difference between results from NonCompart and WinNonlin.
```{r}
# install.packages("NonCompart", repos="http://r.acr.kr")
library(NonCompart)
RptCfg = read.csv("RptCfg.csv", as.is=TRUE)
Equal = function(Wres, Rres, Tol=0.001)
{
Wres[,"ID"] = as.character(Wres[,"Subject"])
ColName0 = colnames(Rres)
rownames(RptCfg) = RptCfg[,"PPTESTCD"]
colnames(Rres) = c(ColName0[1], RptCfg[ColName0[-1],"WNL"])
Inter = intersect(colnames(Wres), colnames(Rres))
IsSame = TRUE
for (i in 1:nrow(Wres)) {
for (j in Inter) {
R = as.numeric(Rres[i,j])
W = as.numeric(Wres[i,j])
if (W != 0) {
if(abs((R - W)/W) > Tol) {
print(Wres[i,j])
print(Rres[i,j])
IsSame = FALSE
}
}
}
}
return(IsSame)
}
```
Eight comparison tests were performed using `Theoph` and `Indometh` default datasets. (Table 1)
Detailed side-by-side comparison is in Appendix A.
```{r results = 'asis', echo = FALSE}
table_1 <- 'No.,Dataset,Down,Route,Hyperlink
1,Theoph (n=12),Linear,Extravascular,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Theoph_Linear.csv)
2,Theoph (n=12),Log,Extravascular,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Theoph_Log.csv)
3,Indometh (n=6),Linear,IV Bolus,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Linear.csv)
4,Indometh (n=6),Log,IV Bolus,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Log.csv)
5,Indometh (n=6),Linear,IV Infusion (0.25hr),[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Linear_Infusion.csv)
6,Indometh (n=6),Log,IV Infusion (0.25hr),[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Log_Infusion.csv)
7,Indometh (n=6),Linear,Extravascular,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Linear_Wrong_Extravascular.csv)
8,Indometh (n=6),Log,Extravascular,[CSV](https://raw.githubusercontent.com/asancpt/NonCompart-tests/master/Final_Parameters_Pivoted_Indometh_Log_Wrong_Extravascular.csv)'
knitr::kable(readr::read_csv(table_1), caption = 'Description of settings for the noncompartmental analysis performed in WinNonlin and links to the raw data', booktabs = TRUE, format = 'pandoc')
```
```{r}
Theoph[,"Subject"] = as.numeric(as.character(Theoph[,"Subject"]))
Indometh[,"Subject"] = as.numeric(as.character(Indometh[,"Subject"]))
Wres1 = read.csv("Final_Parameters_Pivoted_Theoph_Linear.csv")
Rres1 = tblNCA(Theoph, "Subject", "Time", "conc", dose=320, concUnit="mg/L")
Equal(Wres1, Rres1)
Wres2 = read.csv("Final_Parameters_Pivoted_Theoph_Log.csv")
Rres2 = tblNCA(Theoph, "Subject", "Time", "conc", dose=320, down="Log",
concUnit="mg/L")
Equal(Wres2, Rres2)
Wres3 = read.csv("Final_Parameters_Pivoted_Indometh_Linear.csv")
Rres3 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, adm="Bolus",
concUnit="mg/L", R2ADJ=0.8)
Equal(Wres3, Rres3)
Wres4 = read.csv("Final_Parameters_Pivoted_Indometh_Log.csv")
Rres4 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, adm="Bolus",
down="Log", concUnit="mg/L", R2ADJ=0.8)
Equal(Wres4, Rres4)
Wres5 = read.csv("Final_Parameters_Pivoted_Indometh_Linear_Infusion.csv")
Rres5 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, adm="Infusion",
dur=0.25, concUnit="mg/L", R2ADJ=0.8)
Equal(Wres5, Rres5)
Wres6 = read.csv("Final_Parameters_Pivoted_Indometh_Log_Infusion.csv")
Rres6 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, adm="Infusion",
dur=0.25, down="Log", concUnit="mg/L", R2ADJ=0.8)
Equal(Wres6, Rres6)
Wres7 = read.csv("Final_Parameters_Pivoted_Indometh_Linear_Wrong_Extravascular.csv")
Rres7 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, concUnit="mg/L",
R2ADJ=0.8)
Equal(Wres7, Rres7)
Wres8 = read.csv("Final_Parameters_Pivoted_Indometh_Log_Wrong_Extravascular.csv")
Rres8 = tblNCA(Indometh, "Subject", "time", "conc", dose=25, down="Log",
concUnit="mg/L", R2ADJ=0.8)
Equal(Wres8, Rres8)
```
\pagebreak
# Conclusion
*There is no discrepancy* between results from NonCompart and WinNonlin. We also performed multiple analyses with the real clinical trial datasets and have found no differences (data not shown: confidential). Noncompartmental analysis performed by the open-source R package, NonCompart can be **qualified and validated** enough to acquire the identical results of the commercial software, WinNonlin.
*Please report issues regarding validation of the R package to <https://github.com/asancpt/NonCompart-tests/issues>.*
------
**Affiliation**:
Sungpil Han
M.D/Ph.D, Resident
Department of Clinical Pharmacology and Therapeutics,
Asan Medical Center, University of Ulsan,
Seoul 05505, Republic of Korea
E-mail: shan@acp.kr
URL: www.github.com/shanmdphd
\pagebreak
# (APPENDIX) Appendix {-}
# Side-by-side comparison of results {#sidebyside}
```{r}
library(dplyr)
library(tidyr)
table_wres_rres <- function(wres, rres, Caption){
wres %>%
gather(WNL, WinNonlin, -Subject) %>%
left_join(RptCfg %>% select(PPTESTCD, WNL), by = "WNL") %>%
left_join(rres %>% as.data.frame() %>% gather(PPTESTCD, NonCompart, -Subject),
by = c("Subject", "PPTESTCD")) %>%
select(Subject, PPTESTCD, WNL, NonCompart, WinNonlin) %>%
mutate(NonCompart = as.numeric(NonCompart),
WinNonlin = as.numeric(WinNonlin)) %>%
mutate(Difference = ifelse((NonCompart - WinNonlin) / WinNonlin < 0.001,
yes = 0, no = 'Larger than tol.')) %>%
mutate(Difference = ifelse(is.na(Difference), 0, Difference)) %>%
filter(!is.na(WinNonlin) & !is.na(NonCompart)) %>%
knitr::kable(longtable = TRUE, booktabs = TRUE, # format = "latex",
caption = Caption) %>%
add_header_above(c(" ", "Pharmacokinetic Parameters" = 2, "Values" = 2, " ")) %>%
kable_styling(latex_options = c("repeat_header"))
}
```
## Test 1: Theoph (n=12), Linear, Extravascular
```{r}
table_wres_rres(Wres1, Rres1,
Caption = 'Theoph (n=12), Linear, Extravascular')
```
## Test 2: Theoph (n=12), Log, Extravascular
```{r}
table_wres_rres(Wres2, Rres2,
Caption = 'Theoph (n=12), Log, Extravascular')
```
## Test 3: Indometh (n=6), Linear, IV Bolus
```{r}
table_wres_rres(Wres3, Rres3,
Caption = 'Indometh (n=6), Linear, IV Bolus')
```
## Test 4: Indometh (n=6), Log, IV Bolus
```{r}
table_wres_rres(Wres4, Rres4,
Caption = 'Indometh (n=6), Log, IV Bolus')
```
## Test 5: Indometh (n=6), Linear, IV Infusion (0.25hr)
```{r}
table_wres_rres(Wres5, Rres5,
Caption = 'Indometh (n=6), Linear, IV Infusion (0.25hr)')
```
## Test 6: Indometh (n=6), Log, IV Infusion (0.25hr)
```{r}
table_wres_rres(Wres6, Rres6,
Caption = 'Indometh (n=6), Log, IV Infusion (0.25hr)')
```
## Test 7: Indometh (n=6), Linear, Extravascular
```{r}
table_wres_rres(Wres7, Rres7,
Caption = 'Indometh (n=6), Linear, Extravascular')
```
## Test 8: Indometh (n=6), Log, Extravascular
```{r}
table_wres_rres(Wres8, Rres8,
Caption = 'Indometh (n=6), Log, Extravascular')
```
# Session Information
```{r}
devtools::session_info()
```
# References {-}
```{r include = FALSE}
library(NonCompart)
knitr::write_bib(file = 'packages.bib')
```