aboutsummaryrefslogtreecommitdiff
path: root/vignettes/web_only
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-07-08 17:39:44 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-07-08 17:39:44 +0200
commitf35e0b3d3b9f41bee2f5cc357afcb69e3aadad15 (patch)
tree675d90c517a0e8a32c7c3af8ef631a5c588503d4 /vignettes/web_only
parent16a7ed9548b37fe3c68c993651226fdc2dda6402 (diff)
Store DLL info in mkinmod objects for performance
Thanks to Tomas Kalibera for his analysis of the problem on the r-package-devel mailing list and for the suggestion on how to fix it. See the current benchmark vignette for the new data on mkin 1.1.1 with R 4.2.1, with unprecedented performance.
Diffstat (limited to 'vignettes/web_only')
-rw-r--r--vignettes/web_only/benchmarks.R112
-rw-r--r--vignettes/web_only/benchmarks.html53
-rw-r--r--vignettes/web_only/dimethenamid_2018.R152
-rw-r--r--vignettes/web_only/mkin_benchmarks.rdabin1359 -> 1419 bytes
4 files changed, 41 insertions, 276 deletions
diff --git a/vignettes/web_only/benchmarks.R b/vignettes/web_only/benchmarks.R
deleted file mode 100644
index c9ba5be3..00000000
--- a/vignettes/web_only/benchmarks.R
+++ /dev/null
@@ -1,112 +0,0 @@
-## ---- include = FALSE---------------------------------------------------------
-library(knitr)
-opts_chunk$set(tidy = FALSE, cache = FALSE)
-library("mkin")
-
-## ----include = FALSE----------------------------------------------------------
-cpu_model <- benchmarkme::get_cpu()$model_name
-# Abbreviate CPU identifiers
-cpu_model <- gsub("AMD ", "", cpu_model)
-cpu_model <- gsub("Intel\\(R\\) Core\\(TM\\) ", "", cpu_model)
-cpu_model <- gsub(" Eight-Core Processor", "", cpu_model)
-cpu_model <- gsub(" CPU @ 2.50GHz", "", cpu_model)
-
-operating_system <- Sys.info()[["sysname"]]
-mkin_version <- as.character(packageVersion("mkin"))
-R_version <- paste0(R.version$major, ".", R.version$minor)
-system_string <- paste0(operating_system, ", ", cpu_model, ", mkin ", mkin_version, ", R ", R_version)
-
-benchmark_path = normalizePath("~/git/mkin/vignettes/web_only/mkin_benchmarks.rda")
-load(benchmark_path)
-
-# Used for reformatting the data on 2022-06-30
-# mkin_benchmarks[, "R"] <- NA
-# mkin_benchmarks <- mkin_benchmarks[c(2, 1, 15, 3, 4:14)]
-# mkin_benchmarks[, "CPU"] <- gsub("AMD.*", "Ryzen 7 1700", mkin_benchmarks[, "CPU"])
-# mkin_benchmarks[, "CPU"] <- gsub("Intel.*", "i7-4710MQ", mkin_benchmarks[, "CPU"])
-# rownames(mkin_benchmarks) <- gsub("AMD Ryzen 7 1700 Eight-Core Processor", "Ryzen 7 1700", rownames(mkin_benchmarks))
-# rownames(mkin_benchmarks) <- gsub("Intel\\(R\\) Core\\(TM\\) i7-4710MQ CPU @ 2.50GHz", "i7-4710MQ", rownames(mkin_benchmarks))
-# rownames(mkin_benchmarks) <- gsub(" version", "", rownames(mkin_benchmarks))
-
-mkin_benchmarks[system_string, c("CPU", "OS", "mkin", "R")] <-
- c(cpu_model, operating_system, mkin_version, R_version)
-
-if (mkin_version > "0.9.48.1") {
- mmkin_bench <- function(models, datasets, error_model = "const") {
- mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE)
- }
-} else {
- mmkin_bench <- function(models, datasets, error_model = NULL) {
- mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE)
- }
-}
-
-## ----parent_only, warning = FALSE---------------------------------------------
-FOCUS_C <- FOCUS_2006_C
-FOCUS_D <- subset(FOCUS_2006_D, value != 0)
-parent_datasets <- list(FOCUS_C, FOCUS_D)
-
-t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets))[["elapsed"]]
-t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets,
- error_model = "tc"))[["elapsed"]]
-
-## ----one_metabolite, message = FALSE------------------------------------------
-SFO_SFO <- mkinmod(
- parent = mkinsub("SFO", "m1"),
- m1 = mkinsub("SFO"))
-FOMC_SFO <- mkinmod(
- parent = mkinsub("FOMC", "m1"),
- m1 = mkinsub("SFO"))
-DFOP_SFO <- mkinmod(
- parent = mkinsub("FOMC", "m1"),
- m1 = mkinsub("SFO"))
-t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D)))[["elapsed"]]
-t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D),
- error_model = "tc"))[["elapsed"]]
-t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D),
- error_model = "obs"))[["elapsed"]]
-
-## ----two_metabolites, message = FALSE-----------------------------------------
-m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
- M1 = mkinsub("SFO", "M2"),
- M2 = mkinsub("SFO"),
- use_of_ff = "max", quiet = TRUE)
-
-m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
- M1 = mkinsub("SFO"),
- M2 = mkinsub("SFO"),
- use_of_ff = "max", quiet = TRUE)
-
-SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
-
-DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
-
-t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))[["elapsed"]]
-t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))[["elapsed"]]
-
-t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a),
- error_model = "tc"))[["elapsed"]]
-t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c),
- error_model = "tc"))[["elapsed"]]
-
-t10 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a),
- error_model = "obs"))[["elapsed"]]
-t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c),
- error_model = "obs"))[["elapsed"]]
-
-## ----results------------------------------------------------------------------
-mkin_benchmarks[system_string, paste0("t", 1:11)] <-
- c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
-save(mkin_benchmarks, file = benchmark_path)
-# Hide rownames from kable for results section
-rownames(mkin_benchmarks) <- NULL
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(mkin_benchmarks[, c(1:4, 5:6)])
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(mkin_benchmarks[, c(1:4, 7:9)])
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(mkin_benchmarks[, c(1:4, 10:15)])
-
diff --git a/vignettes/web_only/benchmarks.html b/vignettes/web_only/benchmarks.html
index a127a7b4..9923a8fa 100644
--- a/vignettes/web_only/benchmarks.html
+++ b/vignettes/web_only/benchmarks.html
@@ -1599,7 +1599,7 @@ div.tocify {
<h1 class="title toc-ignore">Benchmark timings for mkin</h1>
<h4 class="author">Johannes Ranke</h4>
-<h4 class="date">Last change 1 July 2022 (rebuilt 2022-07-01)</h4>
+<h4 class="date">Last change 1 July 2022 (rebuilt 2022-07-08)</h4>
</div>
@@ -1775,8 +1775,8 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="left">Ryzen 7 1700</td>
<td align="left">4.2.1</td>
<td align="left">1.1.0</td>
-<td align="right">1.807</td>
-<td align="right">3.488</td>
+<td align="right">1.842</td>
+<td align="right">3.453</td>
</tr>
<tr class="odd">
<td align="left">Linux</td>
@@ -1794,6 +1794,14 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="right">1.877</td>
<td align="right">3.906</td>
</tr>
+<tr class="odd">
+<td align="left">Linux</td>
+<td align="left">i7-4710MQ</td>
+<td align="left">4.2.1</td>
+<td align="left">1.1.1</td>
+<td align="right">1.592</td>
+<td align="right">3.101</td>
+</tr>
</tbody>
</table>
</div>
@@ -1917,9 +1925,9 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="left">Ryzen 7 1700</td>
<td align="left">4.2.1</td>
<td align="left">1.1.0</td>
-<td align="right">3.788</td>
-<td align="right">19.727</td>
-<td align="right">8.846</td>
+<td align="right">3.802</td>
+<td align="right">21.247</td>
+<td align="right">8.461</td>
</tr>
<tr class="odd">
<td align="left">Linux</td>
@@ -1939,6 +1947,15 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="right">8.058</td>
<td align="right">3.339</td>
</tr>
+<tr class="odd">
+<td align="left">Linux</td>
+<td align="left">i7-4710MQ</td>
+<td align="left">4.2.1</td>
+<td align="left">1.1.1</td>
+<td align="right">1.198</td>
+<td align="right">5.740</td>
+<td align="right">2.388</td>
+</tr>
</tbody>
</table>
</div>
@@ -2098,12 +2115,12 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="left">Ryzen 7 1700</td>
<td align="left">4.2.1</td>
<td align="left">1.1.0</td>
-<td align="right">2.828</td>
-<td align="right">4.286</td>
-<td align="right">5.475</td>
-<td align="right">11.054</td>
-<td align="right">6.704</td>
-<td align="right">9.085</td>
+<td align="right">3.018</td>
+<td align="right">4.165</td>
+<td align="right">5.036</td>
+<td align="right">10.844</td>
+<td align="right">6.623</td>
+<td align="right">9.722</td>
</tr>
<tr class="odd">
<td align="left">Linux</td>
@@ -2129,6 +2146,18 @@ rownames(mkin_benchmarks) &lt;- NULL</code></pre>
<td align="right">2.302</td>
<td align="right">3.463</td>
</tr>
+<tr class="odd">
+<td align="left">Linux</td>
+<td align="left">i7-4710MQ</td>
+<td align="left">4.2.1</td>
+<td align="left">1.1.1</td>
+<td align="right">0.652</td>
+<td align="right">1.089</td>
+<td align="right">1.149</td>
+<td align="right">3.205</td>
+<td align="right">1.635</td>
+<td align="right">2.444</td>
+</tr>
</tbody>
</table>
</div>
diff --git a/vignettes/web_only/dimethenamid_2018.R b/vignettes/web_only/dimethenamid_2018.R
deleted file mode 100644
index 2554cd13..00000000
--- a/vignettes/web_only/dimethenamid_2018.R
+++ /dev/null
@@ -1,152 +0,0 @@
-## ---- include = FALSE---------------------------------------------------------
-require(knitr)
-require(mkin)
-require(nlme)
-options(digits = 5)
-opts_chunk$set(
- comment = "",
- tidy = FALSE,
- cache = TRUE
-)
-
-## ----dimethenamid_data--------------------------------------------------------
-library(mkin, quietly = TRUE)
-dmta_ds <- lapply(1:7, function(i) {
- ds_i <- dimethenamid_2018$ds[[i]]$data
- ds_i[ds_i$name == "DMTAP", "name"] <- "DMTA"
- ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
- ds_i
-})
-names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
-dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
-dmta_ds[["Elliot 1"]] <- NULL
-dmta_ds[["Elliot 2"]] <- NULL
-
-## ----f_parent_mkin------------------------------------------------------------
-f_parent_mkin_const <- mmkin(c("SFO", "DFOP"), dmta_ds,
- error_model = "const", quiet = TRUE)
-f_parent_mkin_tc <- mmkin(c("SFO", "DFOP"), dmta_ds,
- error_model = "tc", quiet = TRUE)
-
-## ----f_parent_mkin_sfo_const--------------------------------------------------
-plot(mixed(f_parent_mkin_const["SFO", ]))
-
-## ----f_parent_mkin_dfop_const-------------------------------------------------
-plot(mixed(f_parent_mkin_const["DFOP", ]))
-
-## ----f_parent_mkin_dfop_const_test--------------------------------------------
-plot(mixed(f_parent_mkin_const["DFOP", ]), test_log_parms = TRUE)
-
-## ----f_parent_mkin_dfop_tc_test-----------------------------------------------
-plot(mixed(f_parent_mkin_tc["DFOP", ]), test_log_parms = TRUE)
-
-## ----f_parent_mkin_dfop_tc_print----------------------------------------------
-print(f_parent_mkin_tc["DFOP", ])
-
-## ----f_parent_nlme, warning = FALSE-------------------------------------------
-library(nlme)
-f_parent_nlme_sfo_const <- nlme(f_parent_mkin_const["SFO", ])
-# f_parent_nlme_dfop_const <- nlme(f_parent_mkin_const["DFOP", ])
-f_parent_nlme_sfo_tc <- nlme(f_parent_mkin_tc["SFO", ])
-f_parent_nlme_dfop_tc <- nlme(f_parent_mkin_tc["DFOP", ])
-
-## ----AIC_parent_nlme----------------------------------------------------------
-anova(
- f_parent_nlme_sfo_const, f_parent_nlme_sfo_tc, f_parent_nlme_dfop_tc
-)
-
-## ----f_parent_nlme_logchol, warning = FALSE, eval = FALSE---------------------
-# f_parent_nlme_sfo_const_logchol <- nlme(f_parent_mkin_const["SFO", ],
-# random = nlme::pdLogChol(list(DMTA_0 ~ 1, log_k_DMTA ~ 1)))
-# anova(f_parent_nlme_sfo_const, f_parent_nlme_sfo_const_logchol)
-# f_parent_nlme_sfo_tc_logchol <- nlme(f_parent_mkin_tc["SFO", ],
-# random = nlme::pdLogChol(list(DMTA_0 ~ 1, log_k_DMTA ~ 1)))
-# anova(f_parent_nlme_sfo_tc, f_parent_nlme_sfo_tc_logchol)
-# f_parent_nlme_dfop_tc_logchol <- nlme(f_parent_mkin_const["DFOP", ],
-# random = nlme::pdLogChol(list(DMTA_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_qlogis ~ 1)))
-# anova(f_parent_nlme_dfop_tc, f_parent_nlme_dfop_tc_logchol)
-
-## ----plot_parent_nlme---------------------------------------------------------
-plot(f_parent_nlme_dfop_tc)
-
-## ----saemix_control, results='hide'-------------------------------------------
-library(saemix)
-saemix_control <- saemixControl(nbiter.saemix = c(800, 300), nb.chains = 15,
- print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
-saemix_control_moreiter <- saemixControl(nbiter.saemix = c(1600, 300), nb.chains = 15,
- print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
-saemix_control_10k <- saemixControl(nbiter.saemix = c(10000, 300), nb.chains = 15,
- print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
-
-## ----f_parent_saemix_sfo_const, results = 'hide', dependson = "saemix_control"----
-f_parent_saemix_sfo_const <- mkin::saem(f_parent_mkin_const["SFO", ], quiet = TRUE,
- control = saemix_control, transformations = "saemix")
-plot(f_parent_saemix_sfo_const$so, plot.type = "convergence")
-
-## ----f_parent_saemix_sfo_tc, results = 'hide', dependson = "saemix_control"----
-f_parent_saemix_sfo_tc <- mkin::saem(f_parent_mkin_tc["SFO", ], quiet = TRUE,
- control = saemix_control, transformations = "saemix")
-plot(f_parent_saemix_sfo_tc$so, plot.type = "convergence")
-
-## ----f_parent_saemix_dfop_const, results = 'show', dependson = "saemix_control"----
-f_parent_saemix_dfop_const <- mkin::saem(f_parent_mkin_const["DFOP", ], quiet = TRUE,
- control = saemix_control, transformations = "saemix")
-plot(f_parent_saemix_dfop_const$so, plot.type = "convergence")
-print(f_parent_saemix_dfop_const)
-
-## ----f_parent_saemix_dfop_tc, results = 'show', dependson = "saemix_control"----
-f_parent_saemix_dfop_tc <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
- control = saemix_control, transformations = "saemix")
-f_parent_saemix_dfop_tc_moreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
- control = saemix_control_moreiter, transformations = "saemix")
-plot(f_parent_saemix_dfop_tc$so, plot.type = "convergence")
-print(f_parent_saemix_dfop_tc)
-
-## ----AIC_parent_saemix, cache = FALSE-----------------------------------------
-AIC_parent_saemix <- saemix::compare.saemix(
- f_parent_saemix_sfo_const$so,
- f_parent_saemix_sfo_tc$so,
- f_parent_saemix_dfop_const$so,
- f_parent_saemix_dfop_tc$so,
- f_parent_saemix_dfop_tc_moreiter$so)
-rownames(AIC_parent_saemix) <- c(
- "SFO const", "SFO tc", "DFOP const", "DFOP tc", "DFOP tc more iterations")
-print(AIC_parent_saemix)
-
-## ----AIC_parent_saemix_methods, cache = FALSE---------------------------------
-f_parent_saemix_dfop_tc$so <-
- saemix::llgq.saemix(f_parent_saemix_dfop_tc$so)
-AIC_parent_saemix_methods <- c(
- is = AIC(f_parent_saemix_dfop_tc$so, method = "is"),
- gq = AIC(f_parent_saemix_dfop_tc$so, method = "gq"),
- lin = AIC(f_parent_saemix_dfop_tc$so, method = "lin")
-)
-print(AIC_parent_saemix_methods)
-
-## ----AIC_parent_saemix_methods_defaults, cache = FALSE------------------------
-f_parent_saemix_dfop_tc_defaults <- mkin::saem(f_parent_mkin_tc["DFOP", ])
-f_parent_saemix_dfop_tc_defaults$so <-
- saemix::llgq.saemix(f_parent_saemix_dfop_tc_defaults$so)
-AIC_parent_saemix_methods_defaults <- c(
- is = AIC(f_parent_saemix_dfop_tc_defaults$so, method = "is"),
- gq = AIC(f_parent_saemix_dfop_tc_defaults$so, method = "gq"),
- lin = AIC(f_parent_saemix_dfop_tc_defaults$so, method = "lin")
-)
-print(AIC_parent_saemix_methods_defaults)
-
-## ----AIC_all, cache = FALSE---------------------------------------------------
-AIC_all <- data.frame(
- check.names = FALSE,
- "Degradation model" = c("SFO", "SFO", "DFOP", "DFOP"),
- "Error model" = c("const", "tc", "const", "tc"),
- nlme = c(AIC(f_parent_nlme_sfo_const), AIC(f_parent_nlme_sfo_tc), NA, AIC(f_parent_nlme_dfop_tc)),
- saemix_lin = sapply(list(f_parent_saemix_sfo_const$so, f_parent_saemix_sfo_tc$so,
- f_parent_saemix_dfop_const$so, f_parent_saemix_dfop_tc$so), AIC, method = "lin"),
- saemix_is = sapply(list(f_parent_saemix_sfo_const$so, f_parent_saemix_sfo_tc$so,
- f_parent_saemix_dfop_const$so, f_parent_saemix_dfop_tc$so), AIC, method = "is")
-)
-kable(AIC_all)
-
-## ----sessionInfo, cache = FALSE-----------------------------------------------
-sessionInfo()
-
diff --git a/vignettes/web_only/mkin_benchmarks.rda b/vignettes/web_only/mkin_benchmarks.rda
index 18211bb9..3687ab8e 100644
--- a/vignettes/web_only/mkin_benchmarks.rda
+++ b/vignettes/web_only/mkin_benchmarks.rda
Binary files differ

Contact - Imprint