-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworkbook.Rmd
337 lines (207 loc) · 6 KB
/
workbook.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
---
title: "Vignette Title"
output:
github_document:
toc: true
---
```{r, setup, echo = FALSE, message = FALSE, warning = FALSE}
library(mrgsolve)
library(tidyverse)
```
# Problems
## Warm-up
Choose a `PKPD` model from the internal model library (`?modlib_pkpd`)
to explore
- Check the parameter values (`param`)
- Check the compartments and initial values (`init`)
- Review the model code (`see)
```{r, warm_up_example, eval = FALSE}
mod <- mread_cache("", modlib())
```
Extra credit: can you match up the output what what is going
on in the code?
```{r, eval = FALSE}
mod %>% mrgsim()
```
## Meropenem PK
- Load the `meropenem` model from the model directory
- Simulate the following scenarios:
- 100 mg IV bolus q8h x 3
- 100 mg IV over 3 hours q8h x3
Look at the `CP` output
```{r}
```
## Z-Pak
You've been sick for the last two weeks and can't take it any more. Finally,
you decide to go to the doctor, who gives you a diagnosis of
walking pneumonia. When you get home with your azithromycin
prescription, you start wondering about the directions: take
500 mg as a single dose on Day 1, followed by 250 mg once daily
on Days 2 through 5.
Explore this regimen using the following model:
- Model name: `azithro`
- Model location: `model`
Simulate out to at least day 14 to see what is happening.
```{r, z_pak_example, eval = FALSE}
mod <- mread("", "") %>% zero_re
```
## Output
Run the following code and check the output
```{r, eval = FALSE}
mod <- mread_cache("azithro", "model")
out <-
mod %>%
ev(amt = 500) %>%
mrgsim(end = 24, delta = 4)
out
class(out)
head(out)
out$CP
as.data.frame(out)
as_data_frame(out)
filter(out, time==12)
mutate(out, success = TRUE) %>% class
```
## Secukinumab for psoriasis
You are the pharmacometrician supporting secukinumab program for psoriasis,
and the team wants an update. You start telling them about
this awesome indirect response model you developed for week-5 PASI scores.
It has log-normal IIV and combined additive / prortional error model. Standard
errors look good and the condition number was low. The pred-corrected VPC
and NPDE plots showed showed nothing to worry about.
As you wrap up your report, you notice the blank stares coming back from the
faces of the team members.
The clin pharm lead breaks the uncomfortable slience: We're looking at
a 100 mg dose in the 5 week induction period. We'd like to push the dose
higher, but also worried about candida infection. If we increase to 125
mg or 150 mg, are we likely to see lower PASI scores? How close are
we to reaching the maximum effect for end of induction?
- Use the `secukinumab` PK/PD model
- Dose once weekly for 5 weeks
- Generate a plot of PASI as fraction of baseline after 5 weekly
doses between 0 and 150 mg
```{r}
mod <- mread_cache("secukinumab", "model") %>% zero_re()
see(mod)
out <- mod %>% ev(amt = 25) %>% mrgsim(end = 35)
plot(out)
tail(out)
```
## Statin/CsA DDI
- Load the model `yoshikado`
- Examine the the following drug-drug interaction
- pitavastatin 30 mg x1
- cyclosporine 2000 mg x1; wait 1 hr; then pitavastatin 30 mg x1
- What parameters is the pitavastatin profile sensitive to?
```{r}
```
## GCSF dosing
- Simulate 2.5, 5, and 10 mcg/kg assuming 50, 70, 90 kg individual
- Simulate 2.5, 5, and 10 mcg/kg assuming log(WT) ~ N(log(80),0.1)
- Do daily SC dosing x 7d
```{r}
```
## Sim EBE
```{r}
data <- read_table("data/patab", skip = 1)
```
# Answers
## Warm-up
```{r, warm_up_answer}
mod <- mread_cache("irm4", modlib())
param(mod)
init(mod)
see(mod)
```
```{r, eval = FALSE}
mod %>% mrgsim()
```
## Meropenem PK
```{r}
mod <- mread_cache("meropenem", "model")
mod %>%
ev(amt = 100, ii = 8, addl = 2) %>%
mrgsim() %>%
plot
```
```{r}
mod <- mread_cache("meropenem", "model")
mod %>%
ev(amt = 100, ii = 8, rate = 100/3, addl = 2) %>%
mrgsim() %>%
plot
```
## Z-Pak
```{r, z_pak_answer}
mod <- mread("azithro", "model") %>% zero_re
param(mod)
param(mod)$TVV1 + param(mod)$TVV2
```
Set up an dosing event
```{r}
load <- ev(amt = 500, ii = 24, addl = 0)
maint <- ev(amt = 250, ii = 24, addl = 3)
dose <- seq(load, maint)
mod %>%
ev(dose) %>%
mrgsim (end = 24*21) %>%
plot(CP + PER2 + PER3 ~time/24)
```
## Output
```{r}
mod <- mread_cache("azithro", "model")
out <-
mod %>%
ev(amt = 500) %>%
mrgsim(end = 24, delta = 4)
out
class(out)
head(out)
out$CP
as.data.frame(out)
as_data_frame(out)
filter(out, time==12)
mutate(out, success = TRUE) %>% class
```
## Statin/CsA DDI
```{r}
mod <- mread_cache("yoshikado", "model", end = 14, delta = 0.1)
e1 <- ev(amt = 2000, cmt = 2)
mod %>% ev(e) %>% mrgsim() %>% plot(CSA~.)
e2 <- ev(amt = 30, time = 1)
mod %>% ev(e2) %>% mrgsim() %>% plot(CP~.)
out1 <- mod %>% ev(e2) %>% mrgsim_df(delta = 0.1) %>% mutate(ddi = FALSE)
out2 <- mod %>% ev(e1+e2) %>% mrgsim_df(delta = 0.1) %>% mutate(ddi = TRUE)
out <- bind_rows(out1, out2)
ggplot(out, aes(time, CP, col = ddi)) + geom_line(lwd = 1) +
scale_y_continuous(trans = "log10", limits = c(0.1, 100),
breaks = 10^seq(-4,4)) +
scale_color_brewer(palette = "Set1")
out %>% group_by(ddi) %>% summarise(Cmax = max(CP))
#out %>% group_by(ddi) %>% summarise(auc = PKPDmisc::auc_partial(time, CP))
```
## Sim EBE
```{r, message = FALSE}
patab <- read_table("data/meropenem/patab", skip = 1)
patab <- distinct(patab, .keep_all = TRUE)
head(patab)
mod <- mread_cache("pk2", modlib())
inventory(mod, patab)
patab <- rename(patab, V3 = V2, V2 = V1)
inventory(mod,patab)
data <- read_csv("data/Simulated_DatasetMeropenem.csv", na = '.')
head(data)
data <- filter(data, EVID==1) %>% mutate(DUR = round(AMT/RATE,1), DOSE = AMT)
data <- mutate(data, II = 8, ADDL = 11, CMT = "CENT")
count(data,CMT,AMT,RATE,DUR)
dosing <- left_join(data, patab, by = "ID")
tg <- tgrid(0,24,0.25) + 3*24
out <-
mod %>%
data_set(dosing) %>%
carry_out(DOSE,DUR) %>%
mrgsim(tgrid = tg, obsonly = TRUE) %>%
as.data.frame
ggplot(out, aes(TIME,CP, group = ID)) +
facet_wrap(DUR~DOSE) + geom_line()
```