library(ggplot2)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Chapter 4: Extravascular Dose

Ex2 Relation equations
Based on AUC analysis
\[ F* Dose = CL * AUC\] \[ F = CL * \frac{AUC}{Dose}\] or other equantion for calculating bioavailability (F) \[ F = (\frac{AUC_{e.v}}{AUC_{i.v}})*(\frac{Dose_{i.v}}{Dose_{e.v}})\]

\[ F_{rel} = \frac{F_B}{F_A} = (\frac{AUC_B}{AUC_A}) * (\frac{Dose_A}{Dose_B}) \]

Based on Urine analysis
\[ F = (\frac{Ae_{e.v}}{Ae_{i.v}})*(\frac{Dose_{i.v}}{Dose_{e.v}})\] \[F_{rel} = \frac{F_B}{F_A} = (\frac{Ae_B}{Ae_A}) * (\frac{Dose_A}{Dose_B}) \]

# define variables
c4_ex2_iv_dose <- 500 #mg
c4_ex2_iv_AUC <- 13.1 # mg-hr/L
c4_ex2_iv_Ae <- 332 # 0-48h, mg

c4_ex2_ev_f1_dose <- 1000
c4_ex2_ev_f1_AUC <- 20.9
c4_ex2_ev_f1_Ae <- 586

c4_ex2_ev_f2_dose <- 1000
c4_ex2_ev_f2_AUC <- 19.9
c4_ex2_ev_f2_Ae <- 554

# Based on AUC
# Calculate CL based on F . Dose_iv = CL. AUC_iv
c4_ex2_CL <- c4_ex2_iv_dose / c4_ex2_iv_AUC

# calculate Bioavailability (F) and Relative Bioavailability (Frel) of formuation 2
# F_ev * Dose_ev = CL * AUC_ev
c4_ex2_ev_f1_F <- round(c4_ex2_CL * c4_ex2_ev_f1_AUC/c4_ex2_ev_f1_dose,3)
c4_ex2_ev_f2_F <- round(c4_ex2_CL * c4_ex2_ev_f2_AUC/c4_ex2_ev_f2_dose,3)

# calculate F_rel = F_2 / F_1
c4_ex2_AUC_F_rel <- c4_ex2_ev_f2_F / c4_ex2_ev_f1_F

# Based on Urine
# F = (Ae/Dose)_oral / (Ae/Dose)_iv
c4_ex2_ev_uri_f2_F <- (c4_ex2_ev_f2_Ae/c4_ex2_ev_f2_dose) / (c4_ex2_iv_Ae/c4_ex2_iv_dose)

# F_rel of formulation 2 vs. formulation 1
# F_rel = (Ae/Dose)_f2 / (Ae/Dose)_f1
c4_ex2_ev_uri_f2_F_rel <- (c4_ex2_ev_f2_Ae/c4_ex2_ev_f2_dose) / (c4_ex2_ev_f1_Ae/c4_ex2_ev_f1_dose)

The results are
Based on AUC:
+ F = 0.76
+ Frel = 0.95
**Based on Urine data:**
+ F = 0.83
+ Frel = 0.95

Asumptions are:
- Clearance remains constant
- The values of fe is also constant

2.c: Renal Clearance was calculated using the equation \[CL_R = \frac{Ae}{AUC}\]

c4_ex2_iv_CLr <- c4_ex2_iv_Ae/c4_ex2_iv_AUC

c4_ex2_ev_f1_CLr <- c4_ex2_ev_f1_Ae/ c4_ex2_ev_f1_AUC

c4_ex2_ev_f2_CLr <- c4_ex2_ev_f2_Ae/ c4_ex2_ev_f2_AUC

There are differences between intravenous renal clearance and oral renal clearance with 25.3435115 L/hr, 28.0382775 L/hr and 27.839196 L/hr.

Ex4

# Subject information
c4_ex4_weight <- 60 #kg
c4_ex4_ad_units <- 40

c4_ex4_iv_AUC <- 3010
c4_ex4_sub_AUC <- 1372

c4_ex4_iv_Cmax <- 417
c4_ex4_sub_Cmax <- 40.5

c4_ex4_iv_Tmax <- 5/60 #hr
c4_ex4_sub_Tmax <- 12

c4_ex4_iv_T_hf <- 6.7
c4_ex4_sub_t_hf <- 16.1

# 4a. Define the Clearance and volume of distribution

# CL = Dose_iv / AUC
# Dose = Weight * Units
c4_ex4_Dose <- c4_ex4_weight * c4_ex4_ad_units

c4_ex4_CL <- round(c4_ex4_Dose / c4_ex4_iv_AUC, 1)


# calculate Vd = CL / k
c4_ex4_k <- log(2)/c4_ex4_iv_T_hf
c4_ex4_Vd <- round(c4_ex4_CL / c4_ex4_k, 2)

# 4b. Calculate F = AUCsub / AUCiv
ce_ex4_sub_F <- round(c4_ex4_sub_AUC / c4_ex4_iv_AUC, 2)

The results are:
CL = 0.8 L/hr
Vd = 7.73 L
Fsub = 0.46

Ex7

# Input data into data frame
ex7_Time <- c(0.33, 0.5, 0.67, 1, 1.5, 2, 4, 6, 10, 16, 24, 32, 48)
ex7_iv_Conc <- c(14.7, 12.6, 11.0, NA ,9.0, 8.2, 7.9, 6.6, 6.2, 4.6, 3.2, 2.3, 1.2)
ex7_oral_Conc <- c(NA, 2.4, NA, 3.8, 4.2, 4.6, 8.1, 5.8, 5.1, 4.1, 3.0, 2.3, 1.3)

ex7 <- data.frame(Time = ex7_Time, iv.Conc = ex7_iv_Conc, oral.Conc <- ex7_oral_Conc)
# plot semilogarit plot
# for iv
ggplot(data = ex7, aes(x = Time, y = iv.Conc)) +
    geom_point(color = "blue") + 
    scale_y_log10() +
    ggtitle("Plot of intravenous dose") +
    xlab("Time(hr)") +
    ylab("Plasma Concentration (mg/L)")
## Warning: Removed 1 rows containing missing values (geom_point).

# Plot for oral
ggplot(data = ex7, aes(x = Time, y = oral.Conc)) +
    geom_point(color = "blue") + 
    scale_y_log10() +
    ggtitle("Plot of oral dose") +
    xlab("Time(hr)") +
    ylab("Plasma Concentration (mg/L)")
## Warning: Removed 2 rows containing missing values (geom_point).

# estimat k of iv adminitered
ex7_iv_model <- lm(data = ex7, formula = log(iv.Conc) ~ Time)
ex7_iv_k <- ex7_iv_model$coefficients[2] %>% as.numeric() %>% abs() 

# Calculate t half-life
ex7_iv_t_hf <- log(2)/ex7_iv_k
  1. t1/2 = 14.61hr-1, k = 0.047