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

Fix pkTrans() #87

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ jobs:
pak-version: devel
extra-packages: |
any::rcmdcheck
nlmixr2/dparser-R
nlmixr2/lbfgsb3c
nlmixr2/lotri
nlmixr2/PreciseSums
nlmixr2/n1qn1c
nlmixr2/rxode2ll
nlmixr2/rxode2
nlmixr2/nlmixr2est
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ jobs:
pak-version: devel
extra-packages: |
any::pkgdown
nlmixr2/dparser-R
nlmixr2/lbfgsb3c
nlmixr2/lotri
nlmixr2/PreciseSums
nlmixr2/n1qn1c
nlmixr2/rxode2ll
nlmixr2/rxode2
nlmixr2/nlmixr2est
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ jobs:
pak-version: devel
extra-packages: |
any::covr
nlmixr2/dparser-R
nlmixr2/lbfgsb3c
nlmixr2/lotri
nlmixr2/PreciseSums
nlmixr2/n1qn1c
nlmixr2/rxode2ll
nlmixr2/rxode2
nlmixr2/nlmixr2est
Expand Down
30 changes: 16 additions & 14 deletions R/modeldb.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ addFileToModelDb <- function(dir, file, modeldb) {
dosing <- NULL
dosing_meta <- mod$meta$dosing
if(!is.null(dosing_meta)){
dosing = paste(dosing_meta, collapse=",")
dosing <- paste(dosing_meta, collapse=",")
}else {
if("depot" %in% mod$params$cmt){
dosing = c(dosing, "depot") }
if("central" %in% mod$params$cmt){
dosing = c(dosing, "central") }
if(!is.null(dosing)){
dosing = paste(dosing, collapse=",")
if("depot" %in% mod$props$cmt) {
dosing <- c(dosing, "depot")
}
if("central" %in% mod$props$cmt) {
dosing <- c(dosing, "central")
}
if(!is.null(dosing)) {
dosing <- paste(dosing, collapse=",")
} else {
dosing = NA_character_
dosing <- NA_character_
}
}

Expand All @@ -143,7 +145,7 @@ addFileToModelDb <- function(dir, file, modeldb) {
depends = paste(depends_meta, collapse=",")
}
if(is.null(depends)){
depends = NA_character_
depends = NA_character_
}

# Extract the parameter names
Expand All @@ -166,22 +168,22 @@ addFileToModelDb <- function(dir, file, modeldb) {
if (is.null(paramErr)) {
paramErr <- ""
}
if(!mod$params$linCmt && (length(mod$params$cmt) == 0)){


if(!mod$props$linCmt && (length(mod$props$cmt) == 0)){
algebraic = TRUE
} else {
algebraic = FALSE
}


ret <-
data.frame(
name = modelName,
description = description,
parameters = paste(modParamFixed, collapse = ","),
DV = paramErr,
linCmt = mod$params$linCmt,
linCmt = mod$props$linCmt,
algebraic = algebraic,
dosing = dosing,
depends = depends,
Expand Down
1 change: 1 addition & 0 deletions R/transPk.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ addLogEstimates <- function(ui, vars,
.tmp$pre,
.extra,
extraLines,
.tmp$w,
.tmp$post
)
}
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-transPk.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ test_that("transPk -- k", {
pkTrans("k")
expect_true(all(c("lkel", "lk12", "lk21", "lk13", "lk31") %in% names(p3k$theta)))

# Issue #87 -- Make sure depot is not dropped
expect_equal(rxode2::modelExtract(p3k, "d/dt(depot)"),
"d/dt(depot) <- -ka * depot")

p2k <- readModelDb("PK_2cmt_des") |>
pkTrans("k")
expect_true(all(c("lkel", "lk12", "lk21") %in% names(p2k$theta)))
Expand Down
Loading