PP
Introduction
This article shows how to create a Pharmacokinetic Parameters (PP) domain from an ADNCA dataset using the {aNCA} package. PP is the SDTM domain that holds non-compartmental analysis (NCA) results — one row per parameter per subject per time-reference.
{aNCA} wraps {PKNCA} for the NCA calculations and adds column mapping, CDISC code translation, flag rules and export helpers so the full pipeline runs in a single script.
By the end of this example you will have:
- NCA results computed from concentration-time data
- A CDISC-compliant PP dataset
- Companion ADPP and ADNCA datasets
Programming workflow
- Load packages and data
- Define column mapping
- Set up filters
- Define NCA settings
- Create and configure the PKNCA data object
- Run NCA calculations
- Apply flag rules
- Export CDISC datasets (PP, ADPP, ADNCA)
Load packages and data
{aNCA} ships with adnca_example, a 76-row ADNCA dataset with two analytes (DrugA and Metab-DrugA), two specimen types (SERUM and URINE) and two dosing periods. Subjects received different dose levels via extravascular and intravascular routes.
Define column mapping
The mapping tells {aNCA} which columns in your dataset correspond to the expected CDISC variables. Keys are standard ADNCA column names; values are the actual column names in your data.
mapping <- list(
STUDYID = "STUDYID",
USUBJID = "USUBJID",
DOSEA = "DOSEA",
DOSEU = "DOSEU",
DOSETRT = "DOSETRT",
PARAM = "PARAM",
Metabolites = "Metab-DrugA",
ARRLT = "ARRLT",
NRRLT = "NRRLT",
AFRLT = "AFRLT",
NCAwXRS = c("NCA1XRS", "NCA2XRS"),
NFRLT = "NFRLT",
PCSPEC = "PCSPEC",
ROUTE = "ROUTE",
TRTRINT = "TRTRINT",
ADOSEDUR = "ADOSEDUR",
Grouping_Variables = c("TRT01A", "RACE", "SEX"),
RRLTU = "RRLTU",
VOLUME = "VOLUME",
VOLUMEU = "VOLUMEU",
AVAL = "AVAL",
AVALU = "AVALU",
ATPTREF = "ATPTREF"
)A few notes:
Metabolites: PARAM value(s) that represent metabolites. Sets theMETABFLflag internally.NCAwXRS: Column(s) with NCA exclusion reason codes. Flagged subjects are excluded from calculations.Grouping_Variables: Columns carried through to results and used for grouping in descriptive statistics.
Set up filters
Filters restrict the data before analysis. Each filter specifies a column and the values to keep. Here we keep only the parent drug for serum specimens:
Define NCA settings
Partial interval calculations
Interval parameters compute AUC or average concentration over custom time windows:
Parameter selections
Select which NCA parameters to compute, grouped by study type:
Custom units
Override default units for specific parameters:
Flag rules
Quality thresholds for terminal elimination regression. Parameters that violate a checked rule are flagged and excluded from summary statistics:
Slope rules and extra variables
Slope rules allow manual override of the lambda-z regression range. Pass an empty data frame if no manual adjustments are needed:
Create and configure the PKNCA data object
PKNCA_create_data_object() applies the column mapping, filters and duplicate handling. PKNCA_update_data_object() then configures the AUC method, intervals, parameters and units:
pknca_obj <- adnca_data %>%
PKNCA_create_data_object(
mapping = mapping,
applied_filters = applied_filters,
time_duplicate_rows = NULL
) %>%
PKNCA_update_data_object(
method = "lin up/log down",
selected_analytes = "DrugA",
selected_profile = "DOSE 1",
selected_pcspec = "SERUM",
start_impute = "yes",
exclusion_list = list(),
hl_adj_rules = slope_rules,
keep_interval_cols = setdiff(extra_vars_to_keep, c("DOSEA", "ATPTREF", "ROUTE")),
min_hl_points = 3,
parameter_selections = parameters_selected_per_study,
int_parameters = int_parameters,
custom_units_table = units_table
)Run NCA calculations
blq_rule: How to handle BLQ values at different positions in the concentration-time profile. Options:"keep","0","loq/2".add_f_to_pknca_results(NULL): Pass an AUC type to compute bioavailability, orNULLto skip.
Apply flag rules
Flag rules mark parameters that fail quality thresholds. Flagged parameters get an exclusion reason and are dropped from descriptive statistics:
Export CDISC datasets (PP, ADPP, ADNCA)
export_cdisc() produces the PP, ADPP and ADNCA datasets. Flag rules are formatted into CRITy/CRITyFL/PPSUMFL columns in ADPP:
# Format flag rule messages for ADPP criterion columns
flag_operators <- c(
R2ADJ = " < ", R2 = " < ", AUCPEO = " > ", AUCPEP = " > ", LAMZSPN = " < "
)
checked_flags <- purrr::keep(flag_rules, function(x) x$is.checked)
flag_rule_msgs <- if (length(checked_flags) > 0) {
vapply(names(checked_flags), function(nm) {
paste0(nm, flag_operators[nm], checked_flags[[nm]]$threshold)
}, character(1), USE.NAMES = FALSE)
} else {
NULL
}
cdisc_datasets <- pknca_res %>%
export_cdisc(
grouping_vars = extra_vars_to_keep,
flag_rules = flag_rule_msgs
)The result is a named list with three data frames:
cdisc_datasets$pp— PP domain: one row per parameter per subject.cdisc_datasets$adpp— ADPP: PP with ADaM-style flags and criterion columns (CRITy, CRITyFL, PPSUMFL, PPSUMRSN).cdisc_datasets$adnca— ADNCA: the full analysis dataset with results joined back to the concentration-time data.
Alternative workflows
Generate the script from a YAML settings file
The aNCA Shiny app exports a settings YAML that captures the full analysis configuration. You can regenerate the R script from it:
Generate from the aNCA Shiny app
From the app, configure mapping, filters and NCA settings, then export via the Save button to get the settings YAML, reproducible R script and all outputs.