Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
any::conflicted
any::visNetwork
any::tidyr
any::units
any::lme4
any::lmerTest
any::emmeans
any::cdiscdata
github::humanpred/pknca

# Fails the job (non-zero exit) if any documented example check fails
Expand Down
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code when working in this repository.

## What This Is

A Quarto book documenting the [PKNCA](https://github.com/humanpred/pknca) R package (≥ 0.12.2).
A Quarto book documenting the [PKNCA](https://github.com/humanpred/pknca) R package (≥ 0.13.0).
Every parameter, option, and user-facing function is covered with runnable examples verified against live PKNCA output; the `pk.calc.*` calculation functions are indexed in the Developer Reference.

**Book repo:** https://github.com/humanpred/pknca-book
Expand All @@ -20,16 +20,16 @@ quarto preview # live preview with auto-reload

```r
# Install dependencies (once)
remotes::install_github("humanpred/pknca") # >= 0.12.2 required
install.packages(c("knitr", "rmarkdown", "dplyr", "ggplot2", "conflicted", "testthat", "visNetwork"))
remotes::install_github("humanpred/pknca") # >= 0.13.0 required
install.packages(c("knitr", "rmarkdown", "dplyr", "ggplot2", "conflicted", "testthat", "visNetwork", "tidyr", "units", "lme4", "lmerTest", "emmeans"))
```

## Project Structure

```
_quarto.yml # book config: title, author, chapters, site-url, navbar
index.qmd # introduction + What's new per version
user/ # 19 User Guide chapters
user/ # 25 User Guide chapters
dev/ # 2 Developer Reference chapters
validate.R # numeric self-check of key documented examples (Rscript validate.R; exits 1 on failure)
.github/workflows/book.yml # CI: runs validate.R, renders, deploys to GitHub Pages on push to main
Expand All @@ -39,7 +39,7 @@ _book/ # rendered output (gitignored)
## Conventions

- **Datasets:** `datasets::Theoph` (extravascular) and `datasets::Indometh` (intravascular)
- **PKNCA version:** ≥ 0.12.2
- **PKNCA version:** ≥ 0.13.0
- **Code chunks:** `eval: true` — every chunk must run without error
- **No `suppressWarnings()`** hiding real issues — fix root causes
- **Each page is self-contained:** load packages at the top of every `.qmd`
Expand Down
59 changes: 33 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ For each item, classify it:
|---|---|
| New NCA parameter | new `add.interval.col()` entry |
| New option | new key in `PKNCA.options()` |
| New function | e.g. `normalize()` in 0.12.2 |
| New function | e.g. `be_assess()` in 0.13.0 |
| Changed behavior | existing function works differently |
| Bug fix | may invalidate an existing example |

Expand Down Expand Up @@ -102,9 +102,10 @@ as.data.frame(o_nca) |>

**Known gotchas:**

- **Tobit half-life** — set `lloq` on `PKNCAconc()`; in PKNCA ≥ 0.12.2 it is passed through to `pk.calc.half.life()` automatically, so the full `pk.nca()` pipeline works with `options = list(hl_method = "tobit")`. (Older versions required calling `pk.calc.half.life()` directly.)
- **Sparse AUMC** — only set `sparse_aumclast = TRUE`. Explicitly requesting `sparse_auc_se = TRUE` alongside it triggers an internal type error.
- **`normalize()`** — replaces the original parameters (does not append). To keep both, `bind_rows()` before and after.
- **Tobit half-life** — set `lloq` on `PKNCAconc()`; in PKNCA ≥ 0.13.0 it is passed through to `pk.calc.half.life()` automatically, so the full `pk.nca()` pipeline works with `options = list(hl_method = "tobit")`. (Older versions required calling `pk.calc.half.life()` directly.)
- **Sparse parameters** — use the standard names (`auclast`, `aucinf.obs`, …); with `PKNCAconc(sparse = TRUE)` their `_se` and `_df` companions are calculated with them. The `sparse_*` names are deprecated.
- **Tobit with imputation** — until the LLOQ is carried onto imputed rows (pknca PR 678), combining `hl_method = "tobit"` with `impute = "start_conc0"` errors; examples show Tobit without imputation.
- **`normalize()`** — on a data frame it replaces the original parameters (does not append); on a `PKNCAresults` object it appends the normalized rows.
- **New option defaults** — always verify with `PKNCA.options("option_name")` before documenting the default.

---
Expand All @@ -131,7 +132,7 @@ as.data.frame(o_nca) |>
- Add new sections or update existing ones in the relevant `.qmd` files.
- Tag new features with `(≥ X.Y.Z)` so readers know when they were introduced.
- Keep the shared dataset pattern consistent across pages.
- If the new version introduces new functions, add them to the `:::callout-note` pkgdown reference footer at the bottom of the relevant chapter(s). The link pattern is `[function()]( https://humanpred.github.io/pknca/reference/function.html)`.
- If the new version introduces new functions, add them to the `:::callout-note` pkgdown reference footer at the bottom of the relevant chapter(s). The link pattern is `[function()](https://humanpred.github.io/pknca/reference/function.html)`.

---

Expand All @@ -141,7 +142,7 @@ as.data.frame(o_nca) |>
quarto render
```

- Watch for **red error output** in the console — chunks that error are flagged even though `execute: error: false` suppresses them in the HTML output.
- Watch for **red error output** in the console — with `execute: error: false`, a chunk that errors stops the render.
- Fix the code, not the error suppression.

Before pushing, run the numeric self-check, which verifies that key documented examples still produce correct values:
Expand Down Expand Up @@ -219,26 +220,32 @@ Template:
```
_quarto.yml # book config (title, author, chapters)
index.qmd # introduction + What's new
user/ # 19 User Guide chapters
workflow.qmd # PKNCAconc → PKNCAdose → PKNCAdata → pk.nca; all options
intervals.qmd # interval data frame; full parameter catalog
auc-methods.qmd # AUC types; integration methods; AUMC; aucabove; time_above
halflife.qmd # λz regression; Tobit; quality filters; lambda.z.corrxy
extravascular.qmd # oral/SC; BLQ; tmin; lag time
intravascular.qmd # IV bolus; C0; IV infusion; ceoi; MRT
multiple-dose.qmd # steady-state parameters; tau detection
superposition.qmd # predicting multiple-dose from single-dose
tss.qmd # time to steady state
urine-excretion.qmd# ae; fe; clr; volpk; ermax; ertmax; ertlst; clr.*.dn
sparse.qmd # sparse_auclast; sparse AUMC; derived sparse params
postprocessing.qmd # exclude(); normalize(); .dn parameters; PKNCA.set.summary
units.qmd # pknca_units_table(); preferred units; conversions
imputation.qmd # built-in imputation methods; custom methods
dose-aware-interpolation.qmd # interp.extrap.conc.dose; .dose AUCint variants
custom-parameters.qmd # add.interval.col(); registering new parameters
utilities.qmd # geomean; geocv; clean.conc.*; assert_conc_time
regulatory.qmd # PP domain; PPEXCLFL; summary() for CSR tables
validation.qmd # testthat suite; version pinning; spot-checks
user/ # 25 User Guide chapters (order in _quarto.yml)
workflow.qmd # PKNCAconc → PKNCAdose → PKNCAdata → pk.nca
intervals.qmd # Interval data frame
auto-intervals.qmd # Interval builder vs legacy
auc-methods.qmd # auclast/aucall/aucinf
halflife.qmd # Point selection controls
extravascular.qmd # BLQ handling
intravascular.qmd # IV bolus
multiple-dose.qmd # deg.fluc
superposition.qmd # Predicting multiple-dose profiles from single-dose data
tss.qmd # pk.tss.monoexponential
urine-excretion.qmd # ae
secondary-parameters.qmd # interval_id/_ref
sparse.qmd # Serial/batch designs
sparse-uncertainty.qmd # Yuan vs delta method (sparse_lambda_z_se)
bioequivalence.qmd # be_assess()
data-quality.qmd # pknca_missing_samples()
postprocessing.qmd # exclude()
units.qmd # pknca_units_table()
datetime.qmd # POSIXct/Date times
imputation.qmd # start_conc0
dose-aware-interpolation.qmd # interp.extrap.conc.dose
custom-parameters.qmd # add.interval.col()
utilities.qmd # clean.conc.*
regulatory.qmd # CDISC output
validation.qmd # testthat suite
dev/ # Developer Reference
architecture.qmd # class hierarchy; interval column system; formalsmap
function-deps.qmd # parameter dependency graph
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

[![Render and deploy book](https://github.com/humanpred/pknca-book/actions/workflows/book.yml/badge.svg)](https://github.com/humanpred/pknca-book/actions/workflows/book.yml)

A comprehensive **Quarto book** documenting the [PKNCA](https://github.com/humanpred/pknca) R package (≥ 0.12.2) with runnable examples throughout. Every parameter, option, and user-facing function is covered and verified against live PKNCA output; the underlying `pk.calc.*` calculation functions are indexed in the Developer Reference.
A comprehensive **Quarto book** documenting the [PKNCA](https://github.com/humanpred/pknca) R package (≥ 0.13.0) with runnable examples throughout. Every parameter, option, and user-facing function is covered and verified against live PKNCA output; the underlying `pk.calc.*` calculation functions are indexed in the Developer Reference.

**Live book:** https://humanpred.github.io/pknca-book/

## Build locally

```r
# Install PKNCA 0.12.2
# Install PKNCA 0.13.0 or later
remotes::install_github("humanpred/pknca")
```

Expand All @@ -22,29 +22,35 @@ open _book/index.html

## Contents

### User Guide (19 chapters)
### User Guide (25 chapters)

| Chapter | Topics |
|---|---|
| [Workflow](user/workflow.qmd) | PKNCAconc → PKNCAdose → PKNCAdata → pk.nca; all 21 options with defaults |
| [Interval selection & parameter catalog](user/intervals.qmd) | Interval data frame structure; group matching; the full parameter catalog, rendered live from the registry |
| [AUC types & integration methods](user/auc-methods.qmd) | auclast/aucall/aucinf; partial AUC; lin up/log down vs linear vs lin-log; aucabove; time_above; AUMC; cav.int |
| [Half-life & terminal phase](user/halflife.qmd) | Curve stripping; adj.r.squared.factor; quality filters; Tobit regression; lambda.z.corrxy |
| [Extravascular (oral/SC)](user/extravascular.qmd) | BLQ handling; imputation strategies; tmin; lag time; multiple peaks |
| [Intravascular (IV)](user/intravascular.qmd) | IV bolus NCA; C0 back-extrapolation; IV infusion with ceoi; MRT correction |
| [Multiple-dose / steady-state](user/multiple-dose.qmd) | deg.fluc; swing; PTR; Cav; tau detection |
| [Workflow](user/workflow.qmd) | PKNCAconc → PKNCAdose → PKNCAdata → pk.nca; default intervals; all options with defaults; update() |
| [Interval selection & parameter catalog](user/intervals.qmd) | Interval data frame; pknca_interval_table(); presets; interval_add_*(); impute columns; validation; the parameter catalog, rendered live |
| [Automatic intervals & dosing regimens](user/auto-intervals.qmd) | Interval builder vs legacy; find.dose.regimen(); find.tau(); nominal times; regimen changes; classed warnings |
| [AUC types & integration methods](user/auc-methods.qmd) | auclast/aucall/aucinf; dose-aware partial AUCs; lin up/log down vs linear vs lin-log; AUMC; aumcint; aumciv |
| [Half-life & terminal phase](user/halflife.qmd) | Point selection controls; Tobit regression; exclusion rules; get_halflife_fit()/get_halflife_curve(); lambda.z.corrxy |
| [Extravascular (oral/SC)](user/extravascular.qmd) | BLQ handling; imputation; tmin; lag time; f.obs pointer; cl/vz/vss/mrt families |
| [Intravascular (IV)](user/intravascular.qmd) | IV bolus; C0 back-extrapolation; auciv*; IV infusion; cl.iv/vz.iv; MRT correction |
| [Multiple-dose / steady-state](user/multiple-dose.qmd) | deg.fluc; swing; PTR; Cav; tau detection; mrt.md/vss.md; accumulation |
| [Superposition](user/superposition.qmd) | Predicting multiple-dose profiles from single-dose data |
| [Time to steady state](user/tss.qmd) | pk.tss.monoexponential; pk.tss.stepwise.linear; pk.tss |
| [Urine excretion](user/urine-excretion.qmd) | ae; fe; clr.*; volpk; ermax/ertmax/ertlst; clr.*.dn |
| [Sparse PK sampling](user/sparse.qmd) | sparse_auclast + SE + df; sparse AUMC; mrt/cl/kel.sparse.last |
| [Post-processing](user/postprocessing.qmd) | exclude(); normalize(); 17 .dn parameters; PKNCA.set.summary; get_halflife_points |
| [Units](user/units.qmd) | pknca_units_table() S3 generic; PKNCAdata method; preferred units; conversions |
| [Imputation](user/imputation.qmd) | start_conc0; start_predose; start_cmin; custom imputation methods |
| [Dose-aware interpolation](user/dose-aware-interpolation.qmd) | interp.extrap.conc.dose; .dose AUCint variants |
| [Custom parameters](user/custom-parameters.qmd) | add.interval.col; registering new NCA parameters |
| [Utility functions](user/utilities.qmd) | geomean; geocv; clean.conc.*; assert_conc_time |
| [Regulatory & CDISC](user/regulatory.qmd) | PP domain column mapping; CDISC output format; exclusion tracking; summary() for CSR tables |
| [Validation & testing](user/validation.qmd) | testthat suite; version pinning; manual AUClast spot-check |
| [Urine excretion](user/urine-excretion.qmd) | ae; fe; renal clearance in one run; volpk; ermax/ertmax/ertlst; erint/erlst |
| [Secondary parameters](user/secondary-parameters.qmd) | interval_id/_ref; interval_add_secondary(); bioavailability (f.*); ratio.*; renal clearance; composed units |
| [Sparse PK sampling](user/sparse.qmd) | Serial/batch designs; auclast etc. with _se/_df; start_conc0; BLQ rule; summary with SE; sparse_bootstrap() |
| [Sparse AUC to infinity & its uncertainty](user/sparse-uncertainty.qmd) | Yuan vs delta method (sparse_lambda_z_se); IV bolus C0; recommendations; prior work |
| [Bioequivalence](user/bioequivalence.qmd) | be_assess(); ABE/ABEL/RSABE/NTID/HVNTID/descriptive; crossover, replicate, parallel; sparse bootstrap route |
| [Data quality checks](user/data-quality.qmd) | pknca_missing_samples(); exclude_nca_tmax_coverage(); LLOQ and input validation |
| [Post-processing](user/postprocessing.qmd) | exclude(); exclusion rules; normalize(); .dn parameters; summary() options; PKNCA.set.summary |
| [Units](user/units.qmd) | pknca_units_table(); automatic units; preferred units; timeu and tau; conversions |
| [Date-time data & time references](user/datetime.qmd) | POSIXct/Date times; time references; date-time intervals; PPSTINT/PPENINT/PPTPTREF/PPRFTDTC |
| [Imputation](user/imputation.qmd) | start_conc0; start_predose; start_predose_conc0; start_cmin; end_conc_drop; chaining order; custom methods |
| [Dose-aware interpolation](user/dose-aware-interpolation.qmd) | interp.extrap.conc.dose; dose-aware aucint rules |
| [Custom parameters](user/custom-parameters.qmd) | add.interval.col(); FUN_sparse; pknca_ref(); registering new NCA parameters |
| [Utility functions](user/utilities.qmd) | clean.conc.*; interp.extrap.conc(); check.interval.specification(); get.parameter.deps(); route helpers; assert_* |
| [Regulatory & CDISC](user/regulatory.qmd) | CDISC output; pknca_cdisc_codes(); PPANMETH; PPGRPID; exclusion tracking; summary() for CSR tables |
| [Validation & testing](user/validation.qmd) | testthat suite; version pinning; manual AUClast spot-check; PPANMETH |

### Developer Reference (2 chapters)

Expand All @@ -53,16 +59,9 @@ open _book/index.html
| [Architecture](dev/architecture.qmd) | Internal structure of PKNCA |
| [Function dependencies](dev/function-deps.qmd) | Parameter dependency graph |

## What's new in PKNCA 0.12.2
## What's new in PKNCA 0.13.0

- **Tobit regression** for half-life — handles BLQ terminal-phase observations via censored likelihood
- **`normalize()` / `normalize_by_col()`** — normalize results by any column (body weight, BSA, etc.)
- **`tmin`** — time of minimum concentration; **`first.tmin`** option
- **Sparse AUMC** (`sparse_aumclast`, SE, df) and derived parameters (`mrt.sparse.last`, `cl.sparse.last`, `kel.sparse.last`)
- **New urine parameters**: `volpk`, `ermax`, `ertmax`, `ertlst`, `clr.last.dn`, `clr.obs.dn`, `clr.pred.dn`
- **`lambda.z.corrxy`** — correlation between time and log-concentration for the λz regression window
- **`pknca_units_table()`** now an S3 generic with a `PKNCAdata` method
- **`allow_partial_missing_units`** option
See the book's [introduction](index.qmd) for the full list. Highlights: automatic intervals rebuilt from the dosing regimen (breaking); secondary parameters (bioavailability `f.obs` etc., ratios, renal clearance) in one run; bioequivalence (`be_assess()`); sparse NCA with standard parameter names, the delta-method AUC to infinity, and `sparse_bootstrap()`; dose-aware partial AUCs; data quality checks; date-time data and CDISC time references.

## Related

Expand Down
8 changes: 7 additions & 1 deletion _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ book:
title: "PKNCA: Noncompartmental Analysis in R"
author: "Teun M. Post"
date: today
description: "A comprehensive guide to the PKNCA R package (≥ 0.12.2) — covering every function, parameter, and workflow with runnable examples."
description: "A comprehensive guide to the PKNCA R package (≥ 0.13.0) — covering every function, parameter, and workflow with runnable examples."
repo-url: https://github.com/humanpred/pknca-book
repo-actions: [issue, edit]
favicon: ""
Expand All @@ -27,6 +27,7 @@ book:
chapters:
- user/workflow.qmd
- user/intervals.qmd
- user/auto-intervals.qmd
- user/auc-methods.qmd
- user/halflife.qmd
- user/extravascular.qmd
Expand All @@ -35,9 +36,14 @@ book:
- user/superposition.qmd
- user/tss.qmd
- user/urine-excretion.qmd
- user/secondary-parameters.qmd
- user/sparse.qmd
- user/sparse-uncertainty.qmd
- user/bioequivalence.qmd
- user/data-quality.qmd
- user/postprocessing.qmd
- user/units.qmd
- user/datetime.qmd
- user/imputation.qmd
- user/dose-aware-interpolation.qmd
- user/custom-parameters.qmd
Expand Down
Loading
Loading