-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feature request: New logslope & c1 impute_start methods #350 #351
base: main
Are you sure you want to change the base?
Conversation
all_concs <- conc[time >= start & time <= end] | ||
all_times <- time[time >= start & time <= end] | ||
if (!all(is.na(all_concs))) { | ||
c0 <- PKNCA::pk.calc.c0(all_concs, all_times, method = "logslope") |
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.
Since this is within PKNCA, please switch to the pk.calc.c0.method.logslope
function directly rather than using pk.calc.c0
.
@@ -120,6 +120,46 @@ PKNCA_impute_method_start_predose <- function(conc, time, start, end, conc.group | |||
ret | |||
} | |||
|
|||
#' @describeIn PKNCA_impute_method Imputes based on a logarithmic slope on the | |||
#' first points a time zero concentration (usually in IV bolus at dose time) |
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.
Please add an additional part to the description: "If this imputation is used for NCA calculations, back-extrapolation percent will not be calculated or will be calculated as zero."
} | ||
|
||
#' @describeIn PKNCA_impute_method Shift the following concentration to a start | ||
#' to become the time zero concentration (rarely used; non-monodecay IV bolus) |
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.
Please add an additional part to the description: "If this imputation is used for NCA calculations, back-extrapolation percent will not be calculated or will be calculated as zero."
all_concs <- conc[time >= start & time <= end] | ||
all_times <- time[time >= start & time <= end] | ||
if (!all(is.na(all_concs))) { | ||
c0 <- PKNCA::pk.calc.c0(all_concs, all_times, method = "logslope") |
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.
Please set time.dose = start
in case the intended start time is not 0. Please add a test for this case as well.
ret <- data.frame(conc = conc, time = time) | ||
mask_start <- time %in% start | ||
if (!any(mask_start)) { | ||
all_concs <- conc[time >= start & time <= end] |
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.
Please use pk.calc.c0.method.c1
. That way, you don't need to filter all_concs
, all_times
, and your is.na()
test below can be on c1
. That will also ensure that c1
is consistently calculated anywhere it is used within PKNCA.
data.frame(conc = c(3, 3, 1), time = 1:3), | ||
ignore_attr = TRUE | ||
) | ||
}) |
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.
Please add tests for:
- All concentrations are NA
- All times are NA
- All concentrations are 0
(I see that list of tests is needed for the other imputation methods, too. I just added an issue, #361, to add those after this PR is merged.)
New PKNCA_method_start functions that could perhaps be default/standard. Feel free to give them a look and merge them if they are useful!
Closes #350