Skip to content
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
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Imports: Rcpp (>= 1.0.13), BH, data.table, stringr, MASS,
Suggests:
httr,
testthat (>= 3.0.0),
mockery,
knitr,
rmarkdown
LinkingTo: BH, Rcpp (>= 1.0.13)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*


RUN Rscript -e "install.packages(c('mockery', 'nlmixr2', 'knitr', 'rmarkdown'), repos = 'https://cloud.r-project.org')"
RUN Rscript -e "install.packages(c('nlmixr2', 'knitr', 'rmarkdown'), repos = 'https://cloud.r-project.org')"

RUN R CMD check PKPDsim

2 changes: 1 addition & 1 deletion Dockerfile.aws
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ WORKDIR /src/PKPDsim
# Install system and CRAN dependencies
RUN apt-get update
RUN apt install -y pandoc qpdf
RUN Rscript -e "install.packages(c('mockery', 'nlmixr2', 'knitr', 'rmarkdown'), repos = '${RSPM_SNAPSHOT}')"
RUN Rscript -e "install.packages(c('nlmixr2', 'knitr', 'rmarkdown'), repos = '${RSPM_SNAPSHOT}')"
12 changes: 8 additions & 4 deletions R/advan_process_infusion_doses.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ advan_process_infusion_doses <- function (data) {
doserowslast[, badcols] <- NA

# Are there any doserows without a DV value? These need to precede the infusion change
noDVindex <- which(!doserowslast$TIME %in% data$TIME)
# Solely exclude observation-only times (AMT==0): infusion end times coinciding with dose times
# still need an AMT=0 sentinel row so ordering is correct in the RATEALL loop.
noDVindex <- which(!doserowslast$TIME %in% data$TIME[data$AMT == 0])
doserowslastnoDV <- doserowslast[noDVindex,]
doserowslastnoDV$AMT <- 0
doserowslastnoDV$RATE <- 0
doserowslastnoDV$DNUM <- NA
if (nrow(doserowslastnoDV) > 0) {
doserowslastnoDV$AMT <- 0
doserowslastnoDV$RATE <- 0
doserowslastnoDV$DNUM <- NA
}

# Collect the new rows
doserows <- rbind(doserows, doserowslast, doserowslastnoDV)
Expand Down
30 changes: 30 additions & 0 deletions tests/testthat/test_calc_auc_analytic.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,36 @@ test_that("Works for 1cmt model", {
expect_equal(tmp$auc, aucfr$auc)
})

test_that("Correct output when t_inf equals interval", {
# confirm that continuous infusion and infusion that is _nearly_ continuous
# produce nearly the same estimates and don't raise an error
reg_c <- new_regimen(
amt = 750, n = 12, interval = 8, t_inf = 8, type = "infusion"
)
reg_i <- new_regimen(
amt = 750, n = 12, interval = 8, t_inf = 7.999, type = "infusion"
)
expect_no_error(
res_c <- calc_auc_analytic(
f = "2cmt_iv_infusion",
parameters = list(CL = 4.5, V = 45, Q = 2.3, V2 = 49),
regimen = reg_c,
t_obs = c(0, 88, 96)
)
)
res_i <- calc_auc_analytic(
f = "2cmt_iv_infusion",
parameters = list(CL = 4.5, V = 45, Q = 2.3, V2 = 49),
regimen = reg_i,
t_obs = c(0, 88, 96)
)
# Trough at t=96 should be positive and finite
expect_true(is.finite(tail(res_c$y, 1)) && tail(res_c$y, 1) > 0)
# AUC and trough are nearly identical (difference is due to delta in t_inf)
expect_equal(round(res_c$auc[3]/res_i$auc[3], 5), 1)
expect_equal(round(res_c$y[3]/res_i$y[3], 3), 1)
})

test_that("Doesn't fail when t_inf is specified as 0 in regimen or as t_inf. Should be nearly equal to bolus", {
reg1 <- new_regimen(amt = 1500, n = 10, interval = 24, type = "infusion", t_inf = 0)
reg2 <- new_regimen(amt = 1500, n = 10, interval = 24, type = "bolus")
Expand Down
5 changes: 0 additions & 5 deletions tests/testthat/test_misc.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
test_that("now_utc returns time in UTC", {
mockery::stub(
now_utc,
"Sys.time",
structure(1640042187.11864, class = c("POSIXct", "POSIXt"))
)
now <- now_utc()
expect_equal(attr(now, "tzone"), "UTC")
})
Expand Down
Loading