Package: invivoPKfit 2.0.2

invivoPKfit: Fits Toxicokinetic Models to In Vivo PK Data Sets

Takes in vivo toxicokinetic concentration-time data and fits parameters of 1-compartment and 2-compartment models for each chemical. These methods are described in detail in "Informatics for Toxicokinetics" (2025).

Authors:John Wambaugh [aut, cre], Caroline Ring [aut], Gilberto Padilla Mercado [aut], Chris Cook [aut]

invivoPKfit_2.0.2.tar.gz
invivoPKfit_2.0.2.zip(r-4.7)invivoPKfit_2.0.2.zip(r-4.6)invivoPKfit_2.0.2.zip(r-4.5)
invivoPKfit_2.0.2.tgz(r-4.6-any)invivoPKfit_2.0.2.tgz(r-4.5-any)
invivoPKfit_2.0.2.tar.gz(r-4.7-any)invivoPKfit_2.0.2.tar.gz(r-4.6-any)
invivoPKfit_2.0.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
invivoPKfit/json (API)

# Install 'invivoPKfit' in R:
install.packages('invivoPKfit', repos = c('https://jfwambaugh.r-universe.dev', 'https://cloud.r-project.org'))
Datasets:

On CRAN:

Conda:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

3.18 score 6 scripts 220 downloads 83 exports 55 dependencies

Last updated from:5d0fcf6da6. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK372
source / vignettesOK276
linux-release-x86_64OK357
macos-release-arm64OK310
macos-oldrel-arm64OK276
windows-develOK361
windows-releaseOK353
windows-oldrelOK324
wasm-releaseOK136

Exports:AAFEadd_pkadjust_model_nameAFEauc_1compauc_2compauc_flatauc_httk_gas_pbtkauto_unitscalc_ncacheck_required_statuscoef_sdcompare_modelsconvert_summary_to_log10convert_timecp_1compcp_2compcp_2comp_dtcp_flatcp_httk_gas_pbtkdata_summarydlnorm_summarydnorm_summarydo_data_infodo_fitdo_prefitdo_preprocesseval_tkstatsfacet_datafit_sigma.pkfold_errorget_dataget_data_groupget_data_infoget_data_originalget_data_sigma_groupget_data_summaryget_error_groupget_fitget_hessianget_mappingget_ncaget_nca_groupget_params_httk_gas_pbtkget_prefitget_scale_concget_scale_timeget_settings_optimxget_settings_preprocessget_stat_modelget_statusget_tkstatsget_winning_modelis.pkis.pk_facetedis.pk_scalesis.pkprotolog_likelihoodmappingncapkpk_addpk_modelpk_subtractrecalculate_httk_pbtk_paramsrmsersqscale_concset_params_optimizeset_params_startssettings_preprocessstat_error_modelstat_loq_groupstat_nca_groupstat_sd_groupsubtract_pktkstats_1comptkstats_2comptkstats_flattkstats_httk_gas_pbtktoggle_clearance_modetransformed_params_2comptwofold_test

Dependencies:clicpp11data.tableDBIdeSolvedplyrexpmfarvergenericsggplot2gluegtablehttkisobandlabelinglatticelifecyclemagrittrMASSMatrixminqamiraimitoolsmsmmvtnormnanonextnloptrnumDerivoptimxpillarPKpkgconfigpracmapurrrR6rbibutilsRColorBrewerRcppRcppArmadilloRdpackrlangS7scalesstringistringrsurveysurvivaltibbletidyrtidyselecttruncnormutf8vctrsviridisLitewithr

Manuscript Figures and Tables (2024, submitted)
Overview | Setup | Pulling data from CvTdb | Minimal PK object | Running all possible fitting options | Characterizing the data | Number of data groups with both blood and plasma data available | Number of data groups where time scaling could occur | How many experiments (Chemical, Species, Reference, Route, Media) were flagged for potential dose dependence? | Evaluating time and concentration ranges | Evaluating data variability | Figure 3 | Supplemental Figure 3: Histogram of data variability by time | Evaluating fitting options | Winning model tally | RMSLE for Cmax and AUC (with some tallys for extreme values) | AUC_inf and Cmax comparison | Goodness of fit metrics | Get all predictions | Factor of two model error | Evaluate the various GOF metrics | Rank fitting options | Supplemental Table 2: Save evaluation results | Plots for evaluation of fitting options | Goodness-of-fit metrics Rsq and RMSLE across fitting options | Cmax RMSLE vs. AUC RMSLE across fitting options | Analysis Plots and Tables for Best Set of Fitting Options | Supp Figure 7: invivoPKfit model performance | Figure 4 and Supplemental Figures 4 & 5: Model performance vs Data Variability | Figure 5: Multiple goodness-of-fit metrics validate model performance | Figure 7: Examples fits for chemicals with R-squared and within 2-fold | Supp. Fig 8: plots of the five data groups that were best fit by the null model | Figure 6: Comparing derived TK stats with human TK stats from Lombardo et al. | Supp. Fig. 9: Fgutabs comparison with literature values compiled by Musther et al. (2014) | Supp. Fig. 10: Parallelization decreases runtime of invivoPKfit | Summary fit data for all fitting options, all models, all data groups | Individual study level analysis | All plots for best set of fitting options | Print sessionInfo()

Last update: 2025-08-26
Started: 2025-01-09

User Guide
Introduction | The model fitting workflow | Select data to be fit | Initialize a pk object | Step 1: Pre-processing data | Step 2: Data information | Step 3: Pre-fitting | Step 4: Model fitting | Fast-forward to model fitting | Post-fitting: Getting information about the fitted models | Coefficients, residuals, and predictions | Plots | Model evaluation metrics | Data | Toxicokinetic statistics | Winning model | Anatomy of a pk object | Original data | Variable mapping | Expressions in the aes() mapping specification | Current status | Data grouping | Settings for data pre-processing | routes_keep | media_keep | ratio_conc_dose | impute_loq, loq_group and calc_loq_factor | impute_sd, sd_group | Data information settings | Optimizer settings | Data transformations (scalings) | Concentration transformations (scalings) | dose_norm | log10_trans | my_pk$scales$time | Models to be fitted | Error model to apply during fitting | "Hierarchical" error model | "Pooled" analysis | "Separate" analysis | Providing new instructions for a pk object | Checking the current instructions for a pk object | Check original data | Check mapping | Check status | Check data grouping | Check settings_preprocess | Check nca_group | Check settings_optimx | Check scale_conc | Check scale_time | Check stat_model | Check stat_error_model | Replacing instructions with new ones | What happens to a pk object as you go through the steps of model fitting workflow | Initialization | Pre-processing data | Data summary info | Pre-fitting | Fitting | Keeping track of workflow status as you change instructions | A few worked examples | Compare fits made using different error models | How to add a new PK model to invivopkfit | Model function requirements | conc_fun requirements | auc_fun requirements | params_fun requirements | tkstats_fun requirements | Simplified model modification interface | Caveats

Last update: 2025-08-26
Started: 2025-01-09

Wambaugh et al. (2018): Estimating TK Parameters from In Vivo Data
Initialized the Random Number Generator: | Do the noncompartment model fit | Do the 2-compartment model fit | Plot the 2-compartment concentration vs. time | Do the 1-compartment model fit | Plot one compartment concentration vs. time | Output the dataset analyzed:

Last update: 2025-01-09
Started: 2025-01-09

Readme and manuals

Help Manual

Help pageTopics
Subtract a pkproto object from a pk object-.pk
Add a `pkproto` object to a `pk` object+.pk
AAFE()AAFE
Default method for AAFE()AAFE.default
Calculate absolute average fold error (AAFE)AAFE.pk
Add various `pkproto` objects to a `pk` objectadd_pk
Sets the `name` element for models to the `pk_model` object name in the environmentadjust_model_name
AFE()AFE
Default method for AFE()AFE.default
Calculate average fold errorAFE.pk
Akaike information criterionAIC.pk
Analytic AUC for 1-compartment modelauc_1comp
Analytical AUC for the 2-compartment modelauc_2comp
AUC for flat modelauc_flat
Calculates AUC for `httk`'s `gas_pbtk` PBPK modelauc_httk_gas_pbtk
Automatically select new time unitsauto_units
Bayesian information criterionBIC.pk
Calculate Hessiancalc_hessian
Non-compartmental analysiscalc_nca
Calculate RMSE (root mean squared error)calc_rmse
Calculate r-squared for observed vs. predicted valuescalc_rsq
Calculate parameter SDscalc_sds_alerts
Checking data, error, and summary group hierarchical structurecheck_group_hierarchy
Check methodscheck_method
Check modelscheck_model
Check new datacheck_newdata
Check 1-compartment model parameterscheck_params_1comp
Check 2-compartment model parameterscheck_params_2comp
Check flat model parameterscheck_params_flat
Check required statuscheck_required_status
Default method for checking required statuscheck_required_status.default
Check required statuscheck_required_status.pk
Coefficient standard deviationscoef_sd
Coefficient standard deviation defaultcoef_sd.default
Get coefficient standard deviationscoef_sd.pk
Get coefficientscoef.pk
Combined standard deviationcombined_sd
Model comparisoncompare_models
Default method for compare_models()compare_models.default
Model comparison for [pk()] objectscompare_models.pk
Get concentration scalingsconc_scale_use
Convert sample mean and SD to log10-scaleconvert_summary_to_log10
Helper function to convert time unitsconvert_time
Analytical 1-compartment modelcp_1comp
Analytical 2-compartment modelcp_2comp
Time derivative of analytical 2-compartment modelcp_2comp_dt
Flat modelcp_flat
Calculates plasma concentration for `httk`'s `gas_pbtk` modelcp_httk_gas_pbtk
CvTdb datacvt
CvTdb data for invivoPKfit 2.0.0 release (old)cvt_2.0.0
CvTdb download datecvt_date
SQL query result (current)cvtdb_original
data_summary()data_summary
Default method for data_summary()data_summary.default
Data summary for a `pk` objectdata_summary.pk
Log-normal distribution density function for summary datadlnorm_summary
Normal distribution density function for summary datadnorm_summary
do_data_info genericdo_data_info
do_data_info default methoddo_data_info.default
calculate summary data infodo_data_info.pk
Fittingdo_fit
do_fit default methoddo_fit.default
Do fittingdo_fit.pk
Prefittingdo_prefit
do_prefit default methoddo_prefit.default
Do pre-fittingdo_prefit.pk
Preprocess data genericdo_preprocess
do_preprocess default methoddo_preprocess.default
Do pre-processingdo_preprocess.pk
eval_tkstats()eval_tkstats
Default method for eval_tkstats()eval_tkstats.default
Evaluate TK statisticseval_tkstats.pk
Facet a PK fitfacet_data
Fill parameters for 1-compartment modelfill_params_1comp
Fill parameters for 2-compartment modelfill_params_2comp
Fill parameters for flat modelfill_params_flat
Fit a single group of datafit_group
Hyperparameter fittingfit_sigma.pk
Fold errorfold_error
fold_error default methodfold_error.default
Fold errorsfold_error.pk
get_data()get_data
get_data_group()get_data_group
Default method for get_data_group()get_data_group.default
Get data groupingget_data_group.pk
get_data_info()get_data_info
Default method for get_data_info()get_data_info.default
Get data_infoget_data_info.pk
get_data_original()get_data_original
Default method for get_data_original()get_data_original.default
Get data_originalget_data_original.pk
get_data_sigma_group()get_data_sigma_group
Default method for get_data_sigma_group()get_data_sigma_group.default
Get data_sigma_groupget_data_sigma_group.pk
get_data_summary()get_data_summary
Default method for get_data_summary()get_data_summary.default
Default method for get_data()get_data.default
Get dataget_data.pk
Get an elbow pointget_elbow
get_error_group()get_error_group
Default method for get_error_group()get_error_group.default
Get error groupget_error_group.pk
get_fit()get_fit
Default method for get_fit()get_fit.default
Get fits from a `pk` objectget_fit.pk
get_hessian()get_hessian
Default method for get_hessian()get_hessian.default
Get Hessian matrixesget_hessian.pk
get_mapping()get_mapping
Default method for get_mapping()get_mapping.default
Get mappingget_mapping.pk
get_nca()get_nca
get_nca_group()get_nca_group
Default method for get_nca_group()get_nca_group.default
Get nca_groupget_nca_group.pk
Default method for get_nca()get_nca.default
Get NCAget_nca.pk
Get parameters for 1-compartment modelget_params_1comp
Get parameters for 2-compartment modelget_params_2comp
Get parameters to be optimized for flat modelget_params_flat
Get parameters to fit `httk`'s `gas_pbtk` PBPK modelget_params_httk_gas_pbtk
Find the peak of a data seriesget_peak
get_prefit()get_prefit
Default method for get_prefit()get_prefit.default
Get prefitget_prefit.pk
get_scale_conc()get_scale_conc
Default method for get_scale_conc()get_scale_conc.default
Get scale_concget_scale_conc.pk
get_scale_time()get_scale_time
Default method for get_scale_time()get_scale_time.default
Get scale_timeget_scale_time.pk
get_settings_optimx()get_settings_optimx
Default method for get_settings_optimx()get_settings_optimx.default
Get settings_optimxget_settings_optimx.pk
get_settings_preprocess()get_settings_preprocess
Default method for get_settings_preprocess()get_settings_preprocess.default
Get settings_preprocessget_settings_preprocess.pk
Get starting values for 1-compartment modelget_starts_1comp
Get starting values for 2-compartment modelget_starts_2comp
Get starting values for flat modelget_starts_flat
Get starting values for httk `gas_pbtk` model with specific clearanceget_starts_httk_gas_pbtk
get_stat_model()get_stat_model
Default method for get_stat_model()get_stat_model.default
Get stat_modelget_stat_model.pk
Get statusget_status
Default method for getting statusget_status.default
Check status of a `pk` objectget_status.pk
Get TK statsget_tkstats
Default method for get_tkstats()get_tkstats.default
Get TK statsget_tkstats.pk
get_winning_model()get_winning_model
Default method for get_winning_model()get_winning_model.default
Get winning modelget_winning_model.pk
Inverse diagonal, method 1hess_sd1
Inverse diagonal, method 2hess_sd2
Ignore unused importsignore_unused_imports
Check whether an object is of class `pk`is.pk
Check whether an object is of class `pk_faceted`is.pk_faceted
Checks whether object is of class `pk_model`is.pk_model
Is an object class `pk_scales`?is.pk_scales
Is an object pkproto?is.pkproto
Log-likelihoodlog_likelihood
Log-likelihoodlogLik.pk
New mappingmapping
Log10-scaled midpointmidpt_log10
1-compartment modelmodel_1comp
2-compartment modelmodel_2comp
Flat modelmodel_flat
Gas pbtk `httk` modelmodel_httk_gas_pbtk
nca()nca
Default method for nca()nca.default
NCA for a `pk` objectnca.pk
Create a new `pk` objectpk
Add a `pkproto` object to a `pk` objectpk_add
Add pkproto object default methodpk_add.default
Add facet_data()pk_add.pk_facet_data
Add loq_grouppk_add.pk_loq_group
Add a `pk_nca_group` object.pk_add.pk_nca_group
Add a `pk_scales` object to a `pk` object.pk_add.pk_scales
Add sd_grouppk_add.pk_sd_group
Add a `pk_settings_optimx` object.pk_add.pk_settings_optimx
Add a `pk_settings_preprocess` object.pk_add.pk_settings_preprocess
Add a `pk_stat_error_model` object.pk_add.pk_stat_error_model
Add a `pk_stat_model` object.pk_add.pk_stat_model
Add an `uneval` objectpk_add.uneval
Create a new `pk_model` objectpk_model
Subtract a `pkproto` object from a `pk` objectpk_subtract
Subtract pkproto object default methodpk_subtract.default
Subtract a `pk_stat_model` object.pk_subtract.pk_stat_model
Toxicokinetic data from the "Concentration vs. Time Database"pkdataset_nheerlcleaned
Plot a [pk()] object.plot.pk
Creates a [cli::cli_fmt()] output for the pattern "name(x), length = "post_name_value
Get predictionspredict.pk
Print a user-friendly version of a `pk` objectprint.pk
Creating a simple test CvT datasetpseudo_cvt
Recalculating parameters for `httk`'s pbtk or gas_pbtk modelrecalculate_httk_pbtk_params
Convert invivoPKfit output table names to the CvTdb namesrename2_cvt
Get residualsresiduals.pk
Root mean squared error (RMSE)rmse
Root mean squared error (RMSE) default methodrmse.default
Root mean squared errorrmse.pk
Helper function for calculating percentages of count data, by rowrowwise_calc_percentages
rsq()rsq
Default method for rsq()rsq.default
Calculate R-squared for observed vs. predicted valuesrsq.pk
Scale concentrationsscale_conc
Scale timesscale_time
Set model parameters to optimizeset_params_optimize
Set model parameter startsset_params_starts
`optimx` optimizer settingssettings_optimx
Data preprocessing settingssettings_preprocess
Error modelstat_error_model
LOQ Groupstat_loq_group
Add PK model(s) to be fittedstat_model
NCA groupstat_nca_group
SD Groupstat_sd_group
Status ID for data summary infostatus_data_info
Status ID for fittingstatus_fit
Status ID for initializationstatus_init
Status ID for pre-fittingstatus_prefit
Status ID for preprocessingstatus_preprocess
Subtract various `pkproto` objects from a `pk` objectsubtract_pk
Print summary of a `pk` objectsummary.pk
Time conversion tabletime_conversions
Allowable time unitstime_units
Toxicokinetic statistics for 1-compartment modeltkstats_1comp
Toxicokinetic statistics for 1-compartment modeltkstats_2comp
TK stats for flat modeltkstats_flat
TK stats for gas_pbtk model fit with inivivoPKfittkstats_httk_gas_pbtk
Switch between model parameters to optimizetoggle_clearance_mode
Transformed parameters for 2-compartment modeltransformed_params_2comp
twofold_test()twofold_test
Default method for twofold_test()twofold_test.default
Evaluate whether data and predictions are within two-fold of mean or concentration, respectivelytwofold_test.pk