nlmixr2 / nlmixr2lib

https://nlmixr2.github.io/nlmixr2lib/
5 stars 3 forks source link

Retain information from other types of rxui objects like from nonmem2rx #33

Closed mattfidler closed 1 year ago

mattfidler commented 1 year ago

With this pull, this would happen:

library(nlmixr2)
#> Loading required package: nlmixr2data
library(nlmixr2lib)
library(nonmem2rx)
f <- nonmem2rx(system.file("mods/cpt/runODE032.ctl", package="nonmem2rx"), lst=".res")
#> ℹ getting information from  '/home/matt/R/x86_64-pc-linux-gnu-library/4.2/nonmem2rx/mods/cpt/runODE032.ctl'
#> ℹ reading in xml file
#> ℹ done
#> ℹ reading in phi file
#> ℹ problems reading phi file
#> ℹ reading in lst file
#> ℹ abbreviated list parsing
#> ℹ done
#> ℹ done
#> ℹ splitting control stream by records
#> ℹ done
#> ℹ Processing record $INPUT
#> ℹ Processing record $MODEL
#> ℹ Processing record $THETA
#> ℹ Processing record $OMEGA
#> ℹ Processing record $SIGMA
#> ℹ Processing record $PROBLEM
#> ℹ Processing record $DATA
#> ℹ Processing record $SUBROUTINES
#> Warning in nonmem2rxRec.sub(.ret): $SUBROUTINES TOL=# ignored
#> ℹ Processing record $PK
#> ℹ Processing record $DES
#> ℹ Processing record $ERROR
#> ℹ Processing record $ESTIMATION
#> ℹ Ignore record $ESTIMATION
#> ℹ Processing record $COVARIANCE
#> ℹ Ignore record $COVARIANCE
#> ℹ Processing record $TABLE
#> ℹ change initial estimate of `theta1` to `1.37034`
#> ℹ change initial estimate of `theta2` to `4.19815`
#> ℹ change initial estimate of `theta3` to `1.38003`
#> ℹ change initial estimate of `theta4` to `3.87657`
#> ℹ change initial estimate of `theta5` to `0.196446`
#> ℹ change initial estimate of `eta1` to `0.101251`
#> ℹ change initial estimate of `eta2` to `0.0993872`
#> ℹ change initial estimate of `eta3` to `0.101303`
#> ℹ change initial estimate of `eta4` to `0.0730498`
#> ℹ read in nonmem input data (for model validation): /home/matt/R/x86_64-pc-linux-gnu-library/4.2/nonmem2rx/mods/cpt/Bolus_2CPT.csv
#> ℹ ignoring lines that begin with a letter (IGNORE=@)'
#> ℹ applying names specified by $INPUT
#> ℹ subsetting accept/ignore filters code: .data[-which((.data$SD == 0)),]
#> ℹ done
#> ℹ read in nonmem IPRED data (for model validation): /home/matt/R/x86_64-pc-linux-gnu-library/4.2/nonmem2rx/mods/cpt/runODE032.csv
#> ℹ done
#> ℹ read in nonmem ETA data (for model validation): /home/matt/R/x86_64-pc-linux-gnu-library/4.2/nonmem2rx/mods/cpt/runODE032.csv
#> ℹ done
#> ℹ changing most variables to lower case
#> ℹ done
#> ℹ replace theta names
#> Warning: there are duplicate theta names, not renaming duplicate parameters
#> ℹ done
#> ℹ replace eta names
#> Warning: there are duplicate eta names, not renaming duplicate parameters
#> ℹ done (no labels)
#> ℹ renaming compartments
#> ℹ done
#> ℹ solving ipred problem
#> ℹ done
#> ℹ solving pred problem
#> ℹ done

# remove eta
m <- f %>% model({cl <- exp(theta1)})
#> ! remove between subject variability `eta1`

m2 <- m %>% addEta("theta1")
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> ℹ promote `etatheta1` to between subject variability with initial estimate 0.1
#> ℹ change initial estimate of `etatheta1` to `0.1`
#> → Kept in model: '$sigma'
#> → Removed from model: '$dfObs', '$dfSub', '$etaData', '$ipredAtol', '$ipredCompare', '$ipredRtol', '$nonmemData', '$predAtol', '$predCompare', '$predRtol', '$thetaMat'

Created on 2023-02-26 with reprex v2.0.2

mattfidler commented 1 year ago

This breaks your tests which assume a function instead of a parsed ui expression.