Repository navigation
interval_add_secondary() links per-subject intervals to their own subject - #714
Open
billdenney wants to merge 40 commits into
Open
billdenney wants to merge 40 commits into
billdenney wants to merge 40 commits into
Conversation
…n subject Automatically generated intervals have one row per subject, so a reference such as data.frame(start = 0, end = 12) matched one row per subject. The reference was chosen by time alone, so every later interval matched several references and the helper stopped with pknca_error_secondary_ref_ambiguous_spec. The candidate references are now first narrowed to those sharing the test row's values in the columns that `reference` and `ref_vary` do not name. Reads of a possibly absent interval_id column use [[ ]], so tibble intervals no longer warn about an unknown column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When units differ between groups (a subject without a dose, or unit
columns), the units table keeps the group columns, holding their values
as character. pknca_unit_conversion() joined the results to it with
dplyr::left_join(), which stops on an integer, numeric, or date group
column ("Can't join ... due to incompatible types") and turns a factor
group column into character. left_join_by_value() matches the keys as
character and restores the key columns of the results.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With unit columns and a preferred unit, a unit set already in the preferred units got a table without PPSTRESU and conversion_factor, while the sets that convert had them. Composing the secondary parameter units read the missing columns as zero-length and stopped with "arguments imply differing number of rows: 1, 0". Every unit set now has the standardization columns when any has them, with the set's own units and a factor of 1 where it does not convert, as pknca_units_table() does within one set. The comment that preferred units only apply to scalar units was wrong: pknca_set_units() keeps them for unit columns too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clr.last.dn, clr.obs.dn, and clr.pred.dn were registered like the other dose-normalized parameters, as pk.calc.dn(parameter, dose). They are secondary (they depend on a renal clearance), and secondary parameters are calculated from NCA parameter values only, so the dose source argument stopped every request with "has arguments not covered by formalsmap (dose)". The dose-normalized form of a secondary parameter is now a secondary parameter of its own: the base parameter's inputs and reference, with the dose from totdose (as bioavailability takes it), calculated by pk.calc.clr.dn(). Explicit links, the parameter's own _ref column, and automatic references work, and its units are composed from the urine and plasma groups like renal clearance. The classification of the three parameters is unchanged. New tests calculate every registered secondary parameter through a linked reference interval and check every dose-normalized parameter's registration against its base parameter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…generated # Conflicts: # NEWS.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…zed names The dose-normalized renal clearance is now clr.inf.obs.dn and clr.inf.pred.dn, with clr.obs.dn and clr.pred.dn as their deprecated names; a deprecated dose-normalized name is checked against the base of its replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Renal clearance divided by the dose is not a parameter used in the pharmacokinetic literature (CDISC has a code for it, RENALCLD, but no publication reports it), so this stack does not make clr.*.dn calculable. This reverts the changes of fix/clr-dn-formalsmap, which leaves the stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…econdary-generated
…econdary-generated
…econdary-generated
…econdary-generated
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
interval_add_secondary()failed on automatically generated intervals, which have one row per subject:reference = data.frame(start = 0, end = 12)matched one reference row per subject, the reference was chosen by time alone, and the call stopped withpknca_error_secondary_ref_ambiguous_spec. It also warned "Unknown or uninitialised column:interval_id" on tibble intervals.Fix
Candidate references are first narrowed to those sharing the test row's values in the columns that
referenceandref_varydo not name (the engine reads the group values of the reference row a pointer names), falling back to all candidates when none share them. Reads of a possibly absentinterval_iduse[[.Tests
The generated per-subject case links each subject to its own reference with no warnings, and
pk.nca()givesratio.auclast94/70 and 94/130; a crossover withref_vary = "period"picks each subject's own reference in another period (cmax ratios 6/10 and 9/20).🤖 Generated with Claude Code