-
Notifications
You must be signed in to change notification settings - Fork 32
fix: fail loud on non-logical half-life point columns and annotate unreportable half-life #591
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
Changes from 2 commits
842e9be
edab70e
24e0db0
a2bd27b
bb025fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -334,6 +334,12 @@ pk.calc.half.life <- function(conc, time, tmax, tlast, | |
| } | ||
| if (any(mask_best)) { | ||
| ret[, ret_replacements] <- half_lives_for_selection[mask_best, ret_replacements] | ||
| } else { | ||
| # No window survives selection, e.g. when a well-fitting window with | ||
| # lambda.z <= 0 anchors the adjusted r-squared tolerance so that no | ||
| # window with lambda.z > 0 is within the tolerance. | ||
| attr(ret, "exclude") <- | ||
| "No valid terminal phase: no window with lambda.z > 0 within the adjusted r-squared tolerance of the best fit" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename "window" to "span" as it is the typical description for the calculation window. |
||
| } | ||
| } else { | ||
| attr(ret, "exclude") <- | ||
|
|
@@ -418,6 +424,10 @@ pk.calc.half.life <- function(conc, time, tmax, tlast, | |
| common_cols <- intersect(ret_replacements, names(all_tobit)) | ||
| ret[, common_cols] <- all_tobit[mask_best, common_cols] | ||
| } | ||
| } else { | ||
| # No window with a positive elimination rate (or no converged fit) | ||
| attr(ret, "exclude") <- | ||
| "No valid terminal phase: no Tobit window with lambda.z > 0" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename "window" to "span" as it is the typical description for the calculation window. |
||
| } | ||
| } else { | ||
| attr(ret, "exclude") <- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -277,11 +277,25 @@ pk.nca.intervals <- function(data_conc, data_dose, data_intervals, sparse, | |
| } | ||
| uses_include_hl <- FALSE | ||
| if ("include_half.life" %in% names(conc_data_interval)) { | ||
| # Guards against the column being modified after PKNCAconc() validation; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this test to |
||
| # a non-logical column would silently select nothing. | ||
| if (!is.logical(conc_data_interval$include_half.life)) { | ||
| stop( | ||
| "The include_half.life column must be a logical (TRUE/FALSE/NA) column, not ", | ||
| class(conc_data_interval$include_half.life)[1] | ||
| ) | ||
| } | ||
| args$include_half.life <- conc_data_interval$include_half.life | ||
| uses_include_hl <- !is.null(args$include_half.life) && !all(is.na(args$include_half.life)) | ||
| } | ||
| uses_exclude_hl <- FALSE | ||
| if ("exclude_half.life" %in% names(conc_data_interval)) { | ||
| if (!is.logical(conc_data_interval$exclude_half.life)) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this test to |
||
| stop( | ||
| "The exclude_half.life column must be a logical (TRUE/FALSE/NA) column, not ", | ||
| class(conc_data_interval$exclude_half.life)[1] | ||
| ) | ||
| } | ||
| args$exclude_half.life <- conc_data_interval$exclude_half.life | ||
| uses_exclude_hl <- !is.null(args$exclude_half.life) && !all(is.na(args$exclude_half.life)) | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Remove the extra explanation here. Explaining what is allowed and the error is sufficient.