Draft
Add impute_method parameter to PK calculation functions and refactor imputation logic#6
Conversation
Co-authored-by: Gero1999 <68994823+Gero1999@users.noreply.github.com>
Co-authored-by: Gero1999 <68994823+Gero1999@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add impute_method argument to relevant R functions
Add impute_method parameter to PK calculation functions and refactor imputation logic
Oct 14, 2025
Gero1999
pushed a commit
that referenced
this pull request
Apr 15, 2026
…lve bugs #6 and #7 Replace all single | and & operators with || and && in scalar if() conditions across 24 R source files for idiomatic short-circuit evaluation. Vectorized uses of | and & (inside all(), any(), or column-level mask construction) are unchanged. Add comments to auc_integrate.R and cleaners.R documenting that %in% 0 for BLQ detection is intentionally exact equality, since BLQ values are cleaned to exactly 0 upstream and a tolerance cannot be used without domain knowledge of what a "low" concentration means. All 2292 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
This PR refactors how data imputation is handled in PKNCA by moving imputation logic from
pk.nca.intervalinto individual PK calculation functions. Previously, imputation was applied externally before calling parameter functions. Now, each function that handles BLQ (below limit of quantification) values can also handle imputation internally, providing better control and consistency.Changes
New Parameters Added
Added
impute_method,conc.group, andtime.groupparameters to all functions withconc.blqargument:In
R/auc.R:pk.calc.auxc()In
R/half.life.R:pk.calc.half.life()In
R/interpolate.conc.R:interp.extrap.conc()interpolate.conc()extrapolate.conc()interp.extrap.conc.dose()Implementation Details
Imputation after BLQ cleaning: The
impute_methodis now applied afterclean.conc.blq()processing within each function, ensuring proper data cleaning order.Group-level data support: Added optional
conc.groupandtime.groupparameters to support imputation functions likePKNCA_impute_method_start_predosethat require access to group-level concentration and time data.Refactored
pk.nca.interval: Removed the imputation logic that was applied before calling parameter functions. Instead,impute_method,conc.group, andtime.groupare now passed as arguments to the parameter functions, which handle imputation internally.Backward Compatibility
All new parameters have default values that maintain existing behavior:
impute_method = NA_character_conc.group = NULLtime.group = NULLFunctions continue to work as before when imputation is not specified.
Example Usage
Benefits
Fixes the requirement to refactor imputation from being applied outside parameter functions to being passed as an argument and applied internally.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.