nlmixr2 / rxode2

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

Parsing issue due to comment within IIV block #259

Open billdenney opened 2 years ago

billdenney commented 2 years ago

There appears to be a conversion from a comment to a ";" intended to make a label when there is a comment within a parameter definition.

library(nlmixr2)
#> Loading required package: nlmixr2data

# This model is based on
# Oishi, Masayo, Yoshiro Tomono, Hidetomi Yamagami, and Bimal Malhotra.
# “Population Pharmacokinetics of the 5-Hydroxymethyl Metabolite of Tolterodine
# after Administration of Fesoterodine Sustained Release Tablet in Western and
# East Asian Populations: Population Pharmacokinetics of 5-HMT in Western and
# East Asian Populations.” The Journal of Clinical Pharmacology 54, no. 8
# (August 2014): 928–36. https://doi.org/10.1002/jcph.274.

model_5hmt <- function() {
  ini({
    tka <- 0.0935 ; label("Absorption rate of extended release fesoterodine; h^-1")

    tv <- 144 ; label ("Observed central volume (V/F); L")

    tcl <- 93.8 ; label("Observed clearance (CL/F); L/h")
    cl_crcl <- 0.303 ; label("Effect of creatinine clearance on clearance; unitless")
    cl_hep <- 0.422 ; label("Effect of hepatic impairment on clearance; fractional change")
    cl_cyp2d6 <- 0.626 ; label("Effect of cyp2d6 poor metabolizers on clearance; fractional change")
    cl_cyp3a_inh <- 0.504 ; label("Effect of coadministered CYP3A inhibitor on clearance; fractional change")
    cl_cyp3a_ind <- 3.90 ; label("Effect of coadministered CYP3A inducer on clearance; fractional change")
    cl_sexf <- 0.903 ; label("Effect of being female on clearance; fractional change")
    cl_japanese <- 1.12 ; label("Effect of Japanese ethnicity on clearance; fractional change")

    # label("Inter-individual variability of clearance")
    # label("Inter-individual variability of central volume")
    iiv_ka + iiv_cl + iiv_v ~
      c(0.0663, # label("Inter-individual variability of absorption rate")
        0.148, 0.217,
        0,     0.0457, 0.606)

    prop_err <- 0.0951
    add_err <- 0.00123
  })
  model({
    # crcl = creatinine clearance (mL/min)
    cl_crcl_i <- (crcl/80)^cl_crcl
    # hepatic_impair = 1 indicates Child-Pugh stage B; 0 otherwise
    cl_hep_i <- cl_hep * hepatic_impair + (1 - hepatic_impair)
    # cyp2d6 = 1 indicates PM; 0 indicates EM
    cl_cyp2d6_i <- cl_cyp2d6 * cyp2d6 + (1 - cyp2d6)
    # cyp3a_inh = 1 indicates coadministered CYP3A inhibitor; 0 otherwise
    cl_cyp3a_inh_i <- cl_cyp3a_inh * cyp3a_inh + (1 - cyp3a_inh)
    # cyp3a_ind = 1 indicates coadministered CYP3A inducer; 0 otherwise
    cl_cyp3a_ind_i <- cl_cyp3a_ind * cyp3a_ind + (1 - cyp3a_ind)
    # sex = "Female" or "Male"
    cl_sexf_i <- cl_sexf * (sex == "Female") + (sex == "Male")
    # japanese = 1 if Japanese; 0 otherwise
    cl_japanese_i <- cl_japanese * japanese + (1 - japanese)
    cl <-
      tcl * exp(iiv_cl) *
      cl_crcl_i *
      cl_hep_i * cl_cyp2d6_i * cl_cyp3a_inh_i * cl_cyp3a_ind_i * cl_sexf_i *
      cl_japanese_i
    v <- tv * exp(iiv_v)
    ka <- tka * exp(iiv_ka)
    alag(central) <- tlag
    cp <- linCmt()*1000 # convert a mg dose with L volumes to ng/mL
    cp ~ prop(prop_err) + add(add_err)
  })
}

model <- nlmixr(model_5hmt)
#> ℹ parameter labels from comments will be replaced by 'label()'
#> Error in parse(text = paste(.ret, collapse = "\n"), keep.source = FALSE): <text>:20:17: unexpected ';'
#> 19:     iiv_ka + iiv_cl + iiv_v ~
#> 20:       c(0.0663, ;
#>                     ^

Created on 2022-08-25 by the reprex package (v2.0.1)

mattfidler commented 2 years ago

Thanks @billdenney I will look into this

billdenney commented 2 years ago

I think that this is done on the R side. If so, I can look into it. (Though, it'll probably be >1 week before I have time to take the look.)

mattfidler commented 2 years ago

Sure;

The function is here:

https://github.com/nlmixr2/rxode2/blob/a1065e26df91465405a4f5384f99403e96713d6e/R/ui.R#L7-L39

Parsing doesn't work without writing a parser since R ignores comments.