pkmodel package

Module contents

pkmodel is a Pharmokinetic modelling library.

It contains functionality for creating, solving, and visualising the solution of Parmokinetic (PK) models

Submodules

pkmodel.compartment module

class pkmodel.compartment.Compartment(name, volume=None, k_rate=None, q0=0)[source]

Bases: object

A Pharmokinetic (PK) compartment used in a given model type. Holds compartment data.

Parameters

param name:

Name/Type of compartment - must be either central, dose, or peripheral_X.

type name:

string

param volume:

The volume of compartment, mush be positive and if not set (as not required for dose) it is set to None, which errors if central or peripheral compartment

type volume:

float

param k_rate:

Transition rate out of a given compartment. Depending on compartment type is CL, k_a, or Q_Pi.

type k_rate:

float

param q0:

Initial quantity of drug in compartment.

type q0:

float

pkmodel.model module

class pkmodel.model.Model(name='pkmodel')[source]

Bases: object

A Pharmokinetic (PK) model that contain defines drug compartments, dosing protocol and holds solutions.

Parameters

param name:

Name of model

type name:

string

add_Ncompartments(N, **kwargs)[source]

Append multiple new compartment to peripheral compartment dictionary.

Parameters

param N:

Numbr of compartment

type N:

int

param kwargs:

Keyword arguments for compartment to set compartment variables, i.e. volume, transition rate(k_rate), initial drug quantity(q0)

type kwargs:

None

add_compartment(name, **kwargs)[source]

Append new compartment to corresponding compartment dictionary.

Parameters

param name:

Name of compartment, must be correctly formatted to add to dictionary correctly must be either central, dose, or peripheral_X.

type name:

string

param kwargs:

Keyword arguments for compartment to set compartment variables, i.e. volume, transition rate(k_rate), initial drug quantity(q0)

type kwargs:

None

add_protocol(name, dose)[source]

Append new protocol for drug dosing, either subcutaneous or intravenous. Parameters ———- :param name: Name of protocol, either subcutaneous or intravenous. :type name: string

Parameters:

dose (Function) – Dose function defining how dose changes over time

solve(t_eval, *args, **kwargs)[source]

Finds solution of drug dosage over time for a given set of compartments, dose and transition/CL rates.

Parameters

param t_eval:

Array of time points that model is solved for.

type t_eval:

arr

param args:

Arguments, if required, needed to passs to dose function.

type args:

None

param kwargs:

Keyword arguments for optional self definition of initial quantiies q0, and if solutions are returned

pkmodel.protocol module

class pkmodel.protocol.Protocol(name, compartments, dose)[source]

Bases: object

A Pharmokinetic (PK) protocol defines the dising protocol and defines corresponding form the right-hand side of the PK ODE.

Parameters

param name:

Name of protocol, either subcutaneous or intravenous.

type name:

string

param compartments:

Dictionary of compartments/ classes holding classes.

type name:

list

param dose:

Dose function defining how dose changes over time

type dose:

Function

rhs(t, q, *args)[source]

Defines corresponding form of the right-hand side of the PK ODE. Parameters ———- :param t: Time parameter of model. :type t: arr :param q: Ndim-vector representing quantities of drug (qi) across N compartments, first value quantity for central compartment, if dose compartment given it is set as last value :type q: arr :param args: Arguments to pass to dose function :type args: None

Return rhs_ib:

RHS of ODE for the model

pkmodel.solution module

class pkmodel.solution.Solution(models)[source]

Bases: object

Class to analysis solutions to Pharmokinetic (PK) model that contain defines drug compartments, dosing protocol and holds solutions.

Parameters

param models:

Model list holding solved models

type models:

class

add_model(model)[source]

Function to add model to models list.

Parameters

param models:

Model list holding solved models

type models:

class

plot_all(save=False, **kwargs)[source]

Function to plot all models’ results in one graph

plot_indiv(save=False)[source]

Function to plot individual model results