Skip to content

separate HL reason checking from filter_slopes#929

Merged
Gero1999 merged 16 commits intomainfrom
928-enhancement-separate-hl-reason-checking-from-filter_slopes
Jan 27, 2026
Merged

separate HL reason checking from filter_slopes#929
Gero1999 merged 16 commits intomainfrom
928-enhancement-separate-hl-reason-checking-from-filter_slopes

Conversation

@Gero1999
Copy link
Copy Markdown
Collaborator

@Gero1999 Gero1999 commented Jan 23, 2026

Issue

Closes #928

Description

  • Added a new function check_valid_pknca_data to check that all manually excluded half-life points have a non-empty reason; if any are missing, an error is raised and the affected rows are printed. This function is now called before NCA calculations, and can be used to keep expanding the checks.
  • Removed the check_reasons parameter and related logic from the filter_slopes function, delegating responsibility for exclusion reason validation to the new check_valid_pknca_data function
  • Added tests for check_valid_pknca_data to verify correct behavior when exclusions have reasons and when they do not.

Definition of Done

  • create a fun check_valid_pknca_data that do at least the check for REASON populated for exclusions
  • remove old check in filter_slopes

How to test

Map data > NCA > Slope Selector > Double click (add exclusion) > Try run NCA > See message > Populate REASON in Slope Selector > Run NCA

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented
  • App or package changes are reflected in NEWS
  • Package version is incremented
  • R script works with the new implementation (if applicable)

@Gero1999 Gero1999 linked an issue Jan 23, 2026 that may be closed by this pull request
1 task
@Gero1999 Gero1999 changed the title separate HL reason checking from filter slopes separate HL reason checking from filter_slopes Jan 23, 2026
@Gero1999 Gero1999 requested a review from js3110 January 23, 2026 15:49
@Gero1999 Gero1999 marked this pull request as ready for review January 23, 2026 15:49
@Gero1999 Gero1999 requested a review from Shaakon35 January 23, 2026 15:49
@Gero1999 Gero1999 marked this pull request as draft January 23, 2026 15:57
@Gero1999 Gero1999 marked this pull request as ready for review January 26, 2026 07:32
Comment thread R/PKNCA.R Outdated
#' @examples
#' # Suppose processed_pknca_data is a valid PKNCA data object
#' # check_valid_pknca_data(processed_pknca_data)
check_valid_pknca_data <- function(processed_pknca_data, exclusions_have_reasons = TRUE) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have separated the logic from filter slopes, is there a reason to have the parameter exclusions_have_reasons ? Since the whole purpose of this function is to check validity then its implied that we are checking if the exclusions have reasons, and there is no use for the function otherwise...

If you have a reason for keeping it, then it should be renamed as exclusions_have_reasons doesn't quite make sense. I would suggest check_reasons or something similar

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question. I want to let us further include more optional checking args here and also at some point probably allow the user if they want them or not to be checked. But I like the renaming to check_exclusion_has_reason

@Gero1999 Gero1999 requested a review from m-kolomanski January 26, 2026 13:10
use incoming slope_rules()$... instead of slope_rules$...() without the check in filter_slopes()

Merge remote-tracking branch 'origin/main' into 928-enhancement-separate-hl-reason-checking-from-filter_slopes

# Conflicts:
#	inst/shiny/modules/tab_nca.R
@Gero1999 Gero1999 requested a review from js3110 January 26, 2026 15:16
Copy link
Copy Markdown
Collaborator

@js3110 js3110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this warning message isn't super clear for the user:

image

maybe we remove the row info all together (since they can just check which exclusions are missing a reason), or incorporate a paste?

@Gero1999
Copy link
Copy Markdown
Collaborator Author

@js3110 maybe better to open a new issue to customize the message (good-first issue) and don't overexpand this PR

@js3110
Copy link
Copy Markdown
Collaborator

js3110 commented Jan 27, 2026

@js3110 maybe better to open a new issue to customize the message (good-first issue) and don't overexpand this PR

Hmm I woudl disagree seeing as this PR directly changes the message, so its relevant and in-scope. It wouldn't add more to this PR just change what has already been done

@Gero1999
Copy link
Copy Markdown
Collaborator Author

I moved the code and refactor but the logic display should be the same. But if you are keen I can simply take off the information on the exclusion missing, that is fine for me

@Gero1999 Gero1999 requested a review from js3110 January 27, 2026 09:03
@js3110
Copy link
Copy Markdown
Collaborator

js3110 commented Jan 27, 2026

I moved the code and refactor but the logic display should be the same. But if you are keen I can simply take off the information on the exclusion missing, that is fine for me

The display is different, here is the example from main:
image

clearly there is something wrong with this version as there are two sentences telling the user to go to slope selector to add the reason, and the pasting of the data is different. So I would suggest you change it back to how it was before, or remove the data. Whatever you prefer

@Gero1999
Copy link
Copy Markdown
Collaborator Author

Not sure what happened, the row should have been already removed, did you pull? @js3110

@Shaakon35
Copy link
Copy Markdown
Collaborator

It works for me:
image

Comment thread R/PKNCA.R
if (any(missing_reasons)) {
stop(
"No reason provided for all half-life exclusions.\n",
"Please go to `Setup > Slope Selector` and type a REASON in the table for each."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for each row?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well more like for each half-life exclusion (rows can also be half-life selections). Do you think is better be explicit with the repetition?

@js3110
Copy link
Copy Markdown
Collaborator

js3110 commented Jan 27, 2026

Not sure what happened, the row should have been already removed, did you pull? @js3110

yes, works now. I would still change phrasing slightly as it currently says all half life exclusions but if theres only one missing a reason it still shows the message. Maybe No reason provided for at least one half-life exclusion

Copy link
Copy Markdown
Collaborator

@js3110 js3110 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :) LGTM!

@Gero1999 Gero1999 merged commit 018aa3b into main Jan 27, 2026
9 of 10 checks passed
@Gero1999 Gero1999 deleted the 928-enhancement-separate-hl-reason-checking-from-filter_slopes branch January 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: separate HL REASON checking from filter_slopes

3 participants