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.
You can install the development version of pmxhelpr from GitHub with:
# install.packages("devtools")
devtools::install_github("ryancrass/pmxhelpr")
Functions in this package use the following naming conventions:
model_mread_load()
wraps mrgsolve::mread_cache()
to read internal package model files returning an mrgmod
object.df_mrgsim_addpred()
wraps mrgsolve::mrgsim()
including mrgsolve::zero_re()
to add population predictions (PRED) to the input data returning a data.frame
.df_mrgsim_replicate()
wraps mrgsolve::mrgsim()
to replicate the input data returning a data.frame
.plot_vpc_exactbins()
wraps vpc::vpc()
to generate a VPC plot using exact time bins returning a ggplot
object.plot_dvtime
returns a ggplot
object with a dependent variable plotted versus timedf_nobsbin
returns a summary data.frame
with counts of the number of missing and non-missing observations per bin.df_pcdv
returns a data.frame
containing the prediction-corrected dependent variable.plot_legend
returns a ggplot
object containing a legend for a VPC plot generated using plot_vpc_exactbins
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 analysis-ready dataset for an example Phase 1 study
glimpse(data_sad)
#Plot data
data_sad
data <-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")
#Read internal mrgsolve model file
model_mread_load("model")
model <-
#Simulated replicates of the dataset using mrgsim
df_mrgsim_replicate(data = data, model = model,replicates = 100,
simout <-output_vars = c(DV = "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
#LLOQ in the dataset is 1 ng/mL
plot_obj_food <- plot_vpc_exactbins(
sim = mutate(simout, FOOD_f = factor(FOOD, levels = c(0,1), labels = c("Fasted", "Fed"))),
strat_vars = "FOOD_f",
pcvpc = TRUE,
loq = 1
) +
scale_y_log10(guide = "axis_logticks")
plot_obj_food
#Add Legend
plot_obj_leg <- plot_legend()
plot_obj_leg
plot_obj_food_wleg <- plot_obj_food + plot_obj_leg + plot_layout(heights = c(2,1))
plot_obj_food_wleg