-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
109 lines (80 loc) · 2.83 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
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```
# campsismod <img src='man/figures/logo.png' align="right" alt="" width="120" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/Calvagone/campsismod/workflows/R-CMD-check/badge.svg)](https://github.com/Calvagone/campsismod/actions)
[![codecov](https://codecov.io/gh/Calvagone/campsismod/branch/main/graph/badge.svg?token=7DHBRQD7AG)](https://app.codecov.io/gh/Calvagone/campsismod)
[![CRAN version](http://www.r-pkg.org/badges/version/campsismod)](https://cran.r-project.org/package=campsismod)
[![CRAN total downloads](https://cranlogs.r-pkg.org/badges/grand-total/campsismod)](https://cran.r-project.org/package=campsismod)
[![CRAN total downloads](https://cranlogs.r-pkg.org/badges/campsismod)](https://cran.r-project.org/package=campsismod)
<!-- badges: end -->
```{r, echo=FALSE, warning=FALSE, message=FALSE, results='hide'}
EXPORT_PNG <- FALSE
```
## Installation
Install the latest stable release using `devtools`:
```{r, eval=FALSE}
devtools::install_github("Calvagone/campsismod")
```
## Basic examples
### Load example from model library
Load 2-compartment PK model from built-in model library:
```{r message=FALSE}
library(campsismod)
model <- model_suite$pk$`2cpt_fo`
```
### Write CAMPSIS model
```{r message=FALSE, results='hide'}
model %>% write(file="path_to_model_folder")
```
```{r}
list.files("path_to_model_folder")
```
### Read and show CAMPSIS model
```{r}
model <- read.campsis(file="path_to_model_folder")
show(model)
```
### Simulate with rxode2 or mrgsolve
```{r, eval=EXPORT_PNG}
library(campsis)
dataset <- Dataset(5) %>%
add(Bolus(time=0, amount=1000, ii=12, addl=2)) %>%
add(Observations(times=0:36))
rxode <- model %>% simulate(dataset=dataset, dest="rxode2", seed=0)
mrgsolve <- model %>% simulate(dataset=dataset, dest="mrgsolve", seed=0)
```
```{r, eval=EXPORT_PNG}
spaghettiPlot(rxode, "CONC")
```
```{r, echo=FALSE, results='hide'}
file_vignette <- "vignettes/resources/results_rxode.png"
```
```{r, eval=EXPORT_PNG, echo=FALSE, results='hide'}
ggplot2::ggsave(filename=file_vignette, width=7, height=3, dpi=100)
```
```{r, eval=EXPORT_PNG, echo=EXPORT_PNG, results='hide'}
file.copy(file_vignette, "docs/articles/resources/")
```
![RxODE simulation results](vignettes/resources/results_rxode.png)
```{r, eval=EXPORT_PNG}
spaghettiPlot(mrgsolve, "CONC")
```
```{r, echo=FALSE, results='hide'}
file_vignette <- "vignettes/resources/results_mrgsolve.png"
```
```{r, eval=EXPORT_PNG, echo=FALSE, results='hide'}
ggplot2::ggsave(filename=file_vignette, width=7, height=3, dpi=100)
```
```{r, eval=EXPORT_PNG, echo=EXPORT_PNG, results='hide'}
file.copy(file_vignette, "docs/articles/resources/")
```
![mrgsolve simulation results](vignettes/resources/results_mrgsolve.png)