Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into 68-use-new-steady-state-for-lincmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Jul 1, 2024
2 parents 6e44a16 + f7c1fad commit a57b9e9
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 45 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 2.0.17
Date: 2023-12-09 14:16:33 UTC
SHA: 322bf8f43bd079b336d33cd4e3af1f7a6a91648c
Version: 2.0.18
Date: 2024-01-29 00:09:27 UTC
SHA: 94be647f14bed3ecf80d9cdc30525b61ecd881ff
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rxode2parse
Title: Parsing and Code Generation Functions for 'rxode2'
Version: 2.0.18
Version: 2.0.19.9000
Authors@R: c(
person("Matthew L.", "Fidler", , "matthew.fidler@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8538-6691")),
Expand All @@ -16,7 +16,7 @@ Maintainer: Matthew L. Fidler <matthew.fidler@gmail.com>
Description: Provides the parsing needed for 'rxode2' (Wang, Hallow and
James (2016) <doi:10.1002/psp4.12052>). It also provides the 'stan'
based advan linear compartment model solutions with gradients
(Carpenter et al (2015), <arXiv:1509.07164>) needed in 'nlmixr2'
(Carpenter et al (2015), <doi:10.48550/arXiv.1509.07164>) needed in 'nlmixr2'
(Fidler et al (2019) <doi:10.1002/psp4.12445>).
This split will reduce computational burden of recompiling 'rxode2'.
License: GPL (>= 3)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# rxode2parse (development version)

* As requested by CRAN remove the C code `SET_TYPEOF` which is no
longer part of the C R API.

# rxode2parse 2.0.19

* Added a evid suffix of 60 for cases where evid=2 adds an on event
(fixes tad() calculation in certain edge cases)

* Initialize all variables to `NA`

# rxode2parse 2.0.18

* Removed linear compartment solutions with gradients from rxode2parse
Expand Down
12 changes: 8 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Cran comments
- Fixes the m1mac issues flagged by CRAN, including the overlooked issue on 1323:19
- Removes solved systems with gradients for intel c++ compilers (because they didn't compile)
- Have updated reverse dependencies to check if linear compartment solutions are present before running tests

# Update for full nlmixr2 update
- Once accepted, all the nlmixr2 stack will be updated

- Until the new rxode2 and nlmixr2est is fixed all reverse
dependencies will be broken

- Changed arXiv to doi
50 changes: 25 additions & 25 deletions inst/include/rxode2parseHandleEvid.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,29 @@ extern "C" {

#define EVIDF_MODEL_RATE_ON 9
#define EVIDF_MODEL_RATE_OFF 7
// 0 = no Infusion
// 1 = Infusion, AMT=rate (mg/hr for instance)
// 2 = Infusion, duration is fixed
// 4 = Replacement event
// 5 = Multiplication event
// 6 = Turn off modeled duration
// 7 = Turn off modeled rate compartment
// 8 = Duration is modeled, AMT=dose; Rate = AMT/(Modeled Duration) NONMEM RATE=-2
// 9 = Rate is modeled, AMT=dose; Duration = AMT/(Modeled Rate) NONMEM RATE=-1
// c1 = Compartment numbers below 99
// xx = 1, regular event (no lag time)
// xx = 2, An infusion/rate event that doesn't look for start/end of infusion AND does not apply lags
// xx = 8, possibly turn off steady state infusion with lag time (needed in case spans dur)
// xx = 9, steady state event SS=1 with lag time
// xx = 10, steady state event SS=1 (no lag)
// xx = 19, steady state event at dose time (SS=2) with lag
// xx = 20, steady state event + last observed info (not lagged)
// xx = 21, steady state event at dose time (with absorption lag) + last observed info
// xx = 30, Turn off compartment
// xx = 40, Steady state constant infusion
// xx = 50, Phantom event, used for transit compartments
// Steady state events need a II data item > 0
// 0 = no Infusion
// 1 = Infusion, AMT=rate (mg/hr for instance)
// 2 = Infusion, duration is fixed
// 4 = Replacement event
// 5 = Multiplication event
// 6 = Turn off modeled duration
// 7 = Turn off modeled rate compartment
// 8 = Duration is modeled, AMT=dose; Rate = AMT/(Modeled Duration) NONMEM RATE=-2
// 9 = Rate is modeled, AMT=dose; Duration = AMT/(Modeled Rate) NONMEM RATE=-1
// c1 = Compartment numbers below 99
// xx = 1, regular event (no lag time)
// xx = 2, An infusion/rate event that doesn't look for start/end of infusion AND does not apply lags
// xx = 8, possibly turn off steady state infusion with lag time (needed in case spans dur)
// xx = 9, steady state event SS=1 with lag time
// xx = 10, steady state event SS=1 (no lag)
// xx = 19, steady state event at dose time (SS=2) with lag
// xx = 20, steady state event + last observed info (not lagged)
// xx = 21, steady state event at dose time (with absorption lag) + last observed info
// xx = 30, Turn off compartment
// xx = 40, Steady state constant infusion
// xx = 50, Phantom event, used for transit compartments
// xx = 60, Dose that does not track as a dose turn on system
// Steady state events need a II data item > 0
#define EVID0_REGULAR 1
#define EVID0_RATEADJ 2
#define EVID0_INFRM 8
Expand All @@ -111,7 +112,7 @@ extern "C" {
#define EVID0_OFF 30
#define EVID0_SSINF 40
#define EVID0_PHANTOM 50

#define EVID0_ONDOSE 60

static inline void getWh(int evid, int *wh, int *cmt, int *wh100, int *whI, int *wh0){
*wh = evid;
Expand Down Expand Up @@ -356,10 +357,9 @@ extern "C" {
}
}


static inline int syncIdx(rx_solving_options_ind *ind) {
if (ind->idx < 0) return 1; // additional dose; technically the idx doesn't relate to idose/ix
if (ind->ixds >= ind->ndoses) ind->ixds=ind->ndoses-1;
else if (ind->ixds < 0) ind->ixds=0;
if (ind->ix[ind->idx] != ind->idose[ind->ixds]) {
// bisection https://en.wikipedia.org/wiki/Binary_search_algorithm
int m = getDoseNumberFromIndex(ind, ind->ix[ind->idx]);
Expand Down
8 changes: 4 additions & 4 deletions src/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static inline void printParamLags(char *buf, int *j) {
sAppendN(&sbOut, "#define last_", 13);
doDot(&sbOut, buf);
sAppend(&sbOut, "1(x) _getParCov(_cSub, _solveData, %d, (&_solveData->subjects[_cSub])->n_all_times - 1)\n", *j);

sAppendN(&sbOut, "#undef lead_", 12);
doDot(&sbOut, buf);
sAppendN(&sbOut, "1\n", 2);
Expand All @@ -169,14 +169,14 @@ static inline void printParamLags(char *buf, int *j) {

sAppendN(&sbOut, "#undef lag_", 11);
doDot(&sbOut, buf);
sAppendN(&sbOut, "1\n", 2);
sAppendN(&sbOut, "1\n", 2);
sAppendN(&sbOut, "#define lag_", 12);
doDot(&sbOut, buf);
sAppend(&sbOut, "1(x) _getParCov(_cSub, _solveData, %d, (&_solveData->subjects[_cSub])->idx - 1)\n", *j);

sAppendN(&sbOut, "#undef lag_", 11);
doDot(&sbOut, buf);
sAppendN(&sbOut, "\n", 1);
sAppendN(&sbOut, "\n", 1);
sAppendN(&sbOut, "#define lag_", 12);
doDot(&sbOut, buf);
sAppend(&sbOut, "(x,y) _getParCov(_cSub, _solveData, %d, (&_solveData->subjects[_cSub])->idx - (y))\n", *j);
Expand Down Expand Up @@ -219,7 +219,7 @@ static inline void printDoubleDeclaration(char *buf) {
!strcmp("rx_hi_", buf) || !strcmp("rx_low_", buf)){
sAppendN(&sbOut, "__", 2);
}
sAppendN(&sbOut, ";\n", 2);
sAppendN(&sbOut, " = NA_REAL;\n", 12);
}

static inline void printVoidDeclaration(char *buf) {
Expand Down
8 changes: 4 additions & 4 deletions src/etTran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ List etTransParse(List inData, List mv, bool addCmt=false,
else caddl = inAddl[i];
if (IntegerVector::is_na(caddl)) caddl = 0;
// EVID flag
if (evidCol == -1){
if (evidCol == -1) {
// Missing EVID
if (rateI == 0 && (ISNA(camt) || camt == 0.0)){
cevid = 0;
Expand Down Expand Up @@ -1256,7 +1256,7 @@ List etTransParse(List inData, List mv, bool addCmt=false,
cevid=0;
}
}
switch(cevid){
switch(cevid) {
case 0:
// Observation
nobs++;
Expand Down Expand Up @@ -1421,10 +1421,10 @@ List etTransParse(List inData, List mv, bool addCmt=false,
ndose++;
// + cmt needs to turn on cmts.
// This gives a zero dose to cmt
if (cmtCol != -1 && cmt > 0 && cmt <= baseSize){
if (cmtCol != -1 && cmt > 0 && cmt <= baseSize) {
// Turn on state with dose
id.push_back(cid);
evid.push_back(cevid);
evid.push_back(cevid-flg+60);
cmtF.push_back(cmt);
time.push_back(ctime);
amt.push_back(0.0);
Expand Down
3 changes: 1 addition & 2 deletions src/getOption.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
int R_get_option(const char *option, int def) {
SEXP s, t;
int ret, pro=0;
PROTECT(t = s = allocList(3));pro++;
SET_TYPEOF(s, LANGSXP);
PROTECT(t = s = LCONS(R_NilValue, allocList(2)));pro++;
SETCAR(t, install("getOption")); t = CDR(t);
SETCAR(t, mkString(option)); t = CDR(t);
if (def){
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-etTrans.R
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ d/dt(blood) = a*intestine - b*blood
})

test_that("dat3 has evid w/amt 0", {
expect_equal(dat3$EVID, c(101L, 2L, 0L, 0L, 0L, 101L, 2L, 0L, 0L, 0L))
expect_equal(dat3$EVID, c(160L, 2L, 0L, 0L, 0L, 160L, 2L, 0L, 0L, 0L))
expect_equal(dat3$AMT, c(0, NA, NA, NA, NA, 0, NA, NA, NA, NA))
})

Expand Down

0 comments on commit a57b9e9

Please sign in to comment.