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

Fill out evtools function set for dosing #1227

Merged
merged 14 commits into from
Sep 7, 2024
Merged

Fill out evtools function set for dosing #1227

merged 14 commits into from
Sep 7, 2024

Conversation

kylebaron
Copy link
Collaborator

@kylebaron kylebaron commented Sep 1, 2024

Summary

These functions provide new functionality to (1) gives doses at steady state and (2) give additional doses. We also provide the user some of the "missing" api for working with these event objects in C++.

Note: working on this feature, I discovered behavior in #1229 that will need to be addressed in another work stream; it's a known issue now and will need some reimagining of how this in-model dosing is done.

All of the tests compare doses set up via the data set (or event object) and doses that are issued from inside the model. For each combination, there is a test for when the parent event is done "now" and another test when the parent dose is done "later".

New data members in evdata:

  • ss
  • ii
  • addl

All of these items naturally initialize to 0. There is no new central functionality needed to handle these items; they just get passed into existing machinery.

New functions:

  • ss() - advance the system to steady state prior to diving the dose
  • ii() - specify the dose interval
  • addl() - give additional doses
  • amt() - set / reset the dose amount
  • rate() - set / reset the infusion rate
  • cmt()- set / reset the dose compartment

Existing functions:

  • bolus() - bolus dose
  • infuse() - start an infusion
  • reset() - reset the system or reset and dose
  • replace() - replace the amount in a compartment (evid 8)
  • retime() - sets the time attribute and forces now to false
  • now() - make an event happen "now"

The goal is to have a fairly complete set of functions to deal with these objects.

Example

library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union


code <- '
$PLUGIN evtools autodec

$PARAM 
CL = 1, V = 25, KA = 1.3
Dose = 100, Ii = 24, End = 240, Ss = -1

$PKMODEL cmt = "A1,A2", depot = TRUE

$ERROR
if(NEWIND <= 1) {
  evt::ev dose = evt::bolus(Dose, 1);
  evt::ii(dose, Ii); 
  evt::addl(dose, (End/Ii));
  if(Ss > 0) evt::ss(dose, 1);
  self.push(dose);
}
'
mod <- mcode('foo', code)
#> Building foo ...
#> done.

Sensitivity analysis on dose, ii and addl

idata <- expand.idata(Dose = c(50, 100, 200), Ii = c(6, 12, 24), End = c(120, 240, 360))
out <- mrgsim(mod, idata = idata, end = 360, recover = "Dose,Ii,End", recsort = 3) 

plot(out, A2~time|factor(End)*factor(Ii))

Simulation at steady-state

idata <- expand.idata(Dose = 100, Ii = c(6, 12, 24), Ss = c(0,1), End = 240)
out <- mrgsim(mod, idata = idata, end = 360, recover = "Dose,Ii,Ss", recsort = 3) 

plot(out, A2~time|factor(Ss))

Created on 2024-09-03 with reprex v2.1.1

@kylebaron kylebaron linked an issue Sep 1, 2024 that may be closed by this pull request
@kylebaron kylebaron requested a review from kyleam September 4, 2024 19:28
Copy link
Contributor

@kyleam kyleam left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed summary.

All of the tests compare doses set up via the data set (or event object) and doses that are issued from inside the model.

These tests look great.

@kylebaron kylebaron merged commit bde03b3 into main Sep 7, 2024
7 checks passed
@kylebaron kylebaron deleted the evtools-ss branch September 7, 2024 21:11
@kylebaron kylebaron mentioned this pull request Oct 17, 2024
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.

Add ss and addl functionality to evtools
2 participants