New open source R libraries for simulation and visualization: “PKPDsim” and “vpc”
Ron Keizer (1,2,3), Devin Pastoor (4), Rada Savic (1,2)
(1) UCSF, San Francisco, CA (2) InsightRX, San Francisco, CA (3) Pirana Software & Consulting, the Netherlands (4) University of Maryland, Baltimore, MD
PKPDsim library
In pharmacometrics, many models are defined as systems of ordinary differential equations (ODEs). Although solving ODEs numerically in R is relatively straightforward using the deSolve library, the implementation of e.g. infusions and complex dosing regimens as well as the incorporation of random effects is cumbersome. Therefore, modelers commonly resort to Berkeley Madonna (BM) for exploratory simulations and teaching purposes instead of relying on R. BM does provide excellent interactivity features and is fast[1], but is inferior to R regarding plotting functionality, cumbersome regarding implementation of dose regimens and multi-level variability, and not open source/free.
The PKPDsim R library aims to offer similar features to Berkeley Madonna but within the R environment, so that the user can take advantage of R's powerful statistics and visualization tools. The library facilitates simulation of dosing regimens for PKPD mixed-effects models, leveraging either the fast Boost C++ library or R::deSolve for numerical integration. The PKPDsim library can be used from the R command line, but can also dynamically generate Shiny frontends to allow interactive use for model exploration and teaching purposes.
vpc library:
Model simulations and simulation-based diagnostics such as the Visual Predictive Check are essential parts of the modeling workflow. Most modelers will be familiar with the functionality offered by e.g. PsN[4]/Xpose[5] or Monolix[6]. These tools are somewhat inflexible, however, as they are limited to one specific software and produce plots that are not easily tweakable and/or extendible.
The new 'vpc' library is written completely in R, and includes all plots also available in PsN/Xpose/Monolix: continuous, prediction-corrected, categorical, censored, survival, Kaplan-Meier Mean Covariate plots[7], as well as NPDE plots with uncertainty[8]. In comparison with the aforementioned tools, the “vpc” R library has the following strengths:
- use input data from any simulation tool (e.g. R, Matlab, ADAPT, Monolix, Phoenix, or the PKPDsim library introduced above)
- parsing and visualization steps in same environment (R)
- more binning strategies, easier to change binning
- output is ggplot2 object: easier customizable and extendable
- flexible plot options to e.g. optionally plot only observed data, or only simulated percentiles
- fast, by leveraging dplyr for main calculations
Both libraries will soon be released on CRAN, but are currently already available from http://www.github.com/ronkeizer.
References:
[1] Chotsiri et al. WCoP 2012 Korea. PM6-2 [http://www.go-wcop.org/data/WCoP_ProgramAbstract.pdf]
[2] http://simulx.webpopix.org/
[3] http://shiny.rstudio.com
[4] http://psn.sf.net
[5] http://xpose.sf.net
[6] http://www.lixoft.eu
[7] Hooker et al., PAGE 21 (2012) Abstr 2564 [www.page-meeting.org/?abstract=2564]
[8] Comets et al. PAGE 22 (2013) Abstr 2775 [www.page-meeting.org/?abstract=2775]