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 CRAN downloads CRAN_Status_Badge

Simulate plasma caffeine concentrations using population pharmacokinetic model described in Lee, Kim, Perera, McLachlan and Bae (2015) and the package was published .

Installation

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

library(caffsim)
MyDataset <- caffPkparam(Weight = 20, Dose = 200, N = 20)
head(MyDataset)

Create a dataset for concentration-time curve

MyConcTime <- caffConcTime(Weight = 20, Dose = 200, N = 20)
head(MyConcTime)

Create a concentration-time curve

caffPlot(MyConcTime)

Create plots for publication (according to the amount of caffeine)

#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

MyDatasetMulti <- caffPkparamMulti(Weight = 20, Dose = 200, N = 20, Tau = 12)
head(MyDatasetMulti)

Create a dataset for concentration-time curve

MyConcTimeMulti <- caffConcTimeMulti(Weight = 20, Dose = 200, N = 20, Tau = 12, Repeat = 10)
head(MyConcTimeMulti)

Create a concentration-time curve

caffPlotMulti(MyConcTimeMulti)

Create plots for publication (according to dosing interval)

#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

caffShiny()


asancpt/caffsim documentation built on Aug. 31, 2020, 12:49 a.m.