-
Notifications
You must be signed in to change notification settings - Fork 5
Simplify the logic in slope plots, add order option & allow download in ZIP #641
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?
Conversation
TODO: mydata is affected by parameters and is affecting manual_slopes!
…ed (e.g subj 3, time point 5 and 6)
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 37 out of 38 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| new_row <- cbind( | ||
| first_group, | ||
| data.frame( | ||
| TYPE = "Exclusion", | ||
| RANGE = paste0( | ||
| inner_join(first_group, pknca_data()$conc$data)[[time_col]][2] | ||
| ), |
Copilot
AI
Jan 5, 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 inner_join on line 86 may fail or produce unexpected results if first_group contains NA values or if there's no matching row in the concentration data. Consider adding error handling or validation to ensure the join succeeds and that at least 2 rows exist before accessing the second element with [2].
| new_row <- cbind( | |
| first_group, | |
| data.frame( | |
| TYPE = "Exclusion", | |
| RANGE = paste0( | |
| inner_join(first_group, pknca_data()$conc$data)[[time_col]][2] | |
| ), | |
| # Safely join to concentration data and derive a time value for the RANGE column | |
| joined_conc <- inner_join(first_group, pknca_data()$conc$data) | |
| if (!is.null(time_col) && time_col %in% names(joined_conc) && nrow(joined_conc) > 0) { | |
| if (nrow(joined_conc) >= 2) { | |
| range_value <- joined_conc[[time_col]][2] | |
| } else { | |
| # Fallback to the first available time if only one row is present | |
| range_value <- joined_conc[[time_col]][1] | |
| } | |
| } else { | |
| # If join fails or time column is unavailable, use NA to avoid runtime errors | |
| range_value <- NA_character_ | |
| } | |
| new_row <- cbind( | |
| first_group, | |
| data.frame( | |
| TYPE = "Exclusion", | |
| RANGE = paste0(range_value), |
| grepl( | ||
| paste0("USUBJID=(", paste0(search_val, collapse = ")|("), ")"), | ||
| names(plot_outputs()) | ||
| ) |
Copilot
AI
Jan 5, 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 search pattern on line 54 hardcodes "USUBJID" as the grouping variable for filtering plots. If the data uses a different subject identifier column name, this search will not work correctly. Consider making the subject column name configurable or dynamically detecting it from the pknca_data object.
Co-authored-by: Mateusz Kołomański <63905560+m-kolomanski@users.noreply.github.com>
|
@js3110 regarding the very specific user bugs:
This is fixed
This I was not able to replicate it neither here nor in main. Maybe was fixed with after the merge. Otherwise please share me a screen recording and the console messages and I will try to look into it @m-kolomanski regarding the suggestions: Most of them were addressed. Some style changes specifically for |
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.
Hey @Gero1999 , thanks, the bugs from before don't seem to be there anymore!
Unfortunately I ran into some other issues:
If I add a selection it doesn't update the plot:

If I click all the way to the end, I then can't change page anymore:
I also got an error after adding the following selections/exclusions:

ERROR [2026-01-07 11:08:17] Error calculating NCA results:
ℹ In index: 13.
Caused by error in `assert_numeric_between()`:
! Please report a bug.
: Error with interval start=0, end=24.018: Assertion on 'lambda.z' failed: Element 1 is not > 0
It worked after I removed the selection. I tried a different selection and this time it worked (the plot updated but only after I ran the NCA)
I removed an exclusion and ran the NCA again, then when I went to add it back it added two rows to the table:

Now every time I try to add a new exclusion/selection it adds all the previous ones too:
Screen.Recording.2026-01-07.111559.mp4
…update_data_object.R, PKNCA.R, test-PKNCA.R)
Description
This changes simplify the logic that makes the slope plots in order to make easier future implementations and also make able the download of all plots in a zip file easily. The advantages would be:
Features
Enhancements
get_halflife_plot)setup.R, instead of in the post-processing of results. We no longer need to usefilter_slopesis.included.hloris.excluded.hlthat then are used to buildexclude_half.life. Instead we directly use theexclude_half.life&include_half.lifecolumnsBugs fixed
Tests
FIXTURE_PKNCA_DATAobj will now contain the columnsinclude_half.life,exclude_half.lifeDefinition of Done
Closes or contributes to #333 (I think with this the client interest is already satisfied)
Faceting so groups are all on one pageCloses #553
Slope Selectorfeatures work well without issuesSlope selectorincluding its plotsHow to test
How to test features not covered by unit tests.
Contributor checklist
Notes to reviewer
Compare thoughtfully the feats of the plots to make sure I did not miss anything relevant.
Don't hesitate also to leave suggestions for refactoring or code comments that makes the code easier to read.