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

loading dose as a function of body weight #1253

Open
PLLS opened this issue Nov 11, 2024 · 2 comments
Open

loading dose as a function of body weight #1253

PLLS opened this issue Nov 11, 2024 · 2 comments

Comments

@PLLS
Copy link

PLLS commented Nov 11, 2024

Hello,
I am a beginner with mrgsolve. I am trying to simulate the concentration of a manteinance dose of ustekinumab in a population of patients with a mean weight of 70kg and standard deviation of 30, (max of 100 and min 40).

The population is generated like this:

set.seed(33020)
idata <-
tibble(ID=1:1000) %>%
mutate_random(BW[40,100] ~ rnorm(70,30))

The manteinance dose is 90mg c/12w and the loading dose depends on the body weight of each individual: if BW<50kg, 260mg, if BW>80kg, 590mg and 390mg for the rest. The events are:

ev1<-ev(amt=90, time=56, ii=84, addl=10, cmt=1, ss=1)
ev2<-ev(amt=260,time=0, addl=0, cmt=2)
ev3<-ev(amt=390,time=0, addl=0, cmt=2)
ev4<-ev(amt=520,time=0, addl=0, cmt=2)

but I don't know how to enter the loading dose as a function of body weight. I can only run the simulation with a single loading dose, e.g. amt=260, like this:

out<-
mymodel %>%
idata_set(idata)%>%
ev(ev1%then%ev2)%>%
mrgsim(delta=2,end=560,obsonly=TRUE)
out

can someone help me?
Thank you very much
Pilar

@kylebaron
Copy link
Collaborator

Hi @PLLS -

Please see the code below showing how I'd approach it. I would create two data frames, one for the loading dose and another for the maintenance doses. Then bind them together and sort. I also included a column in the data and output that will let you group people by the weight group and the loading dose they got since you'll likely need that when you summarize the simulations.

Please let me know if this is what you're looking for in the simulation.

Kyle

Example

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
library(tidyr)
library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(dmutate)

I’m going to use this model just to illustrate

mymodel <- modlib("popex", CL = 0.1)
#> Building popex ... done.

set.seed(33020)

The manteinance dose is 90mg c/12w and the loading dose depends on
the body weight of each individual: if BW<50kg, 260mg, if BW>80kg,
590mg and 390mg for the rest. The events are:
In addition to simulating BW, assign the loading dose
based on BW

These are the labels for your weight groups

groups <- c("BW<50kg", "BW 50-80kg", "BW>80kg")

idata <-
  tibble(ID = 1:1000) %>%
  mutate_random(BW[40,100] ~ rnorm(70,30)) %>% 
  mutate(
    load = case_when(
      BW < 50 ~ 260, 
      BW > 80 ~ 590, 
      TRUE ~ 390
    ), 
    # Make a factor from the loading dose
    GRP = factor(load, labels = groups), 
  )
#> Warning: `data_frame()` was deprecated in tibble 1.1.0.
#> ℹ Please use `tibble()` instead.
#> ℹ The deprecated feature was likely used in the dmutate package.
#>   Please report the issue at <https://github.com/kylebaron/dmutate/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

Set up one data frame for the maintenance dose

maint <- mutate(
  idata, 
  amt = 90, 
  time = 56, 
  ii = 84, 
  addl = 10, 
  cmt = 2, 
  evid = 1
)

Another data frame for the loading dose; overwrite amt to
be the loading dose we calculated above

load <- mutate(
  maint, 
  amt = load,  # <---- ***
  time = 0, 
  addl = 0, 
  ii = 0
)

Combine and arrange

data <- bind_rows(load, maint) 
data <- arrange(data, ID, time)

Now check the input data

head(data)
#> # A tibble: 6 × 10
#>      ID    BW  load GRP          amt  time    ii  addl   cmt  evid
#>   <int> <dbl> <dbl> <fct>      <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1  95.4   590 BW>80kg      590     0     0     0     2     1
#> 2     1  95.4   590 BW>80kg       90    56    84    10     2     1
#> 3     2  57.6   390 BW 50-80kg   390     0     0     0     2     1
#> 4     2  57.6   390 BW 50-80kg    90    56    84    10     2     1
#> 5     3  78.5   390 BW 50-80kg   390     0     0     0     2     1
#> 6     3  78.5   390 BW 50-80kg    90    56    84    10     2     1

filter(data, BW < 50) %>% slice(1:4)
#> # A tibble: 4 × 10
#>      ID    BW  load GRP       amt  time    ii  addl   cmt  evid
#>   <int> <dbl> <dbl> <fct>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1    14  40.2   260 BW<50kg   260     0     0     0     2     1
#> 2    14  40.2   260 BW<50kg    90    56    84    10     2     1
#> 3    17  43.1   260 BW<50kg   260     0     0     0     2     1
#> 4    17  43.1   260 BW<50kg    90    56    84    10     2     1
filter(data, BW > 80) %>% slice(1:4)
#> # A tibble: 4 × 10
#>      ID    BW  load GRP       amt  time    ii  addl   cmt  evid
#>   <int> <dbl> <dbl> <fct>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     1  95.4   590 BW>80kg   590     0     0     0     2     1
#> 2     1  95.4   590 BW>80kg    90    56    84    10     2     1
#> 3     4  86.9   590 BW>80kg   590     0     0     0     2     1
#> 4     4  86.9   590 BW>80kg    90    56    84    10     2     1
filter(data, BW > 50 & BW < 80) %>% slice(1:4)
#> # A tibble: 4 × 10
#>      ID    BW  load GRP          amt  time    ii  addl   cmt  evid
#>   <int> <dbl> <dbl> <fct>      <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1     2  57.6   390 BW 50-80kg   390     0     0     0     2     1
#> 2     2  57.6   390 BW 50-80kg    90    56    84    10     2     1
#> 3     3  78.5   390 BW 50-80kg   390     0     0     0     2     1
#> 4     3  78.5   390 BW 50-80kg    90    56    84    10     2     1

Give it a try

set.seed(29292)
out <- mrgsim(
  mymodel, data, 
  delta = 2,
  end = 560, 
  recover = "GRP,load", 
  obsonly = TRUE,
  recsort = 3
)

plot(out, IPRED ~ time | GRP, subset = ID <= 50, scales = "same")

Check Cmax on the first (loading) dose

out %>% 
  filter(time==0) %>% 
  summarize(Cmax = max(IPRED), n = n(), .by = c(GRP, load)) %>% 
  mutate(CmaxR = Cmax / last(Cmax), loadR = load/last(load))
#> # A tibble: 3 × 6
#>   GRP         load  Cmax     n CmaxR loadR
#>   <fct>      <dbl> <dbl> <int> <dbl> <dbl>
#> 1 BW>80kg      590  78.1   322  2.51  2.27
#> 2 BW 50-80kg   390  53.3   542  1.71  1.5 
#> 3 BW<50kg      260  31.1   136  1     1

Created on 2024-11-11 with reprex v2.1.1

@PLLS
Copy link
Author

PLLS commented Nov 12, 2024

Hi Kyle,
that's just what I was looking for. I was stuck and I wouldn't have been able to continue without your help.
Sincere thanks!
Pilar

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

No branches or pull requests

2 participants