Repository navigation
v1.3.0 — Correctness fixes: dose matching, BLQ scoping, units, reproducibility
This release fixes four defects that produced plausible-looking wrong numbers rather than errors. Anyone who has run an analysis with a mapped Dose column, a crossover BLQ rule, or non-default units should re-run it.
1. Doses could be assigned to the wrong subject
tblNCA matches its dose argument to profiles by position. The dose vector was built grouped by subject, but the profile key is sorted lexicographically. With ten or more numeric subjects (1, 2, 10, 11 sorts as 10, 11, 1, 2) or unpadded character IDs, and a Treatment column mapped, the two orders diverge and each subject receives another subject's dose.
Affected: CL/F, Vz/F, CMAXD, AUCIFOD and all *_DN parameters.
Not affected: Cmax, Tmax, AUC, half-life — which is why nothing looked wrong.
Doses are now passed as a vector named by subject and matched by name. An unnamed multi-subject vector is refused rather than guessed.
As a side effect, per-subject dosing now works in crossover designs for the first time; it previously stopped with a generic "NCA failed" message.
2. The reproducibility script did not reproduce the app
The reproduce_analysis.R shipped inside the Complete Analysis Record diverged from the app in two ways:
- The generated
dplyr::summarise()referenced the whole data frame rather than the group, so every subject was assigned the highest dose in the file. - The script lacked the app's handling of text entries below the limit of quantification (e.g.
"<0.5"), so they becameNAand were dropped instead of imputed under the selected BLQ rule.
EXP-CMP-01 could not detect either, because it re-runs run_nca() in-process instead of executing the shipped script. The new REG-REP-01 builds a record, runs reproduce_analysis.R through Rscript, and compares every parameter against the app.
3. BLQ rules crossed period boundaries
Rules 1, 5 and 6 depend on which sample comes first and last. They grouped by subject only, so in a crossover they treated a subject's Test and Reference periods as one concatenated profile, imputing the two formulations differently and biasing the ratio. They also ran in file order rather than time order. Both are corrected: rules now apply per profile (subject × treatment), always in time order.
4. Units are semantic, and unsupported spellings failed opaquely
NonCompart derives a real conversion factor for clearance and volume from the dose and concentration units. Free-text entry allowed spellings the engine cannot parse — µg/mL (micro sign), mcg/mL, mg/kg — which failed inside a tryCatch and surfaced as "NCA failed. Check the data and column mapping."
Units are now selected from validated lists and checked before the run by validate_units(), with a specific message. A molecular weight input has been added, so molar assays (e.g. nmol/L with a mg dose) now return CL and V instead of blanks.
Validation
Ten regression tests added in a new REG section, each reproducing one of the defects above. 191 automated + 32 manual tests, all critical passed, 57/57 URS covered.
🤖 Generated with Claude Code