forked from metrumresearchgroup/mrgsolve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
175 lines (119 loc) · 3.75 KB
/
README.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
---
pagetitle: "mrgsolve"
date: ""
author: ""
output: github_document
---
```{r,echo=FALSE}
library(lattice)
library(knitr)
```
```{r, include = FALSE}
knitr::opts_chunk$set(
comment = ".",
fig.path = "man/figures/README-"
)
options(tibble.print_min = 5, tibble.print_max = 5)
```
# mrgsolve <img align="right" src = "man/figures/mrgsolve_sticker_812418_1.png" width="135px">
[![Build Status](https://travis-ci.org/metrumresearchgroup/mrgsolve.svg?branch=master)](https://travis-ci.org/metrumresearchgroup/mrgsolve)
[![CRAN](http://www.r-pkg.org/badges/version/mrgsolve)](https://cran.r-project.org/package=mrgsolve)
[![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)
[![questions](https://img.shields.io/badge/ask_for-Help-brightgreen.svg)](https://github.com/metrumresearchgroup/mrgsolve/issues)
[![MetrumRG](https://img.shields.io/badge/contact-MetrumRG-brightgreen.svg)](http://metrumrg.com)
mrgsolve is an R package for simulation from hierarchical, ordinary differential
equation (ODE) based models typically employed in drug development. mrgsolve
is free and open-source software.
## Resources
Please see [mrgsolve.github.io](https://mrgsolve.github.io) for additional
resources, including:
- [User Guide](https://mrgsolve.github.io/user_guide)
- [R Documentation](https://mrgsolve.github.io/docs)
- [Vignettes](https://mrgsolve.github.io/vignettes)
- [Gallery](https://github.com/mrgsolve/gallery)
## Installation
Install the latest release on CRAN
```{r,eval=FALSE}
install.packages("mrgsolve")
```
__Please__ be sure to see important install-related information
[here](https://github.com/metrumresearchgroup/mrgsolve/wiki/mrgsolve-Installation).
Install the current development version
```{r,eval=FALSE}
remotes::install_github("metrumresearchgroup/mrgsolve@dev")
```
## Interaction
We welcome __questions__ about anything mrgsolve: installation, getting your
model to work, understanding better how mrgsolve works. We also welcome __suggestions__
for how to make mrgsolve more useful to you and to the pharmacometrics community.
Please interact with us at the [Issue Tracker](https://github.com/metrumresearchgroup/mrgsolve/issues).
This requires a GitHub account.
## Some examples
### A simple simulation
```{r,echo=FALSE}
options(mrgsolve_mread_quiet = TRUE)
```
```{r,message=FALSE}
library(mrgsolve)
```
Load a model from the internal library
```{r}
mod <- mread("pk1", modlib())
```
Simulate a simple regimen
```{r,pk-figure}
mod %>%
ev(amt = 100, ii = 24, addl = 9) %>%
mrgsim(end = 300, delta = 0.1) %>%
plot(CP~time)
```
A more complicated regimen: 100 mg infusions over 2 hours every 24 hours
for one week, followed by 50 mg boluses every 12 hours for 10 days:
```{r,regimen-figure}
mod %>%
ev_rx("100 over 2h q 24 x 7 then 50 q 12 x 20") %>%
mrgsim(end = 600, delta = 0.1) %>%
plot(CP~time)
```
### Population simulation
```{r}
mod <- mread("popex", modlib()) %>% zero_re()
```
A data set looking at different patient weights and doses
```{r, message=FALSE}
library(dplyr)
data <- expand.ev(amt = c(100,150), WT = seq(40,140,20)) %>% mutate(dose = amt)
head(data)
```
Simulate
```{r, population-figure}
mod %>%
data_set(data) %>%
carry_out(dose,WT) %>%
mrgsim(delta = 0.1, end = 72) %>%
plot(IPRED~time|factor(dose),scales = "same")
```
### Sensitivity analysis with PBPK model
```{r}
mod <- modlib("pbpk")
```
Reference
```{r, comment = " ", echo=FALSE}
blocks(mod,PROB)
```
Model parameters
```{r}
param(mod)
```
Set up a batch to simulate
```{r}
idata <- expand.idata(Kpli = seq(4,20,2))
idata
```
```{r, pbpk-figure}
mod %>%
ev(amt = 150) %>%
idata_set(idata) %>%
mrgsim(end = 6, delta = 0.1) %>%
plot(Cp~time)
```