BP101T Unit 3 – Data Visualization & Pharmacokinetics
Unit 3 focuses on scientific data visualization using Matplotlib and Seaborn, plotting drug plasma concentration vs. time profiles ($C_p$ vs. $t$), computing pharmacokinetic parameters ($C_{max}, T_{max}, K_e, t_{1/2}, \text{AUC}$), and calculating dissolution profile comparison factors ($f_1$ difference factor and $f_2$ similarity factor).
📋 Prescribed Syllabus Topics
📖 Detailed Lecture Notes & Solved Examples
11. Matplotlib & Seaborn Architecture for Scientific Plotting
Dedicated Webpage➔Matplotlib is the foundational 2D plotting library in Python. It uses a hierarchy of objects: the `Figure` (the overall canvas window) containing one or more `Axes` (individual coordinate systems with x-axis, y-axis, titles, and plot elements). Seaborn builds on top of Matplotlib to provide high-level statistical themes and beautiful color palettes tailored for multi-variable bio-data.Matplotlib Python me graph banane ki sabse popular library hai. Isme `Figure` ka matlab pura canvas hota hai aur `Axes` wo graph area hai jisme x-axis aur y-axis par data plot hota hai. `plt.savefig()` se high resolution PNG image save hoti hai.
▶Basic Scientific Plotting Architecture
Setting up a publication-quality figure canvas with axes labels, grid lines, and custom legends.
import matplotlib.pyplot as plt
# Create Figure and Axes
fig, ax = plt.subplots(figsize=(8, 5), dpi=150)
time = [0, 1, 2, 4, 6, 8, 12]
conc = [0.0, 8.4, 12.6, 9.1, 5.2, 2.8, 0.7]
ax.plot(time, conc, marker='o', color='#10b981', linewidth=2, label='500mg Tablet')
ax.set_title('In Vivo Pharmacokinetic Absorption Profile', fontsize=14, fontweight='bold')
ax.set_xlabel('Time Post-Administration (hours)', fontsize=11)
ax.set_ylabel('Plasma Drug Concentration (ug/mL)', fontsize=11)
ax.grid(True, linestyle='--', alpha=0.6)
ax.legend(frameon=True)
plt.tight_layout()
- •`plt.subplots(nrows, ncols)` creates figure window and subplot axes arrays.
- •`ax.plot()` creates continuous line charts; `ax.scatter()` plots discrete point data.
- •`plt.savefig('pk_profile.png', dpi=300)` exports high-resolution figures for journal publications.
22. Plasma Concentration vs. Time Curves (Cp vs. t) & PK Parameters
Dedicated Webpage➔Following oral administration of a solid dosage form, the drug undergoes dissolution, gastrointestinal absorption, distribution throughout body tissues, and elimination via hepatic metabolism and renal excretion. A plot of Plasma Concentration ($C_p$) against Time ($t$) displays three distinct phases: (1) Absorption Phase where rate of absorption exceeds elimination, (2) Peak Concentration ($C_{max}$) at time $T_{max}$ where rate of absorption equals elimination ($dC/dt = 0$), and (3) Elimination Phase where drug clearance dominates. The Therapeutic Window is bounded by the Minimum Effective Concentration (MEC) and the Minimum Toxic Concentration (MTC).Oral tablet khane ke baad blood me dawa ka level badhta hai (Absorption Phase), phir peak par pahunchta hai jise Cmax aur uske samay ko Tmax kehte hain, aur phir kidney/liver se filter hokar kam hota hai (Elimination Phase). MEC aur MTC ke beech ke safe area ko Therapeutic Window kehte hain.
▶Automated Pharmacokinetic Parameter Extraction Script
Extracting Cmax, Tmax, elimination rate constant (Ke), and elimination half-life (t1/2) from clinical sampling data.
import numpy as np
import math
time_hrs = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 12.0])
cp_ug_ml = np.array([0.0, 3.8, 7.9, 11.4, 12.5, 9.8, 6.7, 3.1, 1.4, 0.3])
# 1. Cmax and Tmax
c_max = np.max(cp_ug_ml)
t_max = time_hrs[np.argmax(cp_ug_ml)]
# 2. Elimination Rate Constant (Ke) from terminal elimination phase (hours 6, 8, 12)
# Slope of ln(Cp) vs time = -Ke
term_t = time_hrs[-3:]
term_cp = cp_ug_ml[-3:]
slope, _ = np.polyfit(term_t, np.log(term_cp), 1)
ke = -slope
half_life = 0.693 / ke
print(f"Peak Concentration (Cmax): {c_max:.2f} ug/mL")
print(f"Time to Peak (Tmax): {t_max:.2f} hours")
print(f"Elimination Rate Constant (Ke): {ke:.4f} hr^-1")
print(f"Elimination Half-Life (t1/2): {half_life:.2f} hours")
| PK Parameter | Symbol | Standard Units | Clinical Significance |
|---|---|---|---|
| Peak Plasma Concentration | Cmax | μg/mL or mg/L | Determines therapeutic efficacy and risk of acute toxicity |
| Time to Peak | Tmax | Hours | Reflects rate of gastrointestinal absorption |
| Elimination Rate Constant | Ke | hr⁻¹ | Fraction of drug removed from body per unit time |
| Elimination Half-Life | t1/2 | Hours | Determines dosing frequency and time to steady state (4-5 half-lives) |
| Area Under the Curve | AUC | μg·hr/mL | Measures total systemic extent of drug absorption / bioavailability |
- •$C_{max}$: Maximum drug concentration achieved in systemic circulation.
- •$T_{max}$: Time required to reach $C_{max}$ (indicator of absorption rate).
- •Therapeutic Range: Drug concentration interval between MEC and MTC.
- •Elimination Half-life ($t_{1/2}$): Time required for plasma concentration to decrease by 50% ($t_{1/2} = 0.693 / K_e$).
33. Area Under the Curve (AUC) by Linear Trapezoidal Rule
Dedicated Webpage➔Area Under the Curve ($\text{AUC}_{0\rightarrow t}$) represents the total cumulative drug exposure over time and is the primary metric for calculating absolute and relative bioavailability. Because plasma samples are drawn at discrete time intervals ($t_0, t_1, t_2, \dots, t_n$), the area is calculated geometrically by dividing the curve into vertical trapezoids and summing their individual areas.AUC se hume pata chalta hai ki shareer me kul kitni dawa intact pahunchi (Bioavailability). Graph ke neeche ka area nikalne ke liye Trapezoidal formula lagate hain jisme 2 time points ke beech ka average concentration time difference se multiply hota hai.
▶Linear Trapezoidal AUC Calculation Implementation
Formula for segment area: $\text{Area}_i = \frac{C_i + C_{i+1}}{2} \times (t_{i+1} - t_i)$.
def calculate_trapezoidal_auc(time_pts, cp_pts):
"""Calculates AUC(0->t) using the linear trapezoidal rule"""
total_auc = 0.0
for i in range(len(time_pts) - 1):
dt = time_pts[i+1] - time_pts[i]
avg_conc = (cp_pts[i] + cp_pts[i+1]) / 2.0
segment_area = avg_conc * dt
total_auc += segment_area
return total_auc
time_data = [0.0, 1.0, 2.0, 4.0, 6.0, 8.0]
cp_data = [0.0, 10.0, 8.0, 4.0, 2.0, 0.5]
auc_value = calculate_trapezoidal_auc(time_data, cp_data)
print(f"Total AUC(0-8h): {auc_value:.2f} ug*hr/mL")
- •Bioavailability ($F$): Fraction of administered dose that reaches systemic circulation intact.
- •Relative Bioavailability: $F_{rel} = \frac{\text{AUC}_{test}}{\text{AUC}_{standard}} \times \frac{\text{Dose}_{standard}}{\text{Dose}_{test}}$.
- •Bioequivalence Criterion: 90% confidence intervals of geometric mean ratio of Test/Reference for AUC and $C_{max}$ must fall within 80.00% to 125.00%.
44. Dissolution Profile Comparison: Difference Factor (f1) & Similarity Factor (f2)
Dedicated Webpage➔In generic formulation development and post-approval manufacturing changes (SUPAC), in vitro dissolution profiles of a Test formulation must be compared against a Reference (innovator) product. The FDA and CDSCO mandate computing the Difference Factor ($f_1$) and Similarity Factor ($f_2$). An $f_1$ value between 0 and 15 ensures minor percentage difference, while an $f_2$ value between 50 and 100 demonstrates equivalent dissolution performance (bio-similarity).Generic dawai ko brand leader se compare karne ke liye dissolution profile match karte hain. f1 factor ka value 0 se 15% ke beech hona chahiye (difference kam ho), aur f2 factor ka value 50 se 100 ke beech hona chahiye (similarity 50% se jyada ho).
▶FDA f1 and f2 Dissolution Profile Comparative Script
Calculating similarity and difference factors across 6 dissolution sampling time points.
import numpy as np
import math
# Dissolution percentages at 5, 10, 15, 20, 30, 45 min
ref_diss = np.array([21.0, 45.0, 68.0, 82.0, 94.0, 98.0])
test_diss = np.array([23.0, 48.0, 65.0, 80.0, 92.0, 97.0])
n = len(ref_diss)
# 1. Difference Factor (f1): { [sum(|R_t - T_t|)] / [sum(R_t)] } * 100
f1 = (np.sum(np.abs(ref_diss - test_diss)) / np.sum(ref_diss)) * 100.0
# 2. Similarity Factor (f2): 50 * log10( { 1 + (1/n)*sum((R_t - T_t)^2) }^(-0.5) * 100 )
mean_sq_error = (1.0 / n) * np.sum((ref_diss - test_diss) ** 2)
f2 = 50.0 * math.log10((1.0 + mean_sq_error) ** (-0.5) * 100.0)
print(f"Difference Factor (f1): {f1:.2f}% (Acceptance: 0 - 15%) -> {'PASS' if f1 <= 15 else 'FAIL'}")
print(f"Similarity Factor (f2): {f2:.2f} (Acceptance: 50 - 100) -> {'PASS' if f2 >= 50 else 'FAIL'}")
- •Difference Factor ($f_1$): Calculates percentage difference between two curves at each time point (Must be $\le 15\%$).
- •Similarity Factor ($f_2$): Logarithmic reciprocal square-root transformation of mean squared error (Must be between $50$ and $100$).
- •When $f_2 = 100$, the test and reference dissolution profiles are identical.
- •At least 12 individual dosage units (tablets/capsules) should be tested per time point for regulatory submissions.
- In university 10-mark questions on PK profiling, draw the Cp vs t curve clearly labeling Absorption Phase, Cmax, Tmax, Elimination Phase, MEC, and MTC.
- State the mathematical acceptance ranges for bioequivalence ($f_1 \le 15\%$ and $f_2 \ge 50$).