Outline
Load data
Data Clean
Color
# colored data table
color<- function(data,var,color,l){
datatable(data, options = list(
pageLength = l), escape=FALSE) %>% formatStyle(names(data),
fontSize="80%",
background = styleColorBar(var, color),
backgroundSize = '88% 78%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'left')
}Cmax: the maximum concentration of a drug (usually measured in plasma or serum) after administration, which is a key parameter in pharmacokinetics (PK). It signifies the peak concentration reached by the drug in the bloodstream following administration.
Cmax is at patient level, one Cmax per patient.
AUC: the area under the curve (AUC) is the integral of a function and is used to calculate the total exposure to a drug after administration that represents the total exposure of a drug in the body over time. It is a key parameter in pharmacokinetics (PK) and is used to determine the bioavailability of a drug. AUC provides valuable information about the drug’s absorption, distribution, metabolism, and elimination processes.
PKNCA package is used to calculate AUC.
se <- function(n,v) {
df<- pkb %>% filter(subjid==n, Visit==v)
}
auc1 <- function(df){
auc<-pk.calc.aucint(conc=df$conc,time=df$time,interval=c(0,6))
}plotc<- function(b){
lb <- paste0("AUC for Subjid " , b$subjid[1], " at ", b$Visit[1])
ggplot(b,
aes(x=time,
y=conc,
group=subjid)) +
geom_ribbon(data=b,
aes(ymin=0, ymax=conc),
fill="#d7e1d0", alpha=0.6) +
geom_line() + theme_minimal()+
geom_point(size=4) +
scale_x_continuous(breaks=b$time) +
labs(y = "Plasma Concentration ng/ML", x = "Injection Time (Hours)", title=lb)}T1/2: the time it takes for the concentration of a drug in the bloodstream to decrease by half. It is a key parameter in pharmacokinetics (PK) and is used to determine the rate of elimination of a drug from the body. t-half is calculated by fitting the natural logarithm of concentration by time.
PKNCA package is used to calculate T1/2.
se1 <- function(n,v) {
df<- pk1a %>% filter(subjid==n, Visit==v)
}
th <- function(df) {
PKNCA.options(allow.tmax.in.half.life=TRUE)
thalf<-pk.calc.half.life(conc=df$conc,time=df$time)
}
th1 <- function(df,out) {
PKNCA.options(allow.tmax.in.half.life=TRUE)
thalf<-pk.calc.half.life(conc=df$conc,time=df$time)
out <- data.frame(thalf)
kable(out)
}ploth<- function(bt){
lb <- paste0("Half time for Subjid " , bt$subjid[1], " at ", bt$Visit[1])
ggplot(bt,
aes(x=time,
y=conc,
group=subjid)) +
geom_ribbon(data=bt,
aes(ymin=0, ymax=conc),
fill="#a3bbdb", alpha=0.6) +
geom_line() + theme_minimal()+
geom_point(size=4) +
scale_x_continuous(breaks=bt$time) +
labs(y = "Plasma Concentration ng/ML", x = "Injection Time (Hours)", title=lb)}conc_obj <- PKNCAconc(b, conc~time|subjid)
data_obj <- PKNCAdata(data.conc=conc_obj,
intervals=data.frame(start=0,
end=6,
aucall=TRUE,
auclast=TRUE,
aucinf.pred=TRUE,
aucinf.obs=TRUE))
results_obj <- pk.nca(data_obj)## No dose information provided, calculations requiring dose will return NA.
| subjid | start | end | PPTESTCD | PPORRES | exclude |
|---|---|---|---|---|---|
| 1 | 0 | 6 | auclast | 305.1905570 | NA |
| 1 | 0 | 6 | aucall | 305.1905570 | NA |
| 1 | 0 | 6 | tmax | 1.0000000 | NA |
| 1 | 0 | 6 | tlast | 6.0000000 | NA |
| 1 | 0 | 6 | clast.obs | 43.8000000 | NA |
| 1 | 0 | 6 | lambda.z | 0.0914000 | NA |
| 1 | 0 | 6 | r.squared | 0.9717344 | NA |
| 1 | 0 | 6 | adj.r.squared | 0.9434688 | NA |
| 1 | 0 | 6 | lambda.z.time.first | 1.0000000 | NA |
| 1 | 0 | 6 | lambda.z.n.points | 3.0000000 | NA |
| 1 | 0 | 6 | clast.pred | 43.0186561 | NA |
| 1 | 0 | 6 | half.life | 7.5836634 | NA |
| 1 | 0 | 6 | span.ratio | 0.6593120 | NA |
| 1 | 0 | 6 | aucinf.obs | 784.4025742 | NA |
| 1 | 0 | 6 | aucinf.pred | 775.8539579 | NA |
Reference:
PKNCA :
[https://cran.r-project.org/web/packages/PKNCA/vignettes/v05-auc-calculation-with-PKNCA.html]
[https://cran.r-project.org/web/packages/PKNCA/vignettes/v06-half-life-calculation.html]