-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeck_00.Rmd
134 lines (100 loc) · 3.31 KB
/
deck_00.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
---
title: "Introduction to <grn>mrgsolve</grn><BR>Welcome"
author: Kyle T. Baron
date: Metrum Research Group, LLC
output:
slidy_presentation:
number_sections: true
css: [styles/slidystyles.css,styles/colors.css]
html_document:
theme: united
number_sections: true
toc: true
css: [styles/htmlstyles.css,styles/colors.css]
---
```{r, include = FALSE}
library(mrgsolve)
library(dplyr)
library(knitr)
library(lattice)
opts_chunk$set(comment = '.', fig.height = 5, fig.width = 9, message = FALSE)
tryit_file <- "workbook.Rmd"
```
```{r setup, echo = FALSE, message = FALSE}
mod <- mread_cache("pk1", modlib()) %>%
update(end = 192, delta = 0.2) %>% Req(CP)
data(exidata)
data <- filter(exidata, ID <= 10)
set.seed(1222)
```
---
```{r, echo = FALSE}
mod %>% ev(amt = 100) %>% mrgsim(end = 72) %>% plot()
```
---
```{r, echo = FALSE}
mod %>% ev(amt = 100, ii = 24, addl = 4) %>% mrgsim() %>% plot()
```
---
```{r, echo = FALSE}
mod <- mread_cache("popex", modlib()) %>% Req(DV)
data <- expand.ev(amt = 300, ii = 24, addl = 4, ID = seq(20))
mod %>% data_set(data) %>% mrgsim() %>% plot()
```
---
```{r, echo = FALSE}
hmod <- mrgsolve:::house() %>% Req(DV,RESP) %>% update(end = 244)
hdat <- mutate(data, time = 24)
mrgsim(hmod, data = hdat, omega = dmat(0.1,0.1,0.1,0.1)) %>% plot()
```
---
```{r, echo = FALSE}
idata <- data_frame(VC = c(20,60,180))
hmod %>% mrgsim(idata = idata, end = 24*28, delta = 0.1,
events = ev(amt = 100, ii = 24, addl = 28)) %>%
plot(DV~.)
```
---
```{r, echo = FALSE}
mod <- mread_cache("conway", "model")
e <- ev(amt = 1, evid = 8, time = 180) + ev(amt = 0, evid = 8, time = 2.5*365)
idata <- data_frame(L_0 = c(1,3,5,7,10))
out <- mrgsim(mod, events = e, idata = idata, end = 6*365, delta = 1)
out@data <- mutate(out@data, time = time - 180)
plot(out, L+logV~(time/365), xlab = "Time (year)")
```
# About `mrgsolve`
- `R` package for simulation from ODE-based models
- Free, OpenSource, GitHub, CRAN
- Language
- Models written in `C++` inside model specification format
- General purpose solver: `ODEPACK` / `DLSODA` (`FORTRAN`)
- Simulation workflow in `R`
- Hierarchical (population) simulation
- `ID`, $\eta$, $\varepsilon$
- Integrated PK functionaility
- Bolus, infusion, `F`, `ALAG`, `SS` etc, handled under the hood
- 1- and 2-cmt PK models in closed-form
- Extensible using `R`, `C++`, `Rcpp`, `boost`, `RcppArmadillo`
- `R` is it's natural habitat
# `mrgsovle` started as `QSP` modeling tool
- Motivation: large bone/mineral homeostatsis model (CaBone)
- History using
- Berkeley Madonna
- WinBUGS
- NONMEM (attempted)
- 2010: write `R` front end to `deSolve`
- 2012: write `C++` interface to `DLSODA`
- Develop dosing / event capability
- More recently, expose functionality provided by
- `Rcpp` - vectors, matrices, functions, environments, random numbers
- `boost` - numerical tools in `C++`
- users' own `C++` code (functions, data structures, classes)
- Translator from `SBML` to `mrgsolve` using `R` bindings to `libSBML`
# Orientation
- https://github.com/mrgsolve/learn
- GitHub site: https://github.com/metrumresearchgroup/mrgsolve
- mrgsolve website: https://mrgsolve.github.io
- User Guide: https://mrgsolve.github.io/user_guide
# Please download the zipped repo again
- https://github.com/mrgsolve/learn