Run a non-compartmental analysis
run_nca.RdThis function runs an NCA on a pre-parsed dataset. The NCA will be performed
using the PKNCA package. The NCA output object will be saved to an
rds file if path is specified.
Usage
run_nca(
data,
dose_data = NULL,
specification = "default",
dictionary = NULL,
settings = NULL,
blq = "<",
groups = NULL,
include_cols = NULL,
intervals = data.frame(start = 0, end = Inf),
partial_auc = NULL,
exclude_points = NULL,
exclude_subjects = NULL,
exclude_lambda_z = NULL,
include_lambda_z = NULL,
units = NULL,
conversions = NULL,
sequence_from = NULL,
add_auctau = TRUE,
post = list(accumulation = list(parameters = c("auctau", "cmax"))),
format = c("wide", "long"),
no_dots = TRUE,
path = NULL,
check_grouping = FALSE,
verbose = FALSE,
...
)Arguments
- data
dataset in pre-parse format, preferrably created using
create_nca_data(). Can also be a NONMEM-style dataset with EVID=0|1 column indicating PK an dosing data.- dose_data
optional, a data.frame with all dosing info. Useful for multi-dose NCAs. Alternative to specifying a NONMEM-style datasett to
data.- specification
use specific options for the NCA and for mapping of input / output data.
- dictionary
abridged data dictionary for the input dataset, specified as list object. Requires at least entries for
subject_id,time,conc,dose. Optional entries are:visit,route, andduration.routeshould be a column in the dose data with the route of administration (e.g. "IV", "intravenous", "oral"); intravenous routes are mapped to PKNCA's "intravascular", all others to "extravascular".durationshould be a column with the dose duration (0 for bolus). Doses with an intravascular route and zero duration are treated as IV bolus (see Imputation below). If required entries are specified only partially, then default values (i.e. CDISC) nomenclature will be imputed for missing identifiers.- settings
list of settings for NCA. Provided setting names can either be settings recognized directly by
pknca, or settings that are included in the map provided bynca_settings_map()(which are then mapped topkncasetting names). In addition to standard PKNCA settings, the following settings are handled internally and not passed to PKNCA:min.hl.time(orminHalfLifeTime): minimum time required for a data point to be eligible for the lambda-z (terminal slope) calculation. Any data points with time < this value are excluded from the lambda-z fit (but remain in the analysis for other parameters such as Cmax and AUClast). This is implemented by settingexclude_lambda_zflags internally.
- blq
optional, string to match in concentration data, e.g. "<" or "BLQ>. If
conccolumn in the data ischaracterclass, then ifblqis not NULL, it will detect any values that match this string and set those values to zero. If NULL, orconcdata is numeric, the data will be used as-is.- groups
optional grouping variable, e.g.
ACTARM.- include_cols
Optional. Character vector of column names in
datathat should be merged in with NCA results (including only a single value for each row). Merge will happen by subject ID, any supplied groupings, andnca_starttime.- intervals
specify time intervals for NCA calculations. The passed argument should be a data.frame, with at least the
startandendtime for each row that specifies the interval.Infis allowed to specify the end of the interval. Example:The
run_nca()function will compute all parameters that are specified insettings()or in the default settings. Animputecolumn can be added to specify PKNCA imputation methods for the concentration at the interval start, which overrides the default imputation (see Imputation below).- partial_auc
a data.frame containing at least the
startandendtime for each row that specifies the start- and endtime for the partial AUC calculation. The partial AUC is computed as PKNCA'saucint.last.dose(aucint.lastwhen no dose data is available), which interpolates the concentration to thestartandendof the interval. Any other parameters specified in the data.frame as column will also be calculated, e.g.cmax=TRUE. Currently, only a single row can be supplied as argument. For multi-dose data, PKNCA selects the intervals from the dosing schedule and the partial AUC is not computed (with a warning); usegroupsto analyze each dosing occasion separately.- exclude_points
list of points to exclude for entire NCA analysis, based on name(s) in the list that should match column name in the input dataset. E.g.
list("sample_id" = c("12345", "23456")). This could similarly be used to exclude entire subjects, e.g.list("subject_id = c("103, "105")- exclude_subjects
optional, vector of subjects to exclude from NCA
- exclude_lambda_z
list of points to exclude but exclusions are only for the calculation of lambda-z and downstream parameters (halflife, CL, V, AUCinf etc) but not summarization parameters like Cmax, Tmax, etc. List with similar structure as
exclude_points.- include_lambda_z
list of points to include for the calculation of lambda-z and downstream parameters (halflife, CL, V, AUCinf etc) but not summarization parameters like Cmax, Tmax, etc. List with similar structure as
exclude_points. Please note that for any subject and interval whereinclude_lambda_zare specified, PKNCA will not run the automated curve-stripping procedure and theexclude_lambda_zargument (if specified) will be ignored for that subject and AUC interval.- units
optional units specification, passed to
PKNCA::PKNCAdata(). Either a named list with elementsconcu,timeu,doseu, and/oramountu, which are forwarded toPKNCA::pknca_units_table()internally; or a pre-built data frame fromPKNCA::pknca_units_table(). When provided, aunitsattribute containing a per-parameter units table is attached to the returned data frame.To automatically simplify derived units (e.g. V in
L, CL inL/h), includeconcu_prefand/ordoseu_prefin the list — these are forwarded toPKNCA::pknca_units_table()and use theunitsR package to compute conversion factors automatically. For example:units = list( concu = "ng/mL", timeu = "h", doseu = "mg", concu_pref = "mg/L" # makes V = mg/(mg/L) = L, CL = L/h )- conversions
optional manual unit conversion table — a data.frame with columns
PPORRESU(original unit),PPSTRESU(preferred unit), andconversion_factor(multiply PPORRESU value to obtain PPSTRESU value), as accepted byPKNCA::pknca_units_table(conversions = ...). This is an alternative toconcu_pref/doseu_prefthat does not require theunitsR package. Only used whenunitsis a named list (not a pre-built data.frame). See the Unit strings and conversions section for format details.- sequence_from
optional. Argument should specify the column name that indicates the treatment e.g. for food-effect cross-over trials. It will then add sequence group and sequence description columns to the output data.
- add_auctau
compute AUCtau whenever relevant? TRUE (default) / FALSE. For multi-dose PK data, this will add the parameter
auc_tauto the NCA output data as the AUC for each interval with a finite end. If a concentration was measured exactly at the end of the interval, this is the AUClast for the interval. Otherwise (e.g. when the sample at the end of the interval was drawn late), it is PKNCA'saucint.last.dose(aucint.lastwithout dose data), which interpolates the concentration to the end of the interval. See the AUCtau and partial AUC section for limitations.- post
named list of lists, indicating which hard-coded post-processing steps to include, and options for each step. Possible post-processing steps include:
accumulation: if NCA calculated for multiple non-overlapping intervals, will add accumulation ratios for the parameters listed in theparametersargument to the NCA output table for each interval.
Other options may be added in future. Default is:
list("accumulation" = list("parameters" = c("auclast", "cmax"))).- format
output as table in wide or long format.
- no_dots
if
TRUE(default) will replace any dots in parameter names (e.g.aucinf.obs) with underscores (aucinf_obs).- path
path to file to store output object from PKNCA as RDS (optional)
- check_grouping
check whether the grouping specified in
groupsis likely to be correct for NCA, and is not creating groups that are too small for NCA to be able to calculate half-life and other parameters. Seecheck_nca_grouping()for details.- verbose
verbose output?
- ...
parameters passed to `PKNCA::pk.nca()“ function.
Details
There are four possible types of input datasets that can be used to run the NCA:
Using a separate data.frame for PK data (
data) and dose data (dose_data), with each PK or dosing event a row in the respective datasedt. Can be used for both single and multi-dose data.Using a single data.frame for PK and dose data (
data), with event type separated using an evid column (specified indictionary). PK data rows should be set toevid=0, and doses toevid=1. This is essentially a NONMEM-style dataset. Rows with otherevidvalues will be ignored. Can be used for both single and multi-dose data, the dosing occasions will be determined from the dosing events. If anevidcolumn is present indata, it will not attempt to use approach 3.Using a single data.frame (
data) with PK data as rows, and a column for dose (with colum name specified indictionary). Adose_datadata.frame will be constructed from the dose column. Can only be used for single-dose data, unlessgroupsare used to separate the dosing occasions.Using a single data.frame (
data) with PK data as rows, but no dosing info in the data. NCA can still compute AUC and Cmax etc, but parameters that require the dose such as CL, V, etc will be returned as NA. Can only be used for single dose, unlessgroupsare used to separate the dosing occasions.
Imputation
Unless an impute column is specified in intervals, the concentration at
the start of each NCA interval is handled as follows:
An observed concentration at the interval start (e.g. a pre-dose trough at the start of a dosing interval, or an observed C0) is always used and never overwritten.
Otherwise, for IV bolus doses, C0 is back-extrapolated using log-linear regression of the first two concentrations after the dose.
Otherwise, the last pre-dose concentration is used if it was taken within 5% of the interval length before the interval start.
Otherwise, a concentration of 0 is imputed.
See PKNCA_impute_method_start_obs_predose_conc0() and
PKNCA_impute_method_start_obs_c0_logslope().
AUCtau and partial AUC
auclast only integrates up to the last sample at or before the end of an
interval, so it is biased low when the sample at the end of the interval
was drawn late. Partial AUC and AUCtau therefore use PKNCA's
aucint.last.dose when needed (see partial_auc and add_auctau). Known
limitations, following PKNCA's behavior:
When there is no sample to interpolate the end of the interval from (the end is after the last measurable sample, or at the time of a next dose without a sample at that time), PKNCA extrapolates the concentration at the end as zero, so the AUC is still underestimated.
aucint.*does not use the start-of-interval imputation (see Imputation), e.g. C0 back-extrapolation for an IV bolus.For multi-dose data, PKNCA only selects an interval between two doses when concentrations were measured exactly at both dose times, and the interval after the last dose when a concentration was measured exactly at the last dose time + tau. If no interval can be selected for any subject,
run_nca()stops with an error. Partial AUC is not computed for multi-dose data.
Unit strings and conversions
Unit string format
The concu, timeu, doseu, and amountu fields in the units list are
free-form label strings. PKNCA passes them through as-is to build composite
unit labels for each NCA parameter (e.g. AUC = timeu*concu, V =
doseu/(concu), CL = doseu/(timeu*concu)). There is no built-in
validation or normalisation, so:
Use consistent, conventional abbreviations throughout:
"mg"not"MG"or"milligram","h"not"hr"or"hours","ng/mL"not"ng*mL-1".Case is significant:
"mg"and"MG"produce different PPORRESU strings, which matter when matching entries inconversions.Concentration units should be written as
"<mass>/<volume>", e.g."ng/mL","ug/mL","mg/L","nmol/L".Dose units may include a body-weight denominator, e.g.
"mg/kg".
Using conversions (no units package required)
The conversions data.frame maps a raw PPORRESU string to a preferred
display unit with a numeric conversion factor:
| Column | Description |
PPORRESU | Exact PPORRESU string as produced by PKNCA (case-sensitive) |
PPSTRESU | Preferred output unit label |
conversion_factor | Multiply the raw value by this to get the preferred value |
PPORRESU strings for common NCA parameters follow these patterns (where the
unit variables are exactly the strings you passed in units):
| Parameter type | PPORRESU pattern | Example |
| Concentration (Cmax, Ctrough) | concu | "ng/mL" |
| Time (t½, Tmax) | timeu | "h" |
| AUC | timeu*concu | "h*ng/mL" |
| AUMC | timeu^2*concu | "h^2*ng/mL" |
| Volume (Vz, Vss) | doseu/(concu) | "mg/(ng/mL)" |
| Clearance (CL) | doseu/(timeu*concu) | "mg/(h*ng/mL)" |
Example — converting V and CL to L / L/h for concu = "ng/mL",
doseu = "mg", timeu = "h" (conversion factor = 1000 because
1 mg/(ng/mL) = 1000 L):
run_nca(data,
units = list(concu = "ng/mL", timeu = "h", doseu = "mg"),
conversions = data.frame(
PPORRESU = c("mg/(ng/mL)", "mg/(h*ng/mL)"),
PPSTRESU = c("L", "L/h"),
conversion_factor = c(1000, 1000)
)
)Using concu_pref / doseu_pref (requires the units R package)
As an alternative, PKNCA can derive conversion factors automatically via the
units package. Pass concu_pref (and/or doseu_pref, timeu_pref,
amountu_pref) inside the units list. Unit strings for _pref fields
must be recognised by the units package (standard SI abbreviations).
The preferred concentration unit controls the derived units. To obtain V in
L and CL in L/h, choose a concu_pref whose mass unit matches doseu: