Skip to content
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

Merged
merged 12 commits into from
Apr 3, 2024

Conversation

roninsightrx
Copy link
Contributor

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.

@jasmineirx jasmineirx self-requested a review March 26, 2024 19:36
Copy link
Contributor

@jasmineirx jasmineirx left a 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?

parameters,
cmt_mapping = NULL
) {
if(is.null(regimen$t_inf)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

apply_duration_scale <- function(
regimen,
duration_scale = NULL,
parameters,
Copy link
Contributor

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

Comment on lines 36 to 37
}
if(class(duration_scale) %in% c("character")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
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

R/apply_duration_scale.R Outdated Show resolved Hide resolved
@roninsightrx roninsightrx requested a review from jasmineirx April 2, 2024 16:41
Copy link
Contributor

@jasmineirx jasmineirx left a 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

R/sim.R Show resolved Hide resolved
if(length(duration_scale) == 1) {
regimen$t_inf <- regimen$t_inf * duration_scale
} else {
regimen$t_inf <- regimen$t_inf * duration_scale[regimen$cmt]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)

Copy link
Contributor Author

@roninsightrx roninsightrx Apr 2, 2024

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 cmts, 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.

@roninsightrx roninsightrx requested a review from jasmineirx April 2, 2024 21:13
@roninsightrx roninsightrx merged commit 60583a0 into master Apr 3, 2024
2 checks passed
@roninsightrx roninsightrx deleted the RXR-1926-duration-scale branch April 3, 2024 18:43
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.

2 participants