- Language: en
- Documentation version: 1.3.1
Motivation
Patients being treated for a given medical condition come in all shapes and sizes, and each patient’s illness will affect them differently. Each patient should therefore receive personalized treatment that ensures the best response for their particular circumstances. This requires an understanding of how variation between patients influences the effect of a given drug on a given condition. Variation between patients can be both directly observed - properties such as age and weight, known as covariates - or observed indirectly through the patient’s response to a specific dosing regimen of the drug.
In order to predict the effect of this variation better, compartmental models were developed that approximate, in a simple way, what the body does to the drug (pharmacokinetics) and what the drug does to the body (pharmacodynamics). These models treat the body as a series of compartments through which the drug circulates until eventually eliminated either through metabolism or excretion. The rate at which the drug moves between compartments is specified by a set of equations that are controlled by a set of model parameters.
Because every individual in a population will process the drug differently, it is important that these model parameters be personalized to each individual. This results, however, in an explosion of parameters for which there is rarely enough data to constrain the solution.
An approach called Nonlinear Mixed Effects Modelling (NLME) addresses this problem by modelling individual parameters as random deviations from a population average, both of which have specific statistical distributions that indicate the likelihood of any particular solution given observed data.
The difficulty with these nonlinear models is that the equations defining them are mathematically complex and must be solved numerically.
In the late 1970s, Stuart L. Beal and Lewis B. Sheiner began developing a computer software package called Nonmem - short for Nonlinear Mixed Effects Modelling - that was written in Fortran and was being used for data analysis at least as early as 1980 [Evaluation of methods for estimating population pharmacokinetics parameters. I. Michaelis-Menten model: routine clinical pharmacokinetic data. Sheiner LB, Beal SL. J Pharmacokinet Biopharm. 1980 Dec;8(6):553-71. doi: 10.1007/BF01060053.].
Nonmem was groundbreaking and quickly set the “Gold Standard” for modelling nonlinear drug effects. Perhaps surprisingly, over four decades later, Nonmem is still the market leader in pharmacokinetic and pharmacodynamic (PK/PD) analysis. A quick analysis of PAGE meeting abstracts suggests that Nonmem still has around a 50% market share within the PK/PD community, and a similar analysis of PubMed abstracts indicates the same pattern.
In those four decades, however, there have been many advances in programming languages, numerical algorithms and computer hardware. Although Nonmem has benefited from some of these (e.g. developments in CPU power), its implementation in Fortran limits the advances on which it can capitalize and from which its many users would benefit (e.g. an enhanced user interface or improved numerical algorithms).
As a result, a number of other packages have emerged that offer similar or alternative approaches to dealing with nonlinear mixed effect models, often using newer languages that can more easily be extended, suggesting that there is appetite for alternatives.
Many of these alternative PK/PD packages, however, only simulate new data and do not estimate population parameters from a given dataset and model, which is arguably the most useful function of a PK/PD modelling package. Unsatisfied by most of these alternatives, therefore, we embarked upon a project to build a modelling package that was as powerful as Nonmem only easier for developers to maintain and extend, and for modellers to use without the need for add-ons such as “Perl speaks Nonmem” to augment its functionality (e.g. visualization and reporting).
Because we wanted a system that would be easy to extend, we chose to implement our system in Python that has a vast ecosystem of libraries and an enormous user community, making it arguably the go-to language choice for data science at the time of writing.
The result is a software package for Population PK/PD in Python - “PoPy” - with many desirable features:
Simulation: To support simulating one or many populations from a model, either from scratch or from seed values, PoPy offers many closed-form models, complex dosing functions and built-in sampling distributions (rather than just the normal distribution).
Parameter Estimation: To support fitting complex models to large datasets, PoPy offers several fitting algorithms, using symbolic differentation for more efficient and accurate parameter updates.
Visualization: To assist in reporting, PoPy generates a range of plots, tables and reports.
Ease-of-use: To be as easy to pick up as possible, especially for existing Nonmem users, PoPy uses a structured input script format that makes it easy to write complex models yet requires little to no Python experience from the user.
Performance: To be as powerful as possible, we compile much of the speed-critical code in Cython for high performance on a single CPU, and we provide parallel computing capabilities (via MPI) to maximize resource use on challenging problems with a large population of individuals.
Here we present PoPy and demonstrate its capability, using comparisons to other major packages for illustration, suggesting that PoPy shows promise as a research platform for PK/PD analysis.