The goal of pmxhelpr is to make pharmacometrics workflows more standardized, efficient, and reproducible. This package provides helper and wrapper functions for common steps in the pharmacometrics analysis workflow, such as exploratory data analysis, model development, model evaluation, and model application.
Installation
You can install the development version of pmxhelpr from GitHub with:
# install.packages("devtools")
devtools::install_github("ryancrass/pmxhelpr")Function Naming Conventions
Functions in this package use the following naming conventions:
- Wrapper functions: ReturnObject_WrappedFunction_Purpose
-
model_mread_load()wrapsmrgsolve::mread_cache()to read internal package model files returning anmrgmodobject. -
df_mrgsim_addpred()wrapsmrgsolve::mrgsim()includingmrgsolve::zero_re()to add population predictions (PRED) to the input data returning adata.frame. -
df_mrgsim_replicate()wrapsmrgsolve::mrgsim()to replicate the input data returning adata.frame. -
plot_vpc_exactbins()wrapsvpc::vpc()to generate a VPC plot using exact time bins returning aggplotobject.
-
- Helper functions: ReturnObject_Purpose
-
plot_dvtimereturns aggplotobject with a dependent variable plotted versus time -
plot_dosepropreturns aggplotobject with log-log regression of exposure metrics versus dose -
df_dosepropreturns adata.framecontaining parameters from a log-log regression of exposure metrics versus dose -
plot_popgofreturns aggplotobject with observed, population-predicted, and individual-predicted values plotted versus time -
df_nobsbinreturns a summarydata.framewith counts of the number of missing and non-missing observations per bin. -
df_pcdvreturns adata.framecontaining the prediction-corrected dependent variable. -
plot_vpclegendreturns aggplotobject containing a legend for a VPC plot generated usingplot_vpc_exactbins
-
Example Exploratory Data Analysis Workflow
This is a basic example which illustrates a simple exploratory data analysis workflow using pmxhelpr:
library(pmxhelpr)
library(dplyr)
library(ggplot2)
library(mrgsolve)
library(vpc)
library(patchwork)
library(withr)
#Read internal analysis-ready dataset for an example Phase 1 study
glimpse(data_sad)
#Plot data
data <- data_sad %>%
mutate(Dose = paste(DOSE, "mg"),
Dose_f = factor(Dose, levels = c("10 mg", "50 mg", "100 mg", "200 mg", "400 mg")))
plot_dvtime(data = data, dv_var = c(DV = "ODV"), cent = "median", col_var = "Dose_f",
ylab = "Concentration (ng/mL)", timeu = "hours")
#Assess dose proportionality in the fasted state
glimpse(data_sad_nca)
data_sad_nca_part1 <- filter(data_sad_nca, PART == "Part 1-SAD")
#Tabulated dose-proportionality
table <- df_doseprop(data_sad_nca, metrics = c("aucinf.obs", "cmax"))
table
#Visualize dose-proportionality
plot_doseprop(data_sad_nca_part1, metrics = c("aucinf.obs", "cmax"))Example Visual Exploratory Data Analysis Workflow
This is a basic example which illustrates a simple VPC workflow using pmxhelpr:
library(pmxhelpr)
library(dplyr)
library(ggplot2)
library(mrgsolve)
library(vpc)
library(patchwork)
library(withr)
#Read internal mrgsolve model file
model <- model_mread_load("model")
#Simulated replicates of the dataset using mrgsim
simout <- df_mrgsim_replicate(data = data, model = model,replicates = 100,
dv_var = "ODV",
num_vars = c("CMT", "LLOQ", "EVID", "MDV", "WTBL", "FOOD"),
char_vars = c("USUBJID", "PART", "Dose_f"))
glimpse(simout)
#Plot output in a Prediction-corrected Visual Predictive Check (VPC)
#Exact nominal time bins present in data_sad ("NTIME") are used to plot summary statistics
#Actual time ("TIME") is used to plot observed data points, which are also prediction-corrected if pcvpc=TRUE
plot_obj_food <- plot_vpc_exactbins(
sim = mutate(simout, FOOD_f = factor(FOOD, levels = c(0,1), labels = c("Fasted", "Fed"))),
strat_var = "FOOD_f",
pcvpc = TRUE
) +
scale_y_log10(guide = "axis_logticks")
plot_obj_food
#Add Legend
plot_obj_leg <- plot_vpclegend()
plot_obj_leg
plot_obj_food_wleg <- plot_obj_food + plot_obj_leg + plot_layout(heights = c(2,1))
plot_obj_food_wleg