PK Exploration with nlmixr dataset

Andrew Stein, Fariba Khanshan, Alison Margolskee

2023-03-22

Overview

This document provides a template for exploring Single or Multiple Ascending Dose PK data.

Load Packages

library(xgxr)
library(ggplot2)
library(dplyr)

# setting ggplot theme
xgx_theme_set()

Load the dataset and assign columns. Take subsets of data that are needed

Multiplying dose by weight to get a mg dosing.

# units of dataset
time_units_dataset <- "hours"
time_units_plot    <- "days"
dose_label         <- "Dose (mg)"
conc_label         <- "Concentration (ug/ml)"  
concnorm_label     <- "Normalized Concentration (ug/ml)/mg"
  
# covariates in the dataset
covariates <- c("WT")
  
# load dataset 
data <- nlmixr_theo_sd
  
# make sure that the necessary columns are assigned
# five columns are required: TIME, LIDV, CMT, DOSE, DOSEREG
data <- data %>%
  mutate(ID = ID) %>%   #ID column
  group_by(ID) %>%
  mutate(TIME = TIME,     #TIME column name 
         NOMTIME = as.numeric(as.character(cut(TIME,
                                  breaks = c(-Inf, 0.1, 0.7, 1.5, 4, 8, 10.5, 15, Inf), 
                                  labels = c( 0, 0.5, 1, 2, 7, 9, 12, 24)))),
         EVID    = EVID,                     # EVENT ID >=1 is dose, 0 otherwise
         CYCLE   = 1,                        # CYCLE of PK data 
         LIDV    = DV,                       # DEPENDENT VARIABLE column name
         CENS    = 0,                        # CENSORING column name
         CMT     = CMT,                      # COMPARTMENT column here (e.g. CMT or YTYPE)
         DOSE    = signif(max(AMT) * WT, 2), # DOSE column here (numeric value)
                                             # convert mg/kg (in dataset) to mg
         DOSEREG = DOSE) %>% # DOSE REGIMEN column here
  ungroup()
  
# convert DOSEREG to factor for proper ordering in the plotting
# add LIDVNORM dose normalized concentration for plotting
data <- data %>%
  arrange(DOSE) %>%
  mutate(LIDVNORM    = LIDV / DOSE,
         DOSEREG     = factor(DOSEREG, levels = unique(DOSEREG)),
         DOSEREG_REV = factor(DOSEREG, levels = rev(unique(DOSEREG))))
                       # define order of treatment factor
  
# for plotting the PK data
data_pk <- filter(data, CMT == 2, TIME > 0)
  
# NCA
NCA <- data %>%
  filter(CMT == 2, NOMTIME > 0, NOMTIME <= 24) %>%
  group_by(ID) %>%
  summarize(AUC_0_24     = caTools::trapz(TIME, LIDV),
            Cmax_0_24    = max(LIDV),
            Ctrough_0_24 = LIDV[length(LIDV)],
            DOSE         = DOSE[1],
            WT           = WT[1]) %>%
  tidyr::gather(PARAM, VALUE, -c(ID, DOSE, WT)) %>%
  mutate(VALUE_NORM = VALUE / DOSE) %>%
  ungroup()

Summary of the data issues and the covariates

check <- xgx_check_data(data,covariates)
#> Warning in xgx_check_data(data, covariates): Setting YTYPE column equal to CMT
#> Warning in xgx_check_data(data, covariates): Setting MDV column equal to as.numeric(EVID!=0)
#> 
#> DATA SUMMARY
#> CONTINUOUS COVARIATES
#> NO CATEGORICAL COVARIATES
#> POSSIBLE DATA ISSUES - FIRST 6 RECORDS
#> The following columns contained missing values
#> :

knitr::kable(check$summary)
Category Description YTYPE Statistic Value
Patients Number of Patients - 12 12
MDV Number of patients with zero PK or PD observations all 0 0
MDV Number of Missing Data Points (MDV==1 and EVID==0) all 0 0
Dose Number of non-zero doses - 12 12
Dose Number of zero doses (AMT==0) - 0 0
Dose Number of patients that never received drug - 0 0
DV Number of Data Points 1 12 12
DV Number of Data Points 2 132 132
DV Number of Data Points per Individual 1 min = 1, median = 1, max = 1 1
DV Number of Data Points per Individual 2 min = 11, median = 11, max = 11 11
DV Number of Data Points with zero value (DV==0) 1 0 0
DV Number of Data Points with zero value (DV==0) 2 9 9
DV Number of Data Points with NA (is.na(DV)) 1 0 0
DV Number of Data Points with NA (is.na(DV)) 2 0 0
DV+TIME Multiple measurements at same time 1 0 0
DV+TIME Multiple measurements at same time 2 0 0
CENS Number of Censored Data Points 1 0 (0%) 0
CENS Number of Censored Data Points 2 0 (0%) 0
All Columns Negative Values (number) - : 0
All Columns Missing Values (number) - : 0
knitr::kable(head(check$data_subset))
Data_Check_Issue ID TIME DV CENS YTYPE
DV == 0 9 0 0 0 2
DV == 0 2 0 0 0 2
DV == 0 3 0 0 0 2
DV == 0 4 0 0 0 2
DV == 0 5 0 0 0 2
DV == 0 6 0 0 0 2
knitr::kable(check$cts_covariates)
Covariate Nmissing min 25th median 75th max
WT 0 54.6 63.575 70.5 74.425 86.4
knitr::kable(check$cat_covariates)

|| || || ||

Provide an overview of the data

Summarize the data in a way that is easy to visualize the general trend of PK over time and between doses. Using summary statistics can be helpful, e.g. Mean +/- SE, or median, 5th & 95th percentiles. Consider either coloring by dose or faceting by dose. Depending on the amount of data one graph may be better than the other.

When looking at summaries of PK over time, there are several things to observe. Note the number of doses and number of time points or sampling schedule. Observe the overall shape of the average profiles. What is the average Cmax per dose? Tmax? Does the elimination phase appear to be parallel across the different doses? Is there separation between the profiles for different doses? Can you make a visual estimate of the number of compartments that would be needed in a PK model?

Concentration over Time, colored by dose, mean +/- 95% CI

glin <- ggplot(data = data_pk, aes(x = NOMTIME,
                                   y = LIDV,
                                   group = DOSE,
                                   color = DOSEREG_REV)) +
  stat_summary() + 
  xgx_scale_x_time_units(time_units_dataset, time_units_plot) +
  labs(y = conc_label, color = "Dose")

glog <- glin + scale_y_log10()
gridExtra::grid.arrange(gridExtra::arrangeGrob(glin, glog, nrow = 1))