-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
139 lines (102 loc) · 3.74 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
---
output:
html_document:
self_contained: no
keep_md: yes
df_print: kable
github_document:
df_print: kable
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE}
library(knitr)
knitr::opts_chunk$set(fig.width=8, fig.height=4, dev = 'png', dpi = 150,
fig.path='assets/figures/',
echo=TRUE, warning=FALSE, message=FALSE, cache = FALSE)
#results = 'asis',
```
# `caffsim` R package: Simulation of Plasma Caffeine Concentrations by Using Population Pharmacokinetic Model
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.842649.svg)](https://doi.org/10.5281/zenodo.842649)
![CRAN downloads](http://cranlogs.r-pkg.org/badges/grand-total/caffsim)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/caffsim)](https://cran.r-project.org/package=caffsim)
> Simulate plasma caffeine concentrations using population pharmacokinetic model described in Lee, Kim, Perera, McLachlan and Bae (2015) <doi:10.1007/s00431-015-2581-x> and the package was published <doi:10.12793/tcp.2017.25.3.141>.
![](inst/doc/cover.png)
- Github: <https://github.com/asancpt/caffsim>
- Package vignettes and references by `pkgdown`: <http://asancpt.github.io/caffsim>
## Installation
```{r eval = FALSE}
install.pacakges("devtools")
devtools::install_github("asancpt/caffsim")
# Simply create single dose dataset
caffsim::caffPkparam(Weight = 20, Dose = 200, N = 20)
# Simply create multiple dose dataset
caffsim::caffPkparamMulti(Weight = 20, Dose = 200, N = 20, Tau = 12)
```
## Single dose
### Create a PK dataset for caffeine single dose
```{r}
library(caffsim)
MyDataset <- caffPkparam(Weight = 20, Dose = 200, N = 20)
head(MyDataset)
```
### Create a dataset for concentration-time curve
```{r}
MyConcTime <- caffConcTime(Weight = 20, Dose = 200, N = 20)
head(MyConcTime)
```
### Create a concentration-time curve
```{r MyPlotMyConcTime}
caffPlot(MyConcTime)
```
### Create plots for publication (according to the amount of caffeine)
- `cowplot` package is required
```{r MyPlotPub, fig.width = 8, fig.height = 12}
#install.packages("cowplot") # if you don't have it
library(cowplot)
MyPlotPub <- lapply(
c(seq(100, 800, by = 100)),
function(x) caffPlotMulti(caffConcTime(20, x, 20)) +
theme(legend.position="none") +
labs(title = paste0("Single Dose ", x, "mg")))
plot_grid(MyPlotPub[[1]], MyPlotPub[[2]],
MyPlotPub[[3]], MyPlotPub[[4]],
MyPlotPub[[5]], MyPlotPub[[6]],
MyPlotPub[[7]], MyPlotPub[[8]],
labels=LETTERS[1:8], ncol = 2, nrow = 4)
```
## Multiple dose
### Create a PK dataset for caffeine multiple doses
```{r}
MyDatasetMulti <- caffPkparamMulti(Weight = 20, Dose = 200, N = 20, Tau = 12)
head(MyDatasetMulti)
```
### Create a dataset for concentration-time curve
```{r}
MyConcTimeMulti <- caffConcTimeMulti(Weight = 20, Dose = 200, N = 20, Tau = 12, Repeat = 10)
head(MyConcTimeMulti)
```
### Create a concentration-time curve
```{r MyPlotMultiMyConcTimeMulti}
caffPlotMulti(MyConcTimeMulti)
```
### Create plots for publication (according to dosing interval)
- `cowplot` package is required
```{r MyPlotMultiPub, fig.width = 8, fig.height = 12}
#install.packages("cowplot") # if you don't have it
library(cowplot)
MyPlotMultiPub <- lapply(
c(seq(4, 32, by = 4)),
function(x) caffPlotMulti(caffConcTimeMulti(20, 250, 20, x, 15)) +
theme(legend.position="none") +
labs(title = paste0("q", x, "hr" )))
plot_grid(MyPlotMultiPub[[1]], MyPlotMultiPub[[2]],
MyPlotMultiPub[[3]], MyPlotMultiPub[[4]],
MyPlotMultiPub[[5]], MyPlotMultiPub[[6]],
MyPlotMultiPub[[7]], MyPlotMultiPub[[8]],
labels=LETTERS[1:8], ncol = 2, nrow = 4)
```
## Interactive shiny app
```r
caffShiny()
```