-
Notifications
You must be signed in to change notification settings - Fork 13
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
RXR-1926 implement infusion duration scaling #92
Conversation
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.
a couple design question. Can you also please add some unit tests to confirm the function is working as intended?
R/apply_duration_scale.R
Outdated
parameters, | ||
cmt_mapping = NULL | ||
) { | ||
if(is.null(regimen$t_inf)) { |
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.
if(is.null(regimen$t_inf)) { | |
if(is.null(regimen$t_inf) || all(regimen$t_inf == 0)) { |
From the warning, it sounds like we should also check for 0-length infusions.
R/apply_duration_scale.R
Outdated
apply_duration_scale <- function( | ||
regimen, | ||
duration_scale = NULL, | ||
parameters, |
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.
from the documentation, it seems like parameters are only required in certain situations ("if parameters are specified"). should this therefore default to NULL? I think the documentation could be a little clearer about what this argument is and when it is necessary
R/apply_duration_scale.R
Outdated
} | ||
if(class(duration_scale) %in% c("character")) { |
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.
} | |
if(class(duration_scale) %in% c("character")) { | |
} else if (class(duration_scale) %in% c("character")) { |
slightly clearer, since you never want to do both conversions
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.
overall lgtm, but one question about cmt vs type
if(length(duration_scale) == 1) { | ||
regimen$t_inf <- regimen$t_inf * duration_scale | ||
} else { | ||
regimen$t_inf <- regimen$t_inf * duration_scale[regimen$cmt] |
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.
regimen$t_inf <- regimen$t_inf * duration_scale[regimen$cmt] | |
regimen$t_inf <- regimen$t_inf * duration_scale[regimen$type] |
does it make more sense to use the type
argument since i think that is how we tend to differentiate doses of different types (which go to different compartments)
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.
Sorry, I misread my earlier code. That 5 lines of code I removed is actually useful, at least when we're using a vector of duration scales that matches cmt
s, which we do. The removed code ensures there is always a cmt
in the regimen, even when not specified by the user. So will bring that code back. I think it is OK where it is, and doesn't need to go on top of the function, since we only want to make a modification to the regimen if its actually needed, IMO.
Regarding your 2nd question whether we should link it to type
rather than cmt
: I think it's less consistent to link it to type
: we now have "lagtime" also linked to a specific cmt
, not to an observation type. I see lagtime and duration scale as two very similar features. Also in NONMEM durations and infusion lengths are linked to compartments, so for most users more intuitive. An option for a future ticket could be that lagtime
and duration_scale
could also be specified as a list, where they then indeed can be mapped to observation types.
…m into RXR-1926-duration-scale
add tests, plus to multiplication
This implements a feature where a model automatically scales infusion durations by a specified factor.
An example model where this is used in NONMEM is Centanni et al. CPK 2024.
In the implementation in PKPDsim it is handled in the same was as lagtime, it just modifies the input regimen / event table that is used in the simulation function.