Welcome to PK_model’s documentation!

class model.Model(Vc, Vps, Qps, CL)

A Pharmokinetic (PK) model Parameters ———-

value: numeric, optional

an example paramter

Vc: float

central compartment volume

Vps: list of floats

list of volumes of peripheral compartments

Qps: list of floats

list of transition rates between central compartment and peripheral compartments

property CL

Returns the clearance/elimination rate from the central compartment.

property Qps

Transition rates between central compartment and peripheral compartments.

property Vc

Volume of the central compartment.

property Vps

Volumes of the peripheral compartments.

add_compartment(Vp=1, Qp=1)

Add a peripheral compartment to the model.

property size

Returns the number of peripheral compartments.

class solution.Solution(model, protocol, tmax=1, nsteps=1000)

A Pharmokinetic (PK) model solution

value: numeric, optional

an example paramter

model: using model class

with model( Vc, Vps, Qps, CL)

protocol: using protocoll class to specify

intravenous or subcutaneous dosing dosing function needed

tmax: float

integrates until it reaches tmax default value is 1

nsteps: int

number of integration steps default value is 1000

compare_plots(solution_2)

Generates a matplotlib figure with two subplots that show the drug quantity in each compartment over time for the models of self and solution_2

Parameters

solution_2 – Should be a Solution object different from self

Returns

Matplotlib Figure object

compare_separate(solution_2)

Generates a matplotlib figure that shows the drug quantity over time for the models self and solution_2, with one plot per compartment

Parameters

solution_2 – Should be a Solution object different from self

Returns

Matplotlib Figure object

generate_plot(compare=None, separate=False, show=False, savefig=False)

Calls appropriate function to generate plots of the drug quantity per compartment over time for the corresponding model

Parameters

compare – If None (default), function will only generate plot

for the Solution object. If set to a Solution object, function will generate plots to compare the two models. Else, function will raise an Assertion Error.

Parameters

separate – If False (default), will show all compartments on the

same plot. Set to True if you want 1 plot per compartment.

plot(separate=False)

Generate a figure of the drug quantity per compartment over time for the corresponding model

Parameters

separate – set to True if you want 1 plot per compartment

Returns

matplotlib figure

rhs_intravenous(t, y)

Right hand side of flux equation for intravenous dosing protocol dimension of system = number of compartments = self.model.size only central compartment dim = 1 one periphal comartment dim = 2 two periphal compartment dim = 3 Parameters ———- t: time y: state vector [qc, q_p1, q_p2]

rhs_subcutaneous(t, y)

Right hand side of flux equation for subcutaneous dosing protocol dimension of system = number of compartments = self.model.size Parameters ———- t: time y: state vector [q0, qc, q_p1, q_p2] y has one dim more than in intravenous protocol q0 is an additional compartment from which the drug is absorbed to the central compartment

solver()

Runge-Kutta solver Dosing protocol specified in protocol class determines which rhs function will be used

class protocol.Protocol(dose_amount=1, subcutaneous=False, k_a=1, continuous=False, continuous_period=[0, 0], instantaneous=True, dose_times=[0], instant_doses=[1])

A Pharmokinetic (PK) protocol

This class protocol sets up the dosing protocol for a pharmokinetic model. This includes setting the amount of dose X ng either continous, multiple, or single application. Furthermore sets up the dosing type between subcutaneous and intravenous.

dose_amount: numeric, optional, default=1

This parameter takes in the amount of dose given - X ng

subcutaneous: logical, optional, default = False

This parameter is set to False for intavenous dosing and True for subcutaneous dosing.

k_a: numerical, optional, dafault = 1

This parameter specifies the absorption rate for the subcutaneous dosing.

continuous: logical, optional, default = False

This parameter specifies whether or not the dose X ng is applied at a continuous rate of X ng per hour.

continuous_period: numerical list, optional, default = [0, 0]

This parameter specifies the time period over which continuous dosing is applied. The first number in the list is the time at which continuous dosing begins and the second number is when continuous dosing ends.

instantaneous: logical, optional, default = True

This parameter specifies whether any instantaneous doses of X ng take place.

dose_times: numerical list, optional, default = [0]

This parameter is a list of numerics that specify the times at which instantaneous doses of X ng are applied.

instant_doses: numerical list, optional, default = [1].

This parameter is a list of numerics that specify the doses of X ng given instantaneously at the times specified in the dose_times param.

The method dose_time_function() for a particular time ouputs the dose(t).

Several other methods have been defined to allow certain modifcations of the dosing protocol without the necessity of reinitialising the protocol for every modification. Until other functions are supported other modifications require reintialising the object of class Protocol. Supported methods are listed below:

change_dose(), modify_dose_type(), make_continuous(), add_dose()

add_dose(time, dose)
Paramater: time: numeric, required

Additional time at which you want there to be an instantaneous dose.

Paramater: dose: numeric, required

The dose in ng that you want applied at this timepoint.

This method modifies an object of class Protocol to add an additional user specified instantaneous dose of dose ng at time. The method also specifies that instantaneous dosing does happen should it not already be specified.

change_dose(dose_amount)

Paramater: dose_amount: The dosage given - X ng

This method modfies the dose_amount parameter in the object of protocol class it is called on.

dose_time_function(t)
Paramater: t: numeric, required.

The time at which you want dose(t) to be returned.

Returns: numeric.

Dose(t) for the specific dosing protocol set up in the object

of class Protocol.

make_continuous(time_added, time_removed)

Paramater: time_added: The time that at which want continuous dosing to start. Parameter: time_removed: The time at whcih you want continuosu dosing to end.

This method modifies an object of class Protocol to convert the dosing protocol to continuous over a user specified time period.

modify_dose_type(subcutaneous, k_a=1)
Paramater: subcutaneous: boolean, required.

When set as True this specifies there is subcutaneous dosing, and when False it specifies intravenous dosing.

Paramater: k_a: numeric, optional, default = 1.

The absorption rate for the subcutaneous dosing.

This method modfies an object of class Protocol to allow users to specifiy whether there is subcutaneous or intravenous dosing. Additionally for subcutaneous dosing it allows users to modify the value of k_a.

protocol.easy_gaus(x, mean, std)

A function which returns generates a gausssian fucntion from user inputted mean and std deviation parameters and returns the value of the function at user inputted x.

Parameter: x: numeric, required

The value at which you wish the gaussian function to be evaluated.

Parameter: mean: numeric, required

The mean or the positon on the x axis at which the gaussian function is centred or at its peak.

Parameter: std: numeric, required

The standard deviation of the gaussian function.

Returns: float

The gaussian function evaluated at x, for the use specified parameters.

Indices and tables