-
Notifications
You must be signed in to change notification settings - Fork 5
139 feat/blq options #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
139 feat/blq options #491
Conversation
js3110
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
I added some comments, and also I have noticed an issue in the handling of the BLQs, it seems to be dropping the last sample in all the options.
For example, subjid 11101 in the main branch has a slope with points 5, 6, 7, where the last point is time = 383.7, conc = 0.0063.
In this branch, that time point is gone and only 5 and 6 are there, which is not enough for slope calculations,
It seems to be the same trend for all the subjects.
This is not only an issue in the plots but also in the main results.
@js3110 Hey, I indeed changed the |
I observed that the last point was dropped for all options selected- including when I chose "keep"- so I don't think thats correct? |
|
dataset is back to what it used for simplification so lambda can still be calculated for first profile. You can still test the thing thanks to the predoses |
|
@js3110 @m-kolomanski Not sure what is the best to do here. Due to the potential discovered bug already reported in PKNCA (here), using a BLQ rule with I opened a discussion in PKNCA to figure out if this is indeed the situation and needs a fix (humanpred/pknca#447) But maybe @billdenney can confirm if this is the issue or if he knows of a workaround for it |
since this issue is not a blocker I would say we can pause it for now and wait until the bugs are fixed! |
|
For the potential bug in PKNCA, is it a real use case where you would say that you want to drop early BLQ values but also you want to impute a BLQ value? It seems like the user is giving discordant instructions at that point. If it is a real use case (rather than option interaction testing which is useful), can you please describe the scenario for this to be intentional? |
Merge remote-tracking branch 'origin/main' into 139-feat/blq-options # Conflicts: # inst/shiny/modules/tab_nca.R # inst/shiny/modules/tab_nca/setup/settings.R
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (2)
man/rm_impute_obs_params.Rd:5
- The title "Apply Imputation for PKNCA Data" is misleading for a function now named
rm_impute_obs_params. The function's primary purpose is to remove imputation from observational parameters, not to apply imputation. The title should be updated to something like "Remove Imputation from Observational Parameters" to accurately reflect the function's purpose.
man/rm_impute_obs_params.Rd:16 - The return value description states "A PKNCAdata object with imputation rules applied" which is misleading since this function removes imputation rules from observational parameters rather than applying them. The description should be updated to "A PKNCAdata object with imputation removed from observational parameters".
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
man/rm_impute_obs_params.Rd:5
- The function was renamed from apply_imputation to rm_impute_obs_params. However, the title still says "Apply Imputation for PKNCA Data" which no longer accurately reflects the function's purpose. The new name suggests it removes imputation from observational parameters, so the title should be updated to something like "Remove Imputation from Observational Parameters" to match the new function name and behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ), | ||
| conditionalPanel( | ||
| condition = sprintf("input['%s'] == 'Set value for all BLQ'", ns("select_blq_strategy")), | ||
| blq_selectize(ns("blq_value"), "Value for BLQ", selected = "0.05"), |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing comma after the last argument. While R allows trailing commas in function calls, this is inconsistent with the other conditional panels in this file where no trailing comma is used (see lines 37, 45). For consistency, consider removing the trailing comma.
| blq_selectize(ns("blq_value"), "Value for BLQ", selected = "0.05"), | |
| blq_selectize(ns("blq_value"), "Value for BLQ", selected = "0.05") |
| #' Apply Imputation for PKNCA Data | ||
| #' | ||
| #' Applies imputation rules to a PKNCAdata object, imputing start values and then | ||
| #' selectively removing imputation for parameters that are not dependent on AUC. |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description states this function "imputing start values and then selectively removing imputation" but this is no longer accurate. After the refactoring, this function only removes imputation from observational parameters (those not dependent on AUC). The start value imputation is now handled separately by create_start_impute. Update the description to accurately reflect that this function only removes imputation rules from parameters that are not dependent on AUC.
| rule_list <- switch( | ||
| input$select_blq_strategy, | ||
| "Tmax based imputation" = list( | ||
| before.tmax = input$before_tmax, | ||
| after.tmax = input$after_tmax | ||
| ), | ||
| "Positional BLQ imputation" = list( | ||
| first = input$before_first_non_blq, | ||
| middle = input$in_between_non_blqs, | ||
| last = input$after_last_non_blq | ||
| ), | ||
| "Set value for all BLQ" = list( | ||
| first = input$blq_value, | ||
| middle = input$blq_value, | ||
| last = input$blq_value | ||
| ), | ||
| "No BLQ handling" = list( | ||
| first = "keep", | ||
| middle = "keep", | ||
| last = "keep" | ||
| ), | ||
| NULL | ||
| ) |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user switches between BLQ imputation strategies, the reactive may attempt to access input values that are not yet defined (e.g., accessing input$before_tmax when switching from "Positional BLQ imputation" to "Tmax based imputation"). This could cause the reactive to fail or produce unexpected NULL values. Consider adding req() calls or NULL checks for each input value before using them in the switch statement.
| # Transform text numbers in the list to numeric | ||
| rule_list <- lapply(rule_list, function(x) { | ||
| if (x %in% c("drop", "keep")) { | ||
| x | ||
| } else if (grepl("^[0-9]+(\\.[0-9]+)?$", x)) { | ||
| as.numeric(x) | ||
| } else { | ||
| NA | ||
| } | ||
| }) |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the switch statement doesn't match any case, rule_list is set to NULL (line 86). However, the subsequent lapply call on line 90 will fail with an error when attempting to apply a function over NULL. This occurs when input$select_blq_strategy has an unexpected value. Add a NULL check after the switch statement before processing rule_list.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
js3110
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For "set value for BLQ" would it not be better to allow a custom input value?
Where does 0.05 come from?
js3110
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would also be good to add some info in the description of what the program considers a BLQ value, so the user is aware
js3110
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In DoD it says " allows to introduce a particular BLQ value (i.e LLOQ/2)" I don't see where this is possible?
I have the same comments as Jana. We would need more flexibility for BLQ handling, the best would be to have these scenarios:
|
Issue
Closes #139
Description
This PR allows users to flexibly specify BLQ imputation rules from the UI and propagate these rules through the NCA data processing pipeline. The changes include both backend logic for applying BLQ imputation and frontend UI updates to let users select their preferred BLQ handling strategy.
BLQ Imputation Feature
data_imputation_uianddata_imputation_servermodules,update_main_intervals,rm_impute_obs_params)NEWS.mdand function documentation to announce and describe the new BLQ imputation capability.Definition of Done
Note: Considering our latest conversations this feat is only in order to incorporate the options that PKNCA support. But we are not doing it with actual intention of internal use. That said, I would suggest against overcomplicating the feature options far from what PKNCA supports
tmax,BLQ positionor allows to introduce a particular BLQ value (i.eLLOQ/2)How to test
Map data > NCA settings > Test the different BLQ imputations in
Data ImputationsectionUse extreme value imputations (i.e,
10000) and check if theauclastis changed for profiles with BLQ values. I made modifications in data to include BLQ points (AVAL = 0), one case is the first profile (USUBJID = 11101, PCSPEC = "CSF", NCA_PROFILE = 1)Contributor checklist
Notes to reviewer
Blocked until we figure out what to do with the potential bug in PKNCA!No need