knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(tidyverse)
savictools is a collection of functions designed to make the pharmacometrics workflow faster, simpler, and more intuitive.
cohort()
generates simulation datasets for NONMEM.expwt()
computes expected weight for children under 5.sparse()
detects sparse vs. intensive PK sampling occasions.tad()
computes time after dose.zscores()
computes z-scores for WHO's anthropometric indicators.cr_plot()
visualizes the clinical relevance of covariates.etacorr_cat()
and etacorr_cont()
plot ETA-covariate correlations.pk_plot()
creates PK concentration curves ("spaghetti plots").VPC()
runs the Perl-speaks-Nonmem (PsN) vpc
command from R, and is also a wrapper for xpose::VPC.param_table()
creates nicely formatted tables of parameter estimates for single or multiple models.parse_all_sse()
parses PsN sse
-generated SSE_results.csv files and combines them into dataframes summarizing parameter statistics and error rates.To install the development version from GitHub:
# install.packages("devtools") devtools::install_github("saviclab/savictools")
library(savictools)
cohort()
is used to generate NONMEM-ready datasets for clinical PK trials, either by sampling from real datasets or generating synthetic data.set.seed(12345) pop_example # 1. Sampling 20 individuals, above 10 kg and below 120 cm, with a fixed dose of # 200 mg, observing every 4 hours for one day and dosing at times 0, 5, and 12. # Note that the data has columns called "WT" and "HT". inc <- "WT > 10 & HT < 120" ot <- seq(0, 24, by = 4) dt <- c(0, 5, 12) cohort( pop_example, include = inc, n = 20, obs_times = ot, dose_times = dt, amt = 200 ) # 2. Simulating data. We assume WT and HT are normally distributed random # variables, with means and standard deviations of 16 and 3.4 for WT and 132 # and 13.6 for HT. p1 <- list("WT" = list("rnorm", 16, 3.4), "HT" = list("rnorm", 132, 13.6)) cohort( param = p1, include = inc, n = 20, pop_size = 1000, obs_times = ot, dose_times = dt, amt = 200, original_id = FALSE ) # 3. As in (2), except we now define a dosing function. dose_fun <- function(WT) { ifelse(WT < 16, 150, ifelse(WT < 20, 200, 250)) } cohort( param = p1, include = inc, n = 20, pop_size = 500, obs_times = ot, dose_times = dt, original_id = FALSE, amt = dose_fun ) set.seed(NULL)
expwt()
calculates expected weight based on age and sex in under-5 children, adding a column called EXPWT.expwt(pop_example)
sparse()
automatically detects sparse vs. intensive PK sampling in a dataset.library(ggplot2) pk_example sparse(pk_example, plot = TRUE) sparse(pk_example, plot = TRUE) + facet_wrap("ID", scales = "free_x", )
tad()
computes time after dose.# Deleting and re-calculating TAD tad(pk_example)
zscores()
computes z-scores indicating nutritional status.zscores(pop_example, units = "months")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.