aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2014-06-26 11:36:02 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2014-06-26 11:36:02 +0200
commita7e6b9f9a0ba46f84929603296d3dd4a0cbe4787 (patch)
treecb4b810c984e8b9ea0f8f85689a2adfe88509796
parente8cf8558b7d071f800a65c3688f19d5ae400c33f (diff)
Calculate additional DT50 values for non-SFO models
-rw-r--r--ChangeLog2
-rw-r--r--R/endpoints.R22
-rw-r--r--TODO2
-rw-r--r--inst/unitTests/runit.mkinfit.R24
-rw-r--r--man/endpoints.Rd6
-rw-r--r--vignettes/FOCUS_Z.pdfbin213073 -> 213092 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_1.pdfbin5670 -> 5670 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_10.pdfbin7587 -> 7587 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_11.pdfbin7598 -> 7598 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_11b.pdfbin5021 -> 5021 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_2.pdfbin5670 -> 5670 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_3.pdfbin5670 -> 5670 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_5.pdfbin6155 -> 6155 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_6.pdfbin6966 -> 6966 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_6_ff.pdfbin6937 -> 6937 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_7.pdfbin6967 -> 6967 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_8.pdfbin6158 -> 6158 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_fits_9.pdfbin6785 -> 6785 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_residuals_11.pdfbin5940 -> 5940 bytes
-rw-r--r--vignettes/figure/FOCUS_2006_Z_residuals_6.pdfbin5959 -> 5959 bytes
-rw-r--r--vignettes/mkin.pdfbin160326 -> 160326 bytes
21 files changed, 35 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 0dab3199..b3cf00f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@
* R/mkinresplot.R: Make it possible to specify xlim
* R/geometric_mean.R, man/geometric_mean.Rd: Add geometric mean
function
+ * R/mkinfit.R, man/mkinfit.Rd: Calculate additional (pseudo)-DT50
+ values for FOMC, DFOP, HS and SFORB
2014-05-20 Johannes Ranke <jranke@uni-bremen.de> for mkin (0.9-28)
diff --git a/R/endpoints.R b/R/endpoints.R
index c9a6a51f..18d8159b 100644
--- a/R/endpoints.R
+++ b/R/endpoints.R
@@ -1,6 +1,8 @@
-endpoints <- function(fit, pseudoDT50 = FALSE) {
+endpoints <- function(fit) {
# Calculate dissipation times DT50 and DT90 and, if necessary, formation
# fractions and SFORB eigenvalues from optimised parameters
+ # Additional DT50 values are calculated from the FOMC DT90 and k1 and k2 from HS and DFOP,
+ # as well as from Eigenvalues b1 and b2 of the SFORB model
ep <- list()
obs_vars <- fit$obs_vars
parms.all <- fit$bparms.ode
@@ -40,6 +42,8 @@ endpoints <- function(fit, pseudoDT50 = FALSE) {
beta = parms.all["beta"]
DT50 = beta * (2^(1/alpha) - 1)
DT90 = beta * (10^(1/alpha) - 1)
+ DT50_back = DT90 / (log(10)/log(2)) # Backcalculated DT50 as recommended in FOCUS 2011
+ ep$distimes[obs_var, c("DT50back")] = DT50_back
}
if (type == "DFOP") {
k1 = parms.all["k1"]
@@ -54,6 +58,10 @@ endpoints <- function(fit, pseudoDT50 = FALSE) {
DT50 = ifelse(DTmax - DT50.o < 0.1, NA, DT50.o)
DT90.o <- optimize(f, c(0.001, DTmax), x=90)$minimum
DT90 = ifelse(DTmax - DT90.o < 0.1, NA, DT90.o)
+ DT50_k1 = log(2)/k1
+ DT50_k2 = log(2)/k2
+ ep$distimes[obs_var, c("DT50_k1")] = DT50_k1
+ ep$distimes[obs_var, c("DT50_k2")] = DT50_k2
}
if (type == "HS") {
k1 = parms.all["k1"]
@@ -68,6 +76,10 @@ endpoints <- function(fit, pseudoDT50 = FALSE) {
}
DT50 <- DTx(50)
DT90 <- DTx(90)
+ DT50_k1 = log(2)/k1
+ DT50_k2 = log(2)/k2
+ ep$distimes[obs_var, c("DT50_k1")] = DT50_k1
+ ep$distimes[obs_var, c("DT50_k2")] = DT50_k2
}
if (type == "SFORB") {
# FOCUS kinetics (2006), p. 60 f
@@ -98,11 +110,17 @@ endpoints <- function(fit, pseudoDT50 = FALSE) {
ep$ff[[sub("k_", "", k_out_name)]] = parms.all[[k_out_name]] / k_1output
}
+ DT50_b1 = log(2)/b1
+ DT50_b2 = log(2)/b2
+
# Return the eigenvalues for comparison with DFOP rate constants
ep$SFORB[[paste(obs_var, "b1", sep="_")]] = b1
ep$SFORB[[paste(obs_var, "b2", sep="_")]] = b2
+
+ ep$distimes[obs_var, c("DT50_b1")] = DT50_b1
+ ep$distimes[obs_var, c("DT50_b2")] = DT50_b2
}
- ep$distimes[obs_var, ] = c(DT50, DT90)
+ ep$distimes[obs_var, c("DT50", "DT90")] = c(DT50, DT90)
}
return(ep)
}
diff --git a/TODO b/TODO
index 9182ed92..27d84f69 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@ TODO for version 1.0
- Support model definitions without pathway to sink in combination with
formation fractions
- Complete the main package vignette named mkin to include a method description
-- Calculate pseudoDT50 values as recommended by FOCUS
- Improve formatting of differential equations in the summary
- Rename formation fractions during transformation and backtransformation as there is no
one to one relationship
@@ -13,4 +12,3 @@ Nice to have:
parameter is involved
- Calculate transformation only DT50 values (exclude pathways to sink) as
additional information
-- Calculate DT50 values from smaller rate constant/eigenvalue of DFOP, HS and SFORB models
diff --git a/inst/unitTests/runit.mkinfit.R b/inst/unitTests/runit.mkinfit.R
index 9a6bd722..61a0b303 100644
--- a/inst/unitTests/runit.mkinfit.R
+++ b/inst/unitTests/runit.mkinfit.R
@@ -66,7 +66,7 @@ test.FOCUS_2006_FOMC <- function()
median.A.FOMC <- as.numeric(lapply(subset(FOCUS_2006_FOMC_ref_A_to_F, dataset == "A",
c(M0, alpha, beta, DT50, DT90)), "median"))
- fit.A.FOMC.r <- as.numeric(c(fit.A.FOMC$bparms.optim, endpoints(fit.A.FOMC)$distimes))
+ fit.A.FOMC.r <- as.numeric(c(fit.A.FOMC$bparms.optim, endpoints(fit.A.FOMC)$distimes[c("DT50", "DT90")]))
dev.A.FOMC <- abs(round(100 * ((median.A.FOMC - fit.A.FOMC.r)/median.A.FOMC), digits=1))
dev.A.FOMC <- dev.A.FOMC[c(1, 4, 5)]
checkIdentical(dev.A.FOMC < 1, rep(TRUE, length(dev.A.FOMC)))
@@ -77,7 +77,7 @@ test.FOCUS_2006_FOMC <- function()
median.B.FOMC <- as.numeric(lapply(subset(FOCUS_2006_FOMC_ref_A_to_F, dataset == "B",
c(M0, alpha, beta, DT50, DT90)), "median"))
- fit.B.FOMC.r <- as.numeric(c(fit.B.FOMC$bparms.optim, endpoints(fit.B.FOMC)$distimes))
+ fit.B.FOMC.r <- as.numeric(c(fit.B.FOMC$bparms.optim, endpoints(fit.B.FOMC)$distimes[c("DT50", "DT90")]))
dev.B.FOMC <- abs(round(100 * ((median.B.FOMC - fit.B.FOMC.r)/median.B.FOMC), digits=1))
dev.B.FOMC <- dev.B.FOMC[c(1, 4, 5)]
checkIdentical(dev.B.FOMC < 1, rep(TRUE, length(dev.B.FOMC)))
@@ -88,7 +88,7 @@ test.FOCUS_2006_FOMC <- function()
median.C.FOMC <- as.numeric(lapply(subset(FOCUS_2006_FOMC_ref_A_to_F, dataset == "C",
c(M0, alpha, beta, DT50, DT90)), "median"))
- fit.C.FOMC.r <- as.numeric(c(fit.C.FOMC$bparms.optim, endpoints(fit.C.FOMC)$distimes))
+ fit.C.FOMC.r <- as.numeric(c(fit.C.FOMC$bparms.optim, endpoints(fit.C.FOMC)$distimes[c("DT50", "DT90")]))
dev.C.FOMC <- abs(round(100 * ((median.C.FOMC - fit.C.FOMC.r)/median.C.FOMC), digits=1))
dev.C.FOMC <- dev.C.FOMC[c(1, 4, 5)]
checkIdentical(dev.C.FOMC < 1, rep(TRUE, length(dev.C.FOMC)))
@@ -105,7 +105,7 @@ test.FOCUS_2006_DFOP <- function()
median.A.DFOP <- as.numeric(lapply(subset(FOCUS_2006_DFOP_ref_A_to_B, dataset == "A",
c(M0, k1, k2, f, DT50, DT90)), "median"))
- fit.A.DFOP.r <- as.numeric(c(fit.A.DFOP$bparms.optim, endpoints(fit.A.DFOP)$distimes))
+ fit.A.DFOP.r <- as.numeric(c(fit.A.DFOP$bparms.optim, endpoints(fit.A.DFOP)$distimes[c("DT50", "DT90")]))
dev.A.DFOP <- abs(round(100 * ((median.A.DFOP - fit.A.DFOP.r)/median.A.DFOP), digits=1))
# about 6.7% deviation for parameter f, the others are < 0.1%
checkIdentical(dev.A.DFOP < c(1, 1, 1, 10, 1, 1), rep(TRUE, length(dev.A.DFOP)))
@@ -116,7 +116,7 @@ test.FOCUS_2006_DFOP <- function()
median.B.DFOP <- as.numeric(lapply(subset(FOCUS_2006_DFOP_ref_A_to_B, dataset == "B",
c(M0, k1, k2, f, DT50, DT90)), "median"))
- fit.B.DFOP.r <- as.numeric(c(fit.B.DFOP$bparms.optim, endpoints(fit.B.DFOP)$distimes))
+ fit.B.DFOP.r <- as.numeric(c(fit.B.DFOP$bparms.optim, endpoints(fit.B.DFOP)$distimes[c("DT50", "DT90")]))
dev.B.DFOP <- abs(round(100 * ((median.B.DFOP - fit.B.DFOP.r)/median.B.DFOP), digits=1))
# about 0.6% deviation for parameter f, the others are <= 0.1%
checkIdentical(dev.B.DFOP < 1, rep(TRUE, length(dev.B.DFOP)))
@@ -134,7 +134,7 @@ test.FOCUS_2006_HS <- function()
median.A.HS <- as.numeric(lapply(subset(FOCUS_2006_HS_ref_A_to_F, dataset == "A",
c(M0, k1, k2, tb, DT50, DT90)), "median"))
- fit.A.HS.r <- as.numeric(c(fit.A.HS$bparms.optim, endpoints(fit.A.HS)$distimes))
+ fit.A.HS.r <- as.numeric(c(fit.A.HS$bparms.optim, endpoints(fit.A.HS)$distimes[c("DT50", "DT90")]))
dev.A.HS <- abs(round(100 * ((median.A.HS - fit.A.HS.r)/median.A.HS), digits=1))
# about 6.7% deviation for parameter f, the others are < 0.1%
checkIdentical(dev.A.HS < 1, rep(TRUE, length(dev.A.HS)))
@@ -145,7 +145,7 @@ test.FOCUS_2006_HS <- function()
median.B.HS <- as.numeric(lapply(subset(FOCUS_2006_HS_ref_A_to_F, dataset == "B",
c(M0, k1, k2, tb, DT50, DT90)), "median"))
- fit.B.HS.r <- as.numeric(c(fit.B.HS$bparms.optim, endpoints(fit.B.HS)$distimes))
+ fit.B.HS.r <- as.numeric(c(fit.B.HS$bparms.optim, endpoints(fit.B.HS)$distimes[c("DT50", "DT90")]))
dev.B.HS <- abs(round(100 * ((median.B.HS - fit.B.HS.r)/median.B.HS), digits=1))
# < 10% deviation for M0, k1, DT50 and DT90, others are problematic
dev.B.HS <- dev.B.HS[c(1, 2, 5, 6)]
@@ -157,7 +157,7 @@ test.FOCUS_2006_HS <- function()
median.C.HS <- as.numeric(lapply(subset(FOCUS_2006_HS_ref_A_to_F, dataset == "C",
c(M0, k1, k2, tb, DT50, DT90)), "median"))
- fit.A.HS.r <- as.numeric(c(fit.A.HS$bparms.optim, endpoints(fit.A.HS)$distimes))
+ fit.A.HS.r <- as.numeric(c(fit.A.HS$bparms.optim, endpoints(fit.A.HS)$distimes[c("DT50", "DT90")]))
dev.A.HS <- abs(round(100 * ((median.A.HS - fit.A.HS.r)/median.A.HS), digits=1))
# deviation <= 0.1%
checkIdentical(dev.A.HS < 1, rep(TRUE, length(dev.A.HS)))
@@ -179,7 +179,7 @@ test.FOCUS_2006_SFORB <- function()
parent_0 = fit.A.SFORB.1$bparms.optim[[1]],
k1 = endpoints(fit.A.SFORB.1)$SFORB[[1]],
k2 = endpoints(fit.A.SFORB.1)$SFORB[[2]],
- endpoints(fit.A.SFORB.1)$distimes))
+ endpoints(fit.A.SFORB.1)$distimes[c("DT50", "DT90")]))
dev.A.SFORB.1 <- abs(round(100 * ((median.A.SFORB - fit.A.SFORB.1.r)/median.A.SFORB), digits=1))
# The first Eigenvalue is a lot different from k1 in the DFOP fit
# The explanation is that the dataset is simply SFO
@@ -190,7 +190,7 @@ test.FOCUS_2006_SFORB <- function()
parent_0 = fit.A.SFORB.2$bparms.optim[[1]],
k1 = endpoints(fit.A.SFORB.2)$SFORB[[1]],
k2 = endpoints(fit.A.SFORB.2)$SFORB[[2]],
- endpoints(fit.A.SFORB.2)$distimes))
+ endpoints(fit.A.SFORB.2)$distimes[c("DT50", "DT90")]))
dev.A.SFORB.2 <- abs(round(100 * ((median.A.SFORB - fit.A.SFORB.2.r)/median.A.SFORB), digits=1))
# The first Eigenvalue is a lot different from k1 in the DFOP fit
# The explanation is that the dataset is simply SFO
@@ -208,7 +208,7 @@ test.FOCUS_2006_SFORB <- function()
parent_0 = fit.B.SFORB.1$bparms.optim[[1]],
k1 = endpoints(fit.B.SFORB.1)$SFORB[[1]],
k2 = endpoints(fit.B.SFORB.1)$SFORB[[2]],
- endpoints(fit.B.SFORB.1)$distimes))
+ endpoints(fit.B.SFORB.1)$distimes[c("DT50", "DT90")]))
dev.B.SFORB.1 <- abs(round(100 * ((median.B.SFORB - fit.B.SFORB.1.r)/median.B.SFORB), digits=1))
checkIdentical(dev.B.SFORB.1 < 1, rep(TRUE, length(dev.B.SFORB.1)))
@@ -216,7 +216,7 @@ test.FOCUS_2006_SFORB <- function()
parent_0 = fit.B.SFORB.2$bparms.optim[[1]],
k1 = endpoints(fit.B.SFORB.2)$SFORB[[1]],
k2 = endpoints(fit.B.SFORB.2)$SFORB[[2]],
- endpoints(fit.B.SFORB.2)$distimes))
+ endpoints(fit.B.SFORB.2)$distimes[c("DT50", "DT90")]))
dev.B.SFORB.2 <- abs(round(100 * ((median.B.SFORB - fit.B.SFORB.2.r)/median.B.SFORB), digits=1))
checkIdentical(dev.B.SFORB.2 < 1, rep(TRUE, length(dev.B.SFORB.2)))
} # }}}
diff --git a/man/endpoints.Rd b/man/endpoints.Rd
index 21316cf2..0a8fd401 100644
--- a/man/endpoints.Rd
+++ b/man/endpoints.Rd
@@ -15,11 +15,7 @@ endpoints(fit, pseudoDT50 = FALSE)
\arguments{
\item{fit}{
An object of class \code{\link{mkinfit}}.
-}
- \item{pseudoDT50}{
- Should pseudoDT50 values for FOMC, DFOP and SFORB models be reported, as
- recommended by the FOCUS group? Currently not implemented.
-}
+ }
}
\note{
The function is used internally by \code{\link{summary.mkinfit}}.
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 41ee12ed..f99fd192 100644
--- a/vignettes/FOCUS_Z.pdf
+++ b/vignettes/FOCUS_Z.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_1.pdf b/vignettes/figure/FOCUS_2006_Z_fits_1.pdf
index caabcced..3aac23ca 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_1.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_1.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_10.pdf b/vignettes/figure/FOCUS_2006_Z_fits_10.pdf
index 71df4e2c..ec4d4127 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_10.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_10.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_11.pdf b/vignettes/figure/FOCUS_2006_Z_fits_11.pdf
index cace9970..8b544c5c 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_11.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_11.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_11b.pdf b/vignettes/figure/FOCUS_2006_Z_fits_11b.pdf
index 19365bcc..4bf4bf5d 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_11b.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_11b.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_2.pdf b/vignettes/figure/FOCUS_2006_Z_fits_2.pdf
index 149422f5..c65df21c 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_2.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_2.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_3.pdf b/vignettes/figure/FOCUS_2006_Z_fits_3.pdf
index 149422f5..633b3d24 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_3.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_3.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_5.pdf b/vignettes/figure/FOCUS_2006_Z_fits_5.pdf
index 963bcb79..6b5a5783 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_5.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_5.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_6.pdf b/vignettes/figure/FOCUS_2006_Z_fits_6.pdf
index daf2e647..936ce669 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_6.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_6.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_6_ff.pdf b/vignettes/figure/FOCUS_2006_Z_fits_6_ff.pdf
index 7a619ad7..09ea4bbf 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_6_ff.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_6_ff.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_7.pdf b/vignettes/figure/FOCUS_2006_Z_fits_7.pdf
index e41ca0cc..25ea0c33 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_7.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_7.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_8.pdf b/vignettes/figure/FOCUS_2006_Z_fits_8.pdf
index 42a4987f..f774c31a 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_8.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_8.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_fits_9.pdf b/vignettes/figure/FOCUS_2006_Z_fits_9.pdf
index 391deb5c..c8498086 100644
--- a/vignettes/figure/FOCUS_2006_Z_fits_9.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_fits_9.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_residuals_11.pdf b/vignettes/figure/FOCUS_2006_Z_residuals_11.pdf
index 50af3f41..cf228c0a 100644
--- a/vignettes/figure/FOCUS_2006_Z_residuals_11.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_residuals_11.pdf
Binary files differ
diff --git a/vignettes/figure/FOCUS_2006_Z_residuals_6.pdf b/vignettes/figure/FOCUS_2006_Z_residuals_6.pdf
index ced69fb8..d7a55683 100644
--- a/vignettes/figure/FOCUS_2006_Z_residuals_6.pdf
+++ b/vignettes/figure/FOCUS_2006_Z_residuals_6.pdf
Binary files differ
diff --git a/vignettes/mkin.pdf b/vignettes/mkin.pdf
index ce81853c..2ed718f5 100644
--- a/vignettes/mkin.pdf
+++ b/vignettes/mkin.pdf
Binary files differ

Contact - Imprint