Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ok-landscape
GitHub Repository: Ok-landscape/computational-pipeline
Path: blob/main/latex-templates/templates/biomedical/pharmacokinetics.tex
51 views
unlisted
1
\documentclass[11pt,a4paper]{article}
2
\usepackage[utf8]{inputenc}
3
\usepackage[T1]{fontenc}
4
\usepackage{amsmath,amssymb}
5
\usepackage{graphicx}
6
\usepackage{booktabs}
7
\usepackage{siunitx}
8
\usepackage{geometry}
9
\geometry{margin=1in}
10
\usepackage{pythontex}
11
\usepackage{hyperref}
12
\usepackage{float}
13
14
\title{Pharmacokinetics\\Compartment Models and Drug Concentration}
15
\author{Clinical Pharmacology Division}
16
\date{\today}
17
18
\begin{document}
19
\maketitle
20
21
\begin{abstract}
22
Computational modeling of drug absorption, distribution, metabolism, and elimination using compartment models.
23
\end{abstract}
24
25
26
\section{Introduction}
27
28
Pharmacokinetics describes the time course of drug concentration in the body.
29
30
\begin{pycode}
31
import numpy as np
32
import matplotlib.pyplot as plt
33
from scipy.integrate import odeint
34
plt.rcParams['text.usetex'] = True
35
plt.rcParams['font.family'] = 'serif'
36
\end{pycode}
37
38
\section{One-Compartment Model}
39
40
$\frac{dC}{dt} = -k_e C$
41
42
\begin{pycode}
43
# IV bolus
44
C0 = 100 # Initial concentration (mg/L)
45
k_e = 0.1 # Elimination rate constant (1/h)
46
t = np.linspace(0, 48, 200)
47
48
C = C0 * np.exp(-k_e * t)
49
t_half = np.log(2) / k_e
50
51
fig, ax = plt.subplots(figsize=(10, 6))
52
ax.semilogy(t, C, 'b-', linewidth=2)
53
ax.axhline(y=C0/2, color='r', linestyle='--', label=f'$t_{{1/2}}$ = {t_half:.1f} h')
54
ax.axvline(x=t_half, color='r', linestyle='--')
55
ax.set_xlabel('Time (h)')
56
ax.set_ylabel('Concentration (mg/L)')
57
ax.set_title('One-Compartment Model: IV Bolus')
58
ax.legend()
59
ax.grid(True, alpha=0.3, which='both')
60
plt.tight_layout()
61
plt.savefig('one_compartment.pdf', dpi=150, bbox_inches='tight')
62
plt.close()
63
\end{pycode}
64
65
\begin{figure}[H]
66
\centering
67
\includegraphics[width=0.85\textwidth]{one_compartment.pdf}
68
\caption{Drug concentration after IV bolus administration.}
69
\end{figure}
70
71
\section{Oral Administration}
72
73
\begin{pycode}
74
k_a = 1.0 # Absorption rate constant
75
F = 0.8 # Bioavailability
76
D = 500 # Dose (mg)
77
V = 50 # Volume of distribution (L)
78
79
C_oral = (F * D * k_a / (V * (k_a - k_e))) * (np.exp(-k_e * t) - np.exp(-k_a * t))
80
81
fig, ax = plt.subplots(figsize=(10, 6))
82
ax.plot(t, C_oral, 'b-', linewidth=2)
83
t_max = np.log(k_a / k_e) / (k_a - k_e)
84
C_max = (F * D * k_a / (V * (k_a - k_e))) * (np.exp(-k_e * t_max) - np.exp(-k_a * t_max))
85
ax.plot(t_max, C_max, 'ro', markersize=10)
86
ax.annotate(f'$C_{{max}}$ = {C_max:.1f} mg/L\n$t_{{max}}$ = {t_max:.1f} h',
87
xy=(t_max, C_max), xytext=(t_max + 5, C_max))
88
ax.set_xlabel('Time (h)')
89
ax.set_ylabel('Concentration (mg/L)')
90
ax.set_title('Oral Administration')
91
ax.grid(True, alpha=0.3)
92
plt.tight_layout()
93
plt.savefig('oral_admin.pdf', dpi=150, bbox_inches='tight')
94
plt.close()
95
\end{pycode}
96
97
\begin{figure}[H]
98
\centering
99
\includegraphics[width=0.85\textwidth]{oral_admin.pdf}
100
\caption{Drug concentration after oral administration.}
101
\end{figure}
102
103
\section{Two-Compartment Model}
104
105
\begin{pycode}
106
def two_compartment(y, t, k12, k21, k10):
107
C1, C2 = y
108
dC1dt = -k12 * C1 + k21 * C2 - k10 * C1
109
dC2dt = k12 * C1 - k21 * C2
110
return [dC1dt, dC2dt]
111
112
k12 = 0.5
113
k21 = 0.2
114
k10 = 0.1
115
y0 = [100, 0]
116
117
sol = odeint(two_compartment, y0, t, args=(k12, k21, k10))
118
119
fig, ax = plt.subplots(figsize=(10, 6))
120
ax.semilogy(t, sol[:, 0], 'b-', linewidth=2, label='Central')
121
ax.semilogy(t, sol[:, 1], 'r-', linewidth=2, label='Peripheral')
122
ax.set_xlabel('Time (h)')
123
ax.set_ylabel('Concentration (mg/L)')
124
ax.set_title('Two-Compartment Model')
125
ax.legend()
126
ax.grid(True, alpha=0.3, which='both')
127
plt.tight_layout()
128
plt.savefig('two_compartment.pdf', dpi=150, bbox_inches='tight')
129
plt.close()
130
\end{pycode}
131
132
\begin{figure}[H]
133
\centering
134
\includegraphics[width=0.85\textwidth]{two_compartment.pdf}
135
\caption{Two-compartment model showing distribution phase.}
136
\end{figure}
137
138
\section{Multiple Dosing}
139
140
\begin{pycode}
141
tau = 8 # Dosing interval (h)
142
n_doses = 6
143
t_multi = np.linspace(0, n_doses * tau, 500)
144
C_multi = np.zeros_like(t_multi)
145
146
for i in range(n_doses):
147
t_dose = i * tau
148
mask = t_multi >= t_dose
149
C_multi[mask] += C0 * np.exp(-k_e * (t_multi[mask] - t_dose))
150
151
fig, ax = plt.subplots(figsize=(10, 6))
152
ax.plot(t_multi, C_multi, 'b-', linewidth=2)
153
ax.set_xlabel('Time (h)')
154
ax.set_ylabel('Concentration (mg/L)')
155
ax.set_title('Multiple Dosing Regimen')
156
ax.grid(True, alpha=0.3)
157
158
# Steady state
159
C_ss_max = C0 / (1 - np.exp(-k_e * tau))
160
C_ss_min = C0 * np.exp(-k_e * tau) / (1 - np.exp(-k_e * tau))
161
ax.axhline(y=C_ss_max, color='r', linestyle='--', alpha=0.5)
162
ax.axhline(y=C_ss_min, color='g', linestyle='--', alpha=0.5)
163
plt.tight_layout()
164
plt.savefig('multiple_dosing.pdf', dpi=150, bbox_inches='tight')
165
plt.close()
166
\end{pycode}
167
168
\begin{figure}[H]
169
\centering
170
\includegraphics[width=0.85\textwidth]{multiple_dosing.pdf}
171
\caption{Drug accumulation with repeated dosing.}
172
\end{figure}
173
174
\section{Continuous Infusion}
175
176
\begin{pycode}
177
R = 50 # Infusion rate (mg/h)
178
CL = k_e * V # Clearance
179
180
C_infusion = (R / CL) * (1 - np.exp(-k_e * t))
181
C_ss = R / CL
182
183
fig, ax = plt.subplots(figsize=(10, 6))
184
ax.plot(t, C_infusion, 'b-', linewidth=2)
185
ax.axhline(y=C_ss, color='r', linestyle='--', label=f'$C_{{ss}}$ = {C_ss:.1f} mg/L')
186
ax.set_xlabel('Time (h)')
187
ax.set_ylabel('Concentration (mg/L)')
188
ax.set_title('Continuous IV Infusion')
189
ax.legend()
190
ax.grid(True, alpha=0.3)
191
plt.tight_layout()
192
plt.savefig('infusion.pdf', dpi=150, bbox_inches='tight')
193
plt.close()
194
\end{pycode}
195
196
\begin{figure}[H]
197
\centering
198
\includegraphics[width=0.85\textwidth]{infusion.pdf}
199
\caption{Drug concentration during continuous infusion.}
200
\end{figure}
201
202
\section{Loading Dose}
203
204
\begin{pycode}
205
D_loading = C_ss * V
206
t_loading = np.linspace(0, 24, 200)
207
208
# With loading dose
209
C_with_load = C_ss + (D_loading/V - C_ss) * np.exp(-k_e * t_loading)
210
# Without loading dose
211
C_without_load = (R / CL) * (1 - np.exp(-k_e * t_loading))
212
213
fig, ax = plt.subplots(figsize=(10, 6))
214
ax.plot(t_loading, C_with_load, 'b-', linewidth=2, label='With loading dose')
215
ax.plot(t_loading, C_without_load, 'r--', linewidth=2, label='Without loading dose')
216
ax.axhline(y=C_ss, color='k', linestyle=':', alpha=0.5)
217
ax.set_xlabel('Time (h)')
218
ax.set_ylabel('Concentration (mg/L)')
219
ax.set_title('Effect of Loading Dose')
220
ax.legend()
221
ax.grid(True, alpha=0.3)
222
plt.tight_layout()
223
plt.savefig('loading_dose.pdf', dpi=150, bbox_inches='tight')
224
plt.close()
225
\end{pycode}
226
227
\begin{figure}[H]
228
\centering
229
\includegraphics[width=0.85\textwidth]{loading_dose.pdf}
230
\caption{Comparison with and without loading dose.}
231
\end{figure}
232
233
\section{Results}
234
235
\begin{pycode}
236
print(r'\begin{table}[H]')
237
print(r'\centering')
238
print(r'\caption{Pharmacokinetic Parameters}')
239
print(r'\begin{tabular}{@{}lc@{}}')
240
print(r'\toprule')
241
print(r'Parameter & Value \\')
242
print(r'\midrule')
243
print(f'Half-life & {t_half:.1f} h \\\\')
244
print(f'Volume of distribution & {V} L \\\\')
245
print(f'Clearance & {CL:.1f} L/h \\\\')
246
print(f'Steady-state concentration & {C_ss:.1f} mg/L \\\\')
247
print(r'\bottomrule')
248
print(r'\end{tabular}')
249
print(r'\end{table}')
250
\end{pycode}
251
252
\section{Conclusions}
253
254
Compartment models provide essential tools for drug dosing optimization and therapeutic monitoring.
255
256
257
\end{document}
258
259