Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
billdenney committed Jan 2, 2018
1 parent fe6e2d8 commit 86a61f1
Show file tree
Hide file tree
Showing 10 changed files with 368 additions and 209 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: PKNCA
Type: Package
Title: Perform Pharmacokinetic Non-Compartmental Analysis
Version: 0.8.3.9001
Version: 0.8.3.9002
Date: 2018-01-01
Authors@R: c(
person("Bill", "Denney", email="[email protected]", role=c("aut", "cre")),
Expand Down
28 changes: 17 additions & 11 deletions R/aucint.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pk.calc.aucint <- function(conc, time, interval, start, end,
# AUCinf traces an AUClast curve (because the interval doesn't go to
# infinity) while AUCall and AUClast trace their own curves.
auc.type_map <-
list(AUCinf="AUClast",
list(AUClast="AUClast",
AUCall="AUCall",
AUCinf="AUClast")[[auc.type]]
pk.calc.auc(conc=conc_interp, time=time_interp,
Expand All @@ -147,31 +147,37 @@ pk.calc.aucint <- function(conc, time, interval, start, end,
#' @describeIn pk.calc.aucint Interpolate or extrapolate concentrations
#' for AUClast
#' @export
pk.calc.aucint.last <- function(conc, time, start, end, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end), options=options, ...,
pk.calc.aucint.last <- function(conc, time, start, end, time.dose, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end), options=options,
time.dose=time.dose,
...,
auc.type="AUClast")
}
#' @describeIn pk.calc.aucint Interpolate or extrapolate concentrations
#' for AUCall
#' @export
pk.calc.aucint.all <- function(conc, time, start, end, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end), options=options, ...,
pk.calc.aucint.all <- function(conc, time, start, end, time.dose, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end), options=options,
time.dose=time.dose,
...,
auc.type="AUCall")
}
#' @describeIn pk.calc.aucint Interpolate or extrapolate concentrations
#' for AUCinf.obs
#' @export
pk.calc.aucint.inf.obs <- function(conc, time, start, end, lambda.z, clast.obs, ..., options=list()) {
pk.calc.aucint.inf.obs <- function(conc, time, start, end, time.dose, lambda.z, clast.obs, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end),
time.dose=time.dose,
lambda.z=lambda.z, clast=clast.obs,
options=options, ...,
auc.type="AUCinf")
}
#' @describeIn pk.calc.aucint Interpolate or extrapolate concentrations
#' for AUCinf.pred
#' @export
pk.calc.aucint.inf.pred <- function(conc, time, start, end, lambda.z, clast.pred, ..., options=list()) {
pk.calc.aucint.inf.pred <- function(conc, time, start, end, time.dose, lambda.z, clast.pred, ..., options=list()) {
pk.calc.aucint(conc=conc, time=time, interval=c(start, end),
time.dose=time.dose,
lambda.z=lambda.z, clast=clast.pred,
options=options, ...,
auc.type="AUCinf")
Expand All @@ -181,30 +187,30 @@ add.interval.col("aucint.last",
FUN="pk.calc.aucint.last",
values=c(FALSE, TRUE),
desc="The area under the concentration time curve in the interval extrapolating from Tlast to infinity with zeros (matching AUClast)",
formalsmap=list(conc="conc.group", time="time.group"),
formalsmap=list(conc="conc.group", time="time.group", time.dose="time.dose.group"),
depends=c())
PKNCA.set.summary("aucint.last", business.geomean, business.geocv)

add.interval.col("aucint.all",
FUN="pk.calc.aucint.all",
values=c(FALSE, TRUE),
desc="The area under the concentration time curve in the interval extrapolating from Tlast to infinity with the triangle from Tlast to the next point and zero thereafter (matching AUCall)",
formalsmap=list(conc="conc.group", time="time.group"),
formalsmap=list(conc="conc.group", time="time.group", time.dose="time.dose.group"),
depends=c())
PKNCA.set.summary("aucint.all", business.geomean, business.geocv)

add.interval.col("aucint.inf.obs",
FUN="pk.calc.aucint.inf.obs",
values=c(FALSE, TRUE),
desc="The area under the concentration time curve in the interval extrapolating from Tlast to infinity with zeros (matching AUClast)",
formalsmap=list(conc="conc.group", time="time.group"),
formalsmap=list(conc="conc.group", time="time.group", time.dose="time.dose.group"),
depends=c("lambda.z", "clast.obs"))
PKNCA.set.summary("aucint.last", business.geomean, business.geocv)

add.interval.col("aucint.inf.pred",
FUN="pk.calc.aucint.inf.pred",
values=c(FALSE, TRUE),
desc="The area under the concentration time curve in the interval extrapolating from Tlast to infinity with the triangle from Tlast to the next point and zero thereafter (matching AUCall)",
formalsmap=list(conc="conc.group", time="time.group"),
formalsmap=list(conc="conc.group", time="time.group", time.dose="time.dose.group"),
depends=c("lambda.z", "clast.pred"))
PKNCA.set.summary("aucint.all", business.geomean, business.geocv)
4 changes: 4 additions & 0 deletions R/class-PKNCAconc.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ PKNCAconc.tbl_df <- function(data, ...)
PKNCAconc.data.frame <- function(data, formula, subject,
time.nominal, exclude, duration, volume,
exclude_half.life, include_half.life, ...) {
## The data must have... data
if (nrow(data) == 0) {
stop("data must have at least one row.")
}
## Verify that all the variables in the formula are columns in the
## data.
if (!all(all.vars(formula) %in% names(data))) {
Expand Down
4 changes: 4 additions & 0 deletions R/class-PKNCAdose.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ PKNCAdose.tbl_df <- function(data, ...)
#' @export
PKNCAdose.data.frame <- function(data, formula, route, rate, duration,
time.nominal, exclude, ...) {
## The data must have... data
if (nrow(data) == 0) {
stop("data must have at least one row.")
}
## Check inputs
if (!missing(time.nominal)) {
if (!(time.nominal %in% names(data))) {
Expand Down
Loading

0 comments on commit 86a61f1

Please sign in to comment.