Yang Zhang (1), Dirk Garmann (1)
(1) Bayer AG, Germany
Introduction:
Implementation of a pharmacometric model in R is a prerequisite for accomplishing different tasks – from a demonstration plot to a full scale simulation; from parameter estimation to evaluating a trial design.
Numerous attempts to reduce the burden of implementing pharmacometric models in R have been made which resulted in new packages on CRAN as well as github. Yet when drilling down to the implementation of pharmacometric models by numerically solving the ordinary differential equations, LSODA still remains the dominating algorithm and is available in one of the most widely used packages for solving ODEs, deSolve.
This work is intended to implement a relatively complex compartmental pharmacometric model in R ultilizing the default method (LSODA) of deSolve and compare the performance in terms of time of execution among different implementations.
Objectives:
To check different implementations of a PMX model in R and compare the time needed to execute
Methods:
A PK model for an antibody drug conjugate (ADC) was chosen as an exemplary model due to its complexity as well as a target binding component which is used more and more often. The model consists of 7 compartments with 2 compartments for the ADC, 3 for the toxophore and 2 for the active agent metabolized from the toxophore.
The model was first implemented purely in R. Then the computation of the derivatives for each compartment (i.e., the right hand sides of the ODEs) was conducted using compiled code written in C++ (via the Rcpp package[1]), C or Fortran (using the interfaces provided by R)[2]. Explicitly computing the Jacobian matrix was added using the same way as the calculation of the r.h.s of the ODEs – R, C++ via Rcpp, C or Fortran. In total, eight implementations were compared in terms of total execution time for 100 repetitions.
The execution environment was a server with CPU base frequency of 2.5GHz running Red Hat Enterprise Linux Server release 6.9 (Santiago). R (3.2.5) with deSolve (version 1.13) and Rcpp (0.12.4) was deployed and the compiler used was GCC version 4.4.7.
Results:
For the implementation without explicit computing the Jacobian matrix, the pure R version took more than 1000 seconds to complete 100 executions while using Rcpp could reduce the time to about 3 minutes (183.015 sec). Using C and Fortran further reduced the time to less than 1.5 seconds (1.379 second for C implementation and 1.402 sec for Fortran implementation). On the other hand, adding a function to compute the Jacobian matrix increased the efficiency of the ODE solver for all except the C version. For the pure R implementation, adding specific codes for the Jacobian shortened the execution time to 28.511 sec. For C++ version, there was an almost 30 times increase in speed (6.232 sec for the version with explicit Jacobian computation compared to 183.15 sec without). Unexpectively, the C implementation with explicit function for Jacobian actually prolonged the execution to 9.810 sec.In contrast the Fortran implementation with separate subroutine for Jacobian was the fastest one among those tested which needed just 0.271 sec to provide the results.
Conclusions:
When implementing a pharmacometric model in R several approaches are available to improve the performance. As shown in this example the efficiency gain can be quite large. Depending the experience of the user, explicit calculation of Jacobian matrix and / or conducting parts of the computation using compiled codes (C++, C or Fortran) may be considered to accelerate the process.
References:
[1] https://cran.r-project.org/web/packages/Rcpp/index.html, accessed Feb 20, 2019
[2] https://cran.r-project.org/web/packages/deSolve/vignettes/compiledCode.pdf, accessed Feb 20, 2019
Reference: PAGE 28 (2019) Abstr 9115 [www.page-meeting.org/?abstract=9115]
Poster: Methodology - Other topics