nlmixr2 / rxode2

rxode2
https://nlmixr2.github.io/rxode2/
GNU General Public License v3.0
28 stars 8 forks source link

Unclear error: cannot solve without event information #334

Closed billdenney closed 1 year ago

billdenney commented 1 year ago

Given the error, I'm not sure what column is missing. I tried adding EVID and cmt, but that didn't work. (I'm sure I'll figure it out soon, but this seems like something where the error could point the user to the expected but missing columns.)

library(tidyverse)
library(nlmixr2)
#> Loading required package: nlmixr2data
oncology_sdm_lobo_2002 <- function() {
  description <- "Signal transduction model for delayed concentration effects on cancer cell growth"
  reference <- "Lobo ED, Balthasar JP. Pharmacodynamic modeling of chemotherapeutic effects: Application of a transit compartment model to characterize methotrexate effects in vitro. AAPS J. 2002;4(4):212-222. doi:10.1208/ps040442"
  # Values for lkng, ltau, lec50, and kmax are for methotrexate from Lobo 2002,
  # Table 2.  propErr and addErr are added as reasonable values though not from
  # Lobo 2002 where no value is apparent in the paper.
  ini({
    lkng <- log(0.02) ; label("Cell net growth rate (growth minus death) (1/hr)")
    ltau <- log(c(1, 34.1, 500)) ; label("Mean transit time of each transit compartment (hr)")
    lec50 <- log(c(1, 50, 2000)) ; label("Drug concentration reducing the cell growth by 50% (ug/mL)")
    kmax <- 0.01 ; label("Maximum drug-related reduction in cell growth (1/hr)")

    propErr <- c(0, 0.3) ; label("Proportional residual error (fraction)")
    addErr <- c(0, 50, 1000) ; label("Additive residual error (tumor volume units)")
  })
  model({
    # cp is the drug concentration
    kng <- exp(lkng)
    tau <- exp(ltau)
    taulast <- tau
    ec50 <- exp(lec50)

    edrug <- kmax*cp/(ec50 + cp)

    tumor(0) <- tumor0
    d/dt(transit1) <- (edrug - transit1)/tau
    d/dt(transit2) <- (transit1 - transit2)/tau
    d/dt(transit3) <- (transit2 - transit3)/tau
    d/dt(transitlast) <- transit3/tau - transitlast/taulast
    d/dt(tumor) <- kng*tumor - transitlast*tumor
    tumor ~ prop(propErr) + add(addErr)
  })
}

d_sim <-
  data.frame(
    tumor0 = 100,
    EVID = 0,
    cmt = "tumor",
    cp=pmxTools::calc_sd_1cmt_linear_bolus(t = 0:24, dose = 1, CL = 1, V = 1)
  ) %>%
  crossing(
    ID = 1:2
  )

simulated <- nlmixr2(oncology_sdm_lobo_2002, data = d_sim, est = "rxSolve")
#> Error in rxSolveSEXP(object, .ctl, .nms, .xtra, params, events, inits,  : 
#>   cannot solve without event information
#> Error: cannot solve without event information

Created on 2022-10-17 with reprex v2.0.2

billdenney commented 1 year ago

The issue is that I was missing the TIME column.

mattfidler commented 1 year ago

Yes, I was about to say that is what I saw

mattfidler commented 1 year ago

I believe that rxode2/nlmixr2 checks to make sure that the data.frame has the right columns for a event table before running a simulation. Perhaps he error can be expanded to say to make sure the dataset has the following columns.

mattfidler commented 1 year ago

In fact the only required column is time

billdenney commented 1 year ago

Thanks!