← Latest papers
📄 medicine

PKPy2: A Python framework for joint population pharmacokinetic and pharmacodynamic estimation, diagnostics, and uncertainty assessment

PKPy2 is a standalone Python framework that enables joint population pharmacokinetic and pharmacodynamic estimation, diagnostics, and uncertainty assessment by directly maximizing marginal likelihood, thereby improving parameter accuracy and convergence compared to its predecessor and demonstrating performance comparable to established tools like nlmixr2 and NONMEM.

Original authors: Hyunseung Kong, Inyoung Kim

Published 2026-10-23
📖 5 min read🧠 Deep dive

Original authors: Hyunseung Kong, Inyoung Kim

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). ✨ This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Medicine is rarely a one-size-fits-all endeavor. When a doctor prescribes a drug, they are making a calculated guess about how that specific chemical will behave inside a specific human body. Some people break down a medication quickly, flushing it out before it can do its work, while others hold onto it for days, risking an overdose. To navigate this biological chaos, scientists use a field called population pharmacokinetics. This discipline treats drug behavior not as a single fixed rule, but as a landscape of typical patterns surrounded by natural variation. By studying groups of patients, researchers can map out the average way a drug moves through the body, how much it varies from person to person, and how factors like weight or age shift the needle. This map is essential for determining the right dose for everyone, from a child to an elderly patient, ensuring the treatment is effective without being dangerous.

For decades, creating these maps required specialized, expensive software that acted as a black box, accessible only to those with specific training and licenses. A team of researchers in South Korea has now opened a new door with a tool called PKPy2. This is a free, open-source program written in Python, a language widely used by scientists for data analysis. The researchers built this tool to solve a specific problem: previous versions of their software tried to understand the group by first studying every single person separately and then averaging the results. This approach worked well when data was plentiful, but it failed miserably when data was sparse, such as when a patient only gave a few blood samples. In those cases, the errors from individual guesses piled up, distorting the picture of the whole group. PKPy2 changes the strategy entirely. Instead of looking at individuals first, it looks at the entire group at once, calculating the most likely patterns for the population while simultaneously accounting for how much each person differs from the norm.

The researchers tested this new approach rigorously, starting with thousands of simulated scenarios. They created virtual patients and gave them virtual drugs, generating data that mimicked real-world conditions, including situations where blood samples were taken very infrequently. In these tests, the old method struggled to accurately measure how much drug levels varied between people, often missing the mark by more than fifty percent. The new PKPy2 tool, however, kept its footing. Even when data was thin, it estimated the variation in drug volume with an error rate of just over thirty-two percent, a significant improvement. The tool also proved it could handle complex, real-world medical data. When the researchers applied it to actual patient records for drugs like theophylline (used for asthma) and warfarin (a blood thinner), the results matched those from the gold-standard commercial software used by experts around the world. The numbers were nearly identical, differing by less than five percent in most cases.

One of the most revealing moments in the study involved a drug called tobramycin, used to treat serious bacterial infections. When the researchers let the computer run freely without any human guidance, it found a mathematical solution that looked statistically perfect but made no biological sense, suggesting the drug distributed into a body compartment far larger than physically possible. This happened because the data was limited, and the computer chased a mathematical shortcut. However, when the researchers added simple, real-world constraints based on medical knowledge—telling the software that certain body volumes could not exceed specific limits—the tool immediately found the correct, biologically plausible answer. This demonstrated that the software is not just a calculator, but a flexible partner that can incorporate a doctor's expert judgment to steer the analysis toward reality.

The tool also excels at speed and clarity when dealing with long treatment histories. In modern medicine, patients often receive dozens or even hundreds of doses over time. Calculating drug levels for such long histories used to be a slow, repetitive process. PKPy2 uses a mathematical shortcut that allows it to predict drug levels for a thousand doses almost instantly, making it hundreds of times faster than previous methods for these specific calculations. Beyond speed, the software provides a full suite of tools to check its own work. It can generate visual charts that show how well the model fits the data, highlight which patients are outliers, and calculate the uncertainty of its predictions. It even includes a way to handle missing data or measurements that were too low to detect, a common hurdle in clinical trials.

By moving these powerful calculations into a free, transparent environment, the researchers have made advanced drug modeling accessible to a much wider audience. The software does not hide its logic behind a paywall or a proprietary interface; instead, it allows scientists to see exactly how the numbers are derived. The study confirms that this new approach recovers the true patterns of drug behavior more accurately than older methods, especially when data is scarce. It bridges the gap between complex statistical theory and practical medical application, offering a way to refine drug dosing that is both mathematically robust and grounded in biological reality. As the authors note, this framework provides a unified way to specify models, estimate parameters, and assess uncertainty, all within a single, standalone environment that anyone with a computer can use.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →