using Random
using Pumas
using PumasUtilities
using AlgebraOfGraphics
using CairoMakie
using CSV
using DataFramesMeta
using Dates
PK46 - Long Infusion and Short Half-Life
1 Background
- Structural model - Long infusion short half life one compartment model
- Route of administration - IV infusion
- Dosage Regimen - 500000 μg
- Number of Subjects - 1
2 Learning Outcome
This exercise deals with the drug having a short half life.
3 Objectives
To build a model for a drug having a short half life given as a very long infusion of up to 3 months.
4 Libraries
Call the necessary libraries to get started.
5 Model
To build a one compartment model for a drug having a short half life given a long infusion for 3 months.
= @model begin
pk_46 @metadata begin
= "One Compartment Model"
desc = u"hr"
timeu end
@param begin
"""
Volume at Steady State (L)
"""
∈ RealDomain(lower = 0)
tvvss """
Clearance (L/hr)
"""
∈ RealDomain(lower = 0)
tvcl ∈ PDiagDomain(2)
Ω """
Additive Error
"""
∈ RealDomain(lower = 0)
σ_add end
@random begin
~ MvNormal(Ω)
η end
@pre begin
= tvvss * exp(η[1])
Vss = tvcl * exp(η[2])
Cl end
@dynamics begin
' = -(Cl / Vss) * Central
Centralend
@derived begin
= @. Central / Vss
cp """
Observed Concentration (μg/L)
"""
~ @. Normal(cp, σ_add)
dv end
end
PumasModel
Parameters: tvvss, tvcl, Ω, σ_add
Random effects: η
Covariates:
Dynamical system variables: Central
Dynamical system type: Matrix exponential
Derived: cp, dv
Observed: cp, dv
6 Parameters
Parameters provided for simulation are as below. Note that tv
represents the typical value for parameters.
Vss
- Steady state volume (L)CL
- Clearance (L/hr)
= (; tvvss = 35.6, tvcl = 61, Ω = Diagonal([0.04, 0.04]), σ_add = 0.196337) param
7 Dosage Regimen
A dose of 500000 μg was given as an Intravenous Infusion to a single subject for over 3 months.
= DosageRegimen(500000, time = 0, cmt = 1, duration = 2016) ev1
1×10 DataFrame
Row | time | cmt | amt | evid | ii | addl | rate | duration | ss | route |
---|---|---|---|---|---|---|---|---|---|---|
Float64 | Int64 | Float64 | Int8 | Float64 | Int64 | Float64 | Float64 | Int8 | NCA.Route | |
1 | 0.0 | 1 | 500000.0 | 1 | 0.0 | 0 | 248.016 | 2016.0 | 0 | NullRoute |
= Subject(id = 1, events = ev1) sub1
Subject
ID: 1
Events: 2
8 Simulation
Simulate the data after the administration of an infusion
Random.seed!(123)
The random effects are zero’ed out since we are simulating a single subject
= zero_randeffs(pk_46, sub1, param) zfx
(η = [0.0, 0.0],)
= simobs(pk_46, sub1, param, zfx, obstimes = 0.5:0.1:2100) sim_sub1
SimulatedObservations
Simulated variables: cp, dv
Time: 0.5:0.1:2100.0
9 Visualization
@chain DataFrame(sim_sub1) begin
dropmissing(:cp)
data(_) *
mapping(:time => "Time (hours)", :cp => "Concentration (μg/L)") *
visual(Lines; linewidth = 4)
draw(; figure = (; fontsize = 22), axis = (; xticks = 0:500:2000))
end
The plot below shows the decline in the concentrations after the end of the infusion
@chain DataFrame(sim_sub1) begin
@rsubset 2016 ≤ :time < 2020
data(_) *
mapping(:time => "Time (hours)", :cp => "Concentration (μg/L)") *
visual(ScatterLines; linewidth = 4)
draw(;
= (;
axis = Makie.Symlog10(10.0),
yscale = (nothing, (-0.1, nothing)),
limits = 2015:1:2020,
xticks
),
)end
10 Simulating a Population
= (; tvvss = 35.6, tvcl = 61, Ω = Diagonal([0.0125, 0.0224]), σ_add = 0.196337)
par
= DosageRegimen(500000, time = 0, cmt = 1, duration = 2016)
ev1 = map(i -> Subject(id = i, events = ev1), 1:72)
pop
Random.seed!(1234)
=
sim_pop simobs(pk_46, pop, par, obstimes = [0.5, 24, 96, 168, 672, 2016, 2016.5, 2017, 2018])
= DataFrame(sim_pop)
df_sim #CSV.write("pk_46.csv", df_sim)