Learn R Programming

⚠️There's a newer version (0.11.0) of this package.Take me there.

The PKNCA R Package

The PKNCA R package is designed to perform all noncompartmental analysis (NCA) calculations for pharmacokinetic (PK) data. The package is broadly separated into two parts (calculation and summary) with some additional housekeeping functions.

The primary and secondary goals of the PKNCA package are to 1) only give correct answers to the specific questions being asked and 2) automate as much as possible to simplify the task of the analyst. When automation would leave ambiguity or make a choice that the analyst may have an alternate preference for, it is either not used or is possible to override.

Note that backward compatibility will not be guaranteed until version 1.0. Argument and function changes will continue until then. These will be especially noticable around the inclusion of IV NCA parameters and additional specifications of the dosing including dose amount and route.

Citation

Citation information for the PKNCA package is available with a call to citation(package="PKNCA"). The preferred citation until publication of version 1.0 is below:

Denney W, Duvvuri S and Buckeridge C (2015). "Simple, Automatic Noncompartmental Analysis: The PKNCA R Package." Journal of Pharmacokinetics and Pharmacodynamics, 42(1), pp. 11-107,S65. ISSN 1573-8744, doi: 10.1007/s10928-015-9432-2, <URL: https://github.com/billdenney/pknca>.

Installation

From CRAN

The current stable version of PKNCA is available on CRAN. You can install it and its dependencies using the following command:

install.packages("PKNCA")

From GitHub

To install the development version from GitHub, install the devtools package and then type the following commands:

install.packages("devtools")
install.packages("Rcpp")
library(devtools)
install_github("billdenney/pknca")

Calculating parameters

# Load the package
library(PKNCA)
# Set the business rule options with the PKNCA.options() function
# Load your concentration-time data
myrawconcdata <- read.csv("myconc.csv", stringsAsFactors=FALSE)
# Load your dose data
myrawdosedata <- read.csv("mydose.csv", stringsAsFactors=FALSE)
# Put your concentration data into a PKNCAconc object
myconc <- PKNCAconc(data=myrawconcdata,
                    formula=conc~time|treatment+subject/analyte)
# Put your dose data into a PKNCAdose object
mydose <- PKNCAdose(data=myrawdosedata,
                    formula=dose~time|treatment+subject)
# Combine the two (and automatically determine the intervals of
# interest
mydata <- PKNCAdata(myconc, mydose)
# Compute the NCA parameters
myresults <- pk.nca(mydata)
# Summarize the results
summary(myresults)

More help is available in the function help files, and be sure to look at the PKNCA.options function for many choices to make PKNCA conform to your company's business rules for calculations and summarization.

Feature requests

Please use the github issues page (https://github.com/billdenney/pknca/issues) to make feature requests and bug reports.

Copy Link

Version

Install

install.packages('PKNCA')

Monthly Downloads

3,440

Version

0.9.2

License

AGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Bill Denney

Last Published

February 28th, 2020

Functions in PKNCA (0.9.2)

PKNCA.options.describe

Describe a PKNCA.options option by name.
PKNCA.choose.option

Choose either the value from an option list or the current set value for an option.
PKNCAconc

Create a PKNCAconc object
PKNCAdose

Create a PKNCAdose object
AIC.list

Assess the AIC for all models in a list of models
PKNCAresults

Generate a PKNCAresults object
PKNCA.options

Set default options for PKNCA functions
PKNCA.set.summary

Define how NCA parameters are summarized.
PKNCAdata

Create a PKNCAdata object.
check.interval.specification

Check the formatting of a calculation interval specification data frame.
PKNCA

Compute noncompartmental pharmacokinetics
business.mean

Generate functions to do the named function (e.g. mean) applying the business rules.
check.conc.time

Verify that the concentration and time are valid
findOperator

Find the first occurrence of an operator in a formula and return the left, right, or both sides of the operator.
choose.auc.intervals

Choose intervals to compute AUCs from time and dosing information
clean.conc.blq

Handle BLQ values in the concentration measurements as requested by the user.
adj.r.squared

Calculate the adjusted r-squared value
get.interval.cols

Get the columns that can be used in an interval specification
as.data.frame.PKNCAresults

Extract the parameter results from a PKNCAresults and return them as a data frame.
get.first.model

Get the first model from a list of models
checkProvenance

Check the hash of an object to confirm its provenance.
check.conversion

Check that the conversion to a data type does not change the number of NA values
add.interval.col

Add columns for calculations within PKNCA intervals
check.interval.deps

Take in a single row of an interval specification and return that row updated with any additional calculations that must be done to fulfill all dependencies.
fit_half_life

Perform the half-life fit given the data. The function simply fits the data without any validation. No selection of points or any other components are done.
formula.parseFormula

Convert the parsed formula back into the original
parseFormula

Parse a formula into its component parts.
get.best.model

Extract the best model from a list of models using AIC.list.
formula.PKNCAconc

Extract the formula from a PKNCAconc object.
pk.business

Run any function with a maximum missing fraction of X and 0s possibly counting as missing. The maximum fraction missing comes from PKNCA.options("max.missing").
geomean

Compute the geometric mean, sd, and CV
addProvenance

Add a hash and associated information to enable checking object provenance.
pk.calc.ceoi

Determine the concentration at the end of infusion
exclude_nca

Exclude NCA parameters based on examining the parameter set.
getData.PKNCAdata

Extract all the original data from a PKNCAconc or PKNCAdose object
model.frame.PKNCAconc

Extract the columns used in the formula (in order) from a PKNCAconc or PKNCAdose object.
pk.calc.cav

Calculate the average concentration during an interval.
pk.calc.cmax

Determine maximum observed PK concentration
normalize_exclude

Normalize the exclude column by setting blanks to NA
getData.PKNCAresults

Extract all the original data from a PKNCAconc or PKNCAdose object
pk.calc.c0

Estimate the concentration at dosing time for an IV bolus dose.
getGroups.PKNCAconc

Get the groups (right hand side after the | from a PKNCA object).
pk.calc.auxc

A compute the Area Under the (Moment) Curve
pk.calc.aucpext

Calculate the AUC percent extrapolated
getIndepVar

Get the independent variable (right hand side of the formula) from a PKNCA object.
pk.calc.ctrough

Determine the trough (predose) concentration
pk.calc.cl

Calculate the (observed oral) clearance
pk.calc.tlast

Determine time of last observed concentration above the limit of quantification.
pk.calc.tmax

Determine time of maximum observed PK concentration
pk.tss.monoexponential.individual

A helper function to estimate individual and single outputs for monoexponential time to steady-state.
pk.calc.deg.fluc

Determine the degree of fluctuation
pk.calc.dn

Determine dose normalized NCA parameter
pk.calc.ptr

Determine the peak-to-trough ratio
clean.conc.na

Handle NA values in the concentration measurements as requested by the user.
get.parameter.deps

Get all columns that depend on a parameter
exclude

Exclude data points or results from calculations or summarization.
getAttributeColumn

Retrieve the value of an attribute column.
pk.calc.swing

Determine the PK swing
pk.nca.interval

Compute all PK parameters for a single concentration-time data set
pk.tss.monoexponential.population

A helper function to estimate population and popind outputs for monoexponential time to steady-state.
getColumnValueOrNot

Get the value from a column in a data frame if the value is a column there, otherwise, the value should be a scalar or the length of the data.
find.tau

Find the repeating interval within a vector of doses
setAttributeColumn

Add an attribute to an object where the attribute is added as a name to the names of the object.
setDuration

Set the duration of dosing or measurement
pk.tss

Compute the time to steady-state (tss)
getData.PKNCAconc

Extract all the original data from a PKNCAconc or PKNCAdose object
signifString

Round a value to a defined number of significant digits printing out trailing zeros, if applicable.
pk.calc.fe

Calculate fraction excreted (typically in urine or feces)
pk.calc.f

Calculate the absolute (or relative) bioavailability
pk.calc.vd

Calculate the volume of distribution (Vd) or observed volume of distribution (Vd/F)
interp.extrap.conc

Interpolate concentrations between measurements or extrapolate concentrations after the last measurement.
time_calc

Times relative to an event (typically dosing)
summary.PKNCAresults

Summarize PKNCA results
sort.interval.cols

Sort the interval columns by dependencies.
superposition

Compute noncompartmental superposition for repeated dosing
merge.splitlist

Merge two or more lists with a data.frame 'groupid' attribute defining the matching.
pk.calc.clr

Calculate renal clearance
pk.calc.mrt.md

Calculate the mean residence time (MRT) for multiple-dose data with nonlinear kinetics.
pk.calc.thalf.eff

Calculate the effective half-life
pk.calc.clast.obs

Determine the last observed concentration above the limit of quantification (LOQ).
pk.calc.mrt

Calculate the mean residence time (MRT) for single-dose data or linear multiple-dose data.
pk.calc.vss

Calculate the steady-state volume of distribution (Vss)
pk.calc.tlag

Determine the observed lag time (time before the first concentration above the limit of quantification or above the first concentration in the interval)
tss.monoexponential.generate.formula

A helper function to generate the formula and starting values for the parameters in monoexponential models.
pk.tss.stepwise.linear

Compute the time to steady state using stepwise test of linear trend
print.provenance

Print the summary of a provenance object
reexports

Objects exported from other packages
print.PKNCAdata

Print a PKNCAdata object
print.summary_PKNCAresults

Print the results summary
pk.calc.ae

Calculate amount excreted (typically in urine or feces)
pk.calc.half.life

Compute the half-life and associated parameters
pk.calc.aucint

Calculate the AUC over an interval with interpolation and/or extrapolation of concentrations for the beginning and end of the interval.
getDataName.PKNCAconc

Get the name of the element containing the data for the current object.
getDepVar

Get the dependent variable (left hand side of the formula) from a PKNCA object.
print.PKNCAconc

Print and/or summarize a PKNCAconc or PKNCAdose object.
setExcludeColumn

Set the exclude parameter on an object
setRoute

Set the dosing route
pk.calc.vz

Calculate the terminal volume of distribution (Vz)
pk.calc.kel

Calculate the elimination rate (Kel)
pk.nca

Compute NCA parameters for each interval for each subject.
pk.tss.monoexponential

Compute the time to steady state using nonlinear, mixed-effects modeling of trough concentrations.
roundString

Round a value to a defined number of digits printing out trailing zeros, if applicable.
roundingSummarize

During the summarization of PKNCAresults, do the rounding of values based on the instructions given.
pk.tss.data.prep

Clean up the time to steady-state parameters and return a data frame for use by the tss calculators.
split.PKNCAconc

Divide into groups
summary.PKNCAdata

Summarize a PKNCAdata object showing important details about the concentration, dosing, and interval information.