Skip to content

MSDLLCpapers/cpk

Repository files navigation

Compartmental Pharmacokinetics (CPK) Analysis Library

A Python library for compartmental pharmacokinetic analysis of drug concentration-time data. It performs non-linear regression to fit one-compartment and two-compartment models, and calculates relevant PK parameters, both for intravenous (IV) and extravascular (oral) scenarios.

For an in-depth understanding of the CPK analysis performed here, refer to our published article Large-Scale Compartmental Model-Based Study of Preclinical Pharmacokinetic Data and Its Impact on Compound Triaging in Drug Discovery.

License: MIT Python 3.8+

Features

  • Compartmental Analysis: Supports one-compartment and two-compartment pharmacokinetic models
  • Multiple Routes: Handles both intravenous (IV) and extravascular (EV) administration routes
  • Model Selection: Automatically selects best-fitting model based on Akaike Information Criterion (AICc)
  • Uncertainty Analysis: Calculates parameter standard errors and identifies high-uncertainty parameters
  • Outlier Detection: Implements outlier detection and removal with automatic reprocessing
  • Command Line Interface: Easy-to-use CLI for analysis of CSV data files
  • Python API: Comprehensive programmatic interface for integration into workflows

Quick Start

Command Line Usage

# Analyze data from CSV file
cpk run --csv-path data.csv --dose 10 --parent-weight 500 --route IV

# Analyze data directly from command line
cpk run --sample-times 0.083 0.25 0.5 1 2 4 8 24 --concentrations 2.28 1.35 1.08 0.82 0.45 0.20 0.08 0.04 --dose 1 --parent-weight 564.55

# Run demo analysis
cpk demo

Python API

import pandas as pd
from cpk import IvPkAnalysis, EvPkAnalysis, load_samples

# Load data
df = pd.DataFrame({
    'sample_time': [0.083, 0.25, 0.5, 1, 2, 4, 8, 24],
    'concentration': [2.28, 1.35, 1.08, 0.82, 0.45, 0.20, 0.08, 0.04]
})

# Create analysis object
iv_cpk = IvPkAnalysis.from_df(
    samples_df=df,
    dose=1.0,  # mg/kg
    parent_weight=564.55  # g/mol
)

# Run analysis
iv_cpk.run_pk_analysis()

# Get results
results_df = iv_cpk.get_samples_dataframe()
best_model = iv_cpk.get_best_model()
model_result = iv_cpk.get_result_by_model(best_model)

print(f"Best model: {best_model}")
print(f"Clearance: {model_result.cl:.3f} L/min/kg")
print(f"Volume: {model_result.V1:.3f} L/kg")

Supported Models

Intravenous (IV) Administration

  • One-compartment model:

    C(t) = A × e^(-α×t)
    
  • Two-compartment model:

    C(t) = A × e^(-α×t) + B × e^(-β×t)
    

Extravascular (EV) Administration

  • One-compartment with absorption: Solved using ODE integration
  • Two-compartment with absorption: Solved using ODE integration

Model Selection

The library automatically selects the best model based on:

  • Akaike Information Criterion corrected (AICc)
  • Parameter uncertainty assessment
  • Goodness of fit statistics

Data Requirements

Input Data Format

CSV files or DataFrames must contain:

  • sample_time: Time points (hours)
  • concentration: Drug concentrations (μM)

Required Parameters

  • dose: Administered dose (mg/kg)
  • parent_weight: Molecular weight of parent compound (g/mol)
  • route: Administration route ('IV' or 'EV')

Output Parameters

Primary Parameters

  • Clearance (CL): Rate of drug elimination
  • Volume of distribution (V1, V2): Apparent distribution volumes
  • Rate constants (k10, k12, k21): Transfer rate constants
  • Inter-compartmental clearance (Q): Distribution clearance

Secondary Parameters

  • AUC: Area under the concentration-time curve
  • Half-life: Terminal elimination half-life
  • Mean residence time (MRT): Average time drug remains in body
  • Bioavailability: Fraction of dose reaching systemic circulation (EV only)

Quality Assessment

The library provides several quality indicators:

  • Parameter standard errors
  • Parameter uncertainty flags (>40% relative standard error)
  • Outlier detection and removal
  • Model selection confidence

API Reference

Core Classes

  • IvPkAnalysis: Intravenous pharmacokinetic analysis
  • EvPkAnalysis: Extravascular pharmacokinetic analysis
  • IvCpkResult: Results container for IV analysis
  • EvCpkResult: Results container for EV analysis
  • Sample: Individual concentration-time data point

Utility Functions

  • load_samples(): Load data from various sources
  • validate_study_parameters(): Input validation

Contributing

We welcome contributions from the community! Here's how you can help:

Reporting Issues

If you encounter bugs, have feature requests, or need help:

  1. Open an issue on the GitHub repository
  2. Provide a clear description of the problem or suggestion
  3. Include relevant details:
    • Python version
    • Operating system
    • Code snippet to reproduce (if applicable)
    • Error messages

Getting Help

  • GitHub Issues: For bug reports and feature requests
  • Email: Contact us at the address in the Contact section
  • Documentation: Check QUICKSTART.md for usage examples

Development Guidelines

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with clear commit messages
  4. Add tests if applicable
  5. Update documentation
  6. Submit a pull request

Citation

If you use CPK in your research, please cite our paper:

@article{ADP2024,
  title={Large-Scale Compartmental Model-Based Study of Preclinical Pharmacokinetic Data and Its Impact on Compound Triaging in Drug Discovery},
  journal={Molecular Pharmaceutics},
  year={2024},
  doi={10.1021/acs.molpharmaceut.4c00813},
  url={https://pubs.acs.org/doi/10.1021/acs.molpharmaceut.4c00813}
}

License

This project is licensed under the MIT License - see the LICENCE file for details.

Contact


Version: 1.0.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages