From 19997986f7ee5b6274c9a06796b97a5610c4f888 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 26 Jun 2015 14:52:22 +0200 Subject: Pass R CMD check --as-cran, vignette rebuild --- GNUmakefile | 4 +- check.log | 2 +- man/Extract.mmkin.Rd | 3 +- man/plot.mmkin.Rd | 6 ++- vignettes/FOCUS_D.html | 23 ++++++---- vignettes/FOCUS_L.html | 93 ++++++++++++++++++++++------------------- vignettes/FOCUS_Z.pdf | Bin 225020 -> 226105 bytes vignettes/compiled_models.html | 47 +++++++++++---------- vignettes/mkin.pdf | Bin 160260 -> 160260 bytes 9 files changed, 98 insertions(+), 80 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 19658a85..df31abf5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -34,7 +34,7 @@ all: build README.md: README.Rmd "$(RBIN)/Rscript" -e 'require(knitr); knit("README.Rmd")' -$(TGZ): $(pkgfiles) vignettes/*.html vignettes/*.pdf +$(TGZ): $(pkgfiles) quickinstall vignettes cd ..;\ "$(RBIN)/R" CMD build $(PKGSRC) 2>&1 | tee $(PKGNAME)/build.log @@ -82,7 +82,7 @@ vignettes/%.pdf: vignettes/header.tex vignettes/references.bib vignettes/%.Rnw vignettes/%.html: vignettes/mkin_vignettes.css vignettes/%.Rmd "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/$*.Rmd', dir = 'vignettes')" -vignettes: quickinstall vignettes/mkin.pdf vignettes/FOCUS_D.html vignettes/FOCUS_L.html vignettes/FOCUS_Z.pdf vignettes/compiled_models.html +vignettes: vignettes/mkin.pdf vignettes/FOCUS_D.html vignettes/FOCUS_L.html vignettes/FOCUS_Z.pdf vignettes/compiled_models.html sd: rm -rf $(SDDIR)/* diff --git a/check.log b/check.log index 593d6c53..36d22b0d 100644 --- a/check.log +++ b/check.log @@ -10,7 +10,7 @@ * checking CRAN incoming feasibility ... NOTE Maintainer: ‘Johannes Ranke ’ -Days since last update: 0 +Days since last update: 3 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK diff --git a/man/Extract.mmkin.Rd b/man/Extract.mmkin.Rd index 769f2f5a..361da3e4 100644 --- a/man/Extract.mmkin.Rd +++ b/man/Extract.mmkin.Rd @@ -26,7 +26,8 @@ Johannes Ranke } \examples{ - fits <- mmkin(c("SFO", "FOMC"), list(B = FOCUS_2006_B, C = FOCUS_2006_C)) + # Only use one core so we pass R CMD check + fits <- mmkin(c("SFO", "FOMC"), list(B = FOCUS_2006_B, C = FOCUS_2006_C), cores = 1) fits["FOMC", ] fits[, "B"] fits[, "B", drop = TRUE]$FOMC diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd index a715fdea..696b3d06 100644 --- a/man/plot.mmkin.Rd +++ b/man/plot.mmkin.Rd @@ -10,7 +10,7 @@ } \usage{ \method{plot}{mmkin}(x, main = "auto", legends = 1, errmin_var = "All data", errmin_digits = 2, - cex = 0.7, rel.height.middle = 0.9, ...) + cex = 0.7, rel.height.middle = 0.9, ...) } \arguments{ \item{x}{ @@ -45,7 +45,9 @@ Johannes Ranke } \examples{ - fits <- mmkin(c("SFO", "FOMC", "HS"), list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C)) + # Only use one core not to offend CRAN checks + fits <- mmkin(c("FOMC", "HS"), list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), + cores = 1) plot(fits[, "FOCUS C"]) plot(fits["FOMC", ]) } diff --git a/vignettes/FOCUS_D.html b/vignettes/FOCUS_D.html index 01d5d4f3..e8ab70de 100644 --- a/vignettes/FOCUS_D.html +++ b/vignettes/FOCUS_D.html @@ -10,7 +10,7 @@ - + Example evaluation of FOCUS Example Dataset D @@ -64,13 +64,18 @@ img {

This is just a very simple vignette showing how to fit a degradation model for a parent compound with one transformation product using mkin. After loading the library we look a the data. We have observed concentrations in the column named value at the times specified in column time for the two observed variables named parent and m1.

-
library("mkin")
-print(FOCUS_2006_D)
+
library("mkin")
+
## Loading required package: minpack.lm
+## Loading required package: rootSolve
+## Loading required package: inline
+## Loading required package: methods
+## Loading required package: parallel
+
print(FOCUS_2006_D)
##      name time  value
 ## 1  parent    0  99.46
 ## 2  parent    0 102.04
@@ -132,13 +137,13 @@ print(FOCUS_2006_D)

Confidence intervals for the parameter estimates are obtained using the mkinparplot function.

mkinparplot(fit)
-

+

A comprehensive report of the results is obtained using the summary method for mkinfit objects.

summary(fit)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:13 2015 
-## Date of summary: Tue Jun 23 15:18:14 2015 
+## Date of fit:     Fri Jun 26 14:41:39 2015 
+## Date of summary: Fri Jun 26 14:41:40 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent - k_parent_m1 * parent
@@ -146,7 +151,7 @@ print(FOCUS_2006_D)
## ## Model predictions using solution type deSolve ## -## Fitted with method Port using 153 model solutions performed in 0.749 s +## Fitted with method Port using 153 model solutions performed in 0.629 s ## ## Weighting: none ## diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html index 095c0ec0..7e0ef4dd 100644 --- a/vignettes/FOCUS_L.html +++ b/vignettes/FOCUS_L.html @@ -10,7 +10,7 @@ - + Example evaluation of FOCUS Laboratory Data L1 to L3 @@ -65,7 +65,7 @@ img {
@@ -80,8 +80,13 @@ img {

Laboratory Data L1

The following code defines example dataset L1 from the FOCUS kinetics report, p. 284:

-
library("mkin")
-FOCUS_2006_L1 = data.frame(
+
library("mkin")
+
## Loading required package: minpack.lm
+## Loading required package: rootSolve
+## Loading required package: inline
+## Loading required package: methods
+## Loading required package: parallel
+
FOCUS_2006_L1 = data.frame(
   t = rep(c(0, 1, 2, 3, 5, 7, 14, 21, 30), each = 2),
   parent = c(88.3, 91.4, 85.6, 84.5, 78.9, 77.6, 
              72.0, 71.9, 50.3, 59.4, 47.0, 45.1,
@@ -91,17 +96,17 @@ FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1)

Since mkin version 0.9-32 (July 2014), we can use shorthand notation like SFO for parent only degradation models. The following two lines fit the model and produce the summary report of the model fit. This covers the numerical analysis given in the FOCUS report.

m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet=TRUE)
 summary(m.L1.SFO)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:14 2015 
-## Date of summary: Tue Jun 23 15:18:14 2015 
+## Date of fit:     Fri Jun 26 14:41:41 2015 
+## Date of summary: Fri Jun 26 14:41:41 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.101 s
+## Fitted with method Port using 37 model solutions performed in 0.08 s
 ## 
 ## Weighting: none
 ## 
@@ -181,10 +186,10 @@ summary(m.L1.SFO)
## Warning in mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet = TRUE): Optimisation by method Port did not converge.
 ## Convergence code is 1
summary(m.L1.FOMC, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:15 2015 
-## Date of summary: Tue Jun 23 15:18:15 2015 
+## Date of fit:     Fri Jun 26 14:41:41 2015 
+## Date of summary: Fri Jun 26 14:41:41 2015 
 ## 
 ## 
 ## Warning: Optimisation by method Port did not converge.
@@ -196,7 +201,7 @@ summary(m.L1.SFO)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 188 model solutions performed in 0.484 s +## Fitted with method Port using 188 model solutions performed in 0.397 s ## ## Weighting: none ## @@ -261,17 +266,17 @@ FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2)

Again, the SFO model is fitted and a summary is obtained:

m.L2.SFO <- mkinfit("SFO", FOCUS_2006_L2_mkin, quiet=TRUE)
 summary(m.L2.SFO)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:15 2015 
-## Date of summary: Tue Jun 23 15:18:15 2015 
+## Date of fit:     Fri Jun 26 14:41:42 2015 
+## Date of summary: Fri Jun 26 14:41:42 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 41 model solutions performed in 0.109 s
+## Fitted with method Port using 41 model solutions performed in 0.087 s
 ## 
 ## Weighting: none
 ## 
@@ -349,17 +354,17 @@ plot(m.L2.FOMC)
 mkinresplot(m.L2.FOMC)

summary(m.L2.FOMC, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:16 2015 
-## Date of summary: Tue Jun 23 15:18:16 2015 
+## Date of fit:     Fri Jun 26 14:41:42 2015 
+## Date of summary: Fri Jun 26 14:41:42 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.227 s
+## Fitted with method Port using 81 model solutions performed in 0.175 s
 ## 
 ## Weighting: none
 ## 
@@ -421,10 +426,10 @@ plot(m.L2.DFOP)
plot(m.L2.DFOP)

summary(m.L2.DFOP, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:18 2015 
-## Date of summary: Tue Jun 23 15:18:18 2015 
+## Date of fit:     Fri Jun 26 14:41:44 2015 
+## Date of summary: Fri Jun 26 14:41:44 2015 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -433,7 +438,7 @@ plot(m.L2.DFOP)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 336 model solutions performed in 0.93 s +## Fitted with method Port using 336 model solutions performed in 0.744 s ## ## Weighting: none ## @@ -498,17 +503,17 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3)
plot(m.L3.SFO)

summary(m.L3.SFO)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:19 2015 
-## Date of summary: Tue Jun 23 15:18:19 2015 
+## Date of fit:     Fri Jun 26 14:41:44 2015 
+## Date of summary: Fri Jun 26 14:41:44 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 43 model solutions performed in 0.111 s
+## Fitted with method Port using 43 model solutions performed in 0.087 s
 ## 
 ## Weighting: none
 ## 
@@ -574,17 +579,17 @@ plot(m.L3.SFO)
plot(m.L3.FOMC)

summary(m.L3.FOMC, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:19 2015 
-## Date of summary: Tue Jun 23 15:18:19 2015 
+## Date of fit:     Fri Jun 26 14:41:44 2015 
+## Date of summary: Fri Jun 26 14:41:44 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 83 model solutions performed in 0.213 s
+## Fitted with method Port using 83 model solutions performed in 0.178 s
 ## 
 ## Weighting: none
 ## 
@@ -640,10 +645,10 @@ plot(m.L3.FOMC)
plot(m.L3.DFOP)

summary(m.L3.DFOP, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:20 2015 
-## Date of summary: Tue Jun 23 15:18:20 2015 
+## Date of fit:     Fri Jun 26 14:41:45 2015 
+## Date of summary: Fri Jun 26 14:41:45 2015 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -652,7 +657,7 @@ plot(m.L3.DFOP)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 137 model solutions performed in 0.348 s +## Fitted with method Port using 137 model solutions performed in 0.287 s ## ## Weighting: none ## @@ -722,17 +727,17 @@ FOCUS_2006_L4_mkin <- mkin_wide_to_long(FOCUS_2006_L4)
plot(m.L4.SFO)

summary(m.L4.SFO, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:20 2015 
-## Date of summary: Tue Jun 23 15:18:20 2015 
+## Date of fit:     Fri Jun 26 14:41:45 2015 
+## Date of summary: Fri Jun 26 14:41:45 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.115 s
+## Fitted with method Port using 46 model solutions performed in 0.097 s
 ## 
 ## Weighting: none
 ## 
@@ -787,17 +792,17 @@ plot(m.L4.SFO)
plot(m.L4.FOMC)

summary(m.L4.FOMC, data = FALSE)
-
## mkin version:    0.9.38 
+
## mkin version:    0.9.39 
 ## R version:       3.2.1 
-## Date of fit:     Tue Jun 23 15:18:20 2015 
-## Date of summary: Tue Jun 23 15:18:20 2015 
+## Date of fit:     Fri Jun 26 14:41:45 2015 
+## Date of summary: Fri Jun 26 14:41:45 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.169 s
+## Fitted with method Port using 66 model solutions performed in 0.143 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 146e9b23..d03b7e01 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html
index 8d4c36a4..12454559 100644
--- a/vignettes/compiled_models.html
+++ b/vignettes/compiled_models.html
@@ -10,7 +10,7 @@
 
 
 
-
+
 
 Performance benefit by using compiled model definitions in mkin
 
@@ -65,7 +65,7 @@ img {
 
 
 
@@ -82,8 +82,13 @@ img {
##            gcc 
 ## "/usr/bin/gcc"

First, we build a simple degradation model for a parent compound with one metabolite.

-
library("mkin")
-SFO_SFO <- mkinmod(
+
library("mkin")
+
## Loading required package: minpack.lm
+## Loading required package: rootSolve
+## Loading required package: inline
+## Loading required package: methods
+## Loading required package: parallel
+
SFO_SFO <- mkinmod(
   parent = mkinsub("SFO", "m1"),
   m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
@@ -99,18 +104,18 @@ smb.1 <- summary(mb.1)[-1] rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "deSolve, compiled") print(smb.1)
##                             min        lq      mean    median        uq
-## deSolve, not compiled 6555.9044 6654.5464 6693.6732 6753.1885 6762.5577
-## Eigenvalue based       941.4496  949.4094  972.3045  957.3693  987.7320
-## deSolve, compiled      743.6684  756.3411  761.1512  769.0139  769.8926
+## deSolve, not compiled 5292.0165 5313.7620 5364.5733 5335.5075 5400.8517
+## Eigenvalue based       893.9459  921.1984  936.1750  948.4509  957.2895
+## deSolve, compiled      742.7723  745.4243  750.1963  748.0763  753.9083
 ##                             max neval
-## deSolve, not compiled 6771.9268     3
-## Eigenvalue based      1018.0946     3
-## deSolve, compiled      770.7713     3
-

We see that using the compiled model is by a factor of 8.8 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:

+## deSolve, not compiled 5466.1959 3 +## Eigenvalue based 966.1282 3 +## deSolve, compiled 759.7404 3
+

We see that using the compiled model is by a factor of 7.1 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:

smb.1["median"]/smb.1["deSolve, compiled", "median"]
##                         median
-## deSolve, not compiled 8.781621
-## Eigenvalue based      1.244931
+## deSolve, not compiled 7.132304
+## Eigenvalue based      1.267853
 ## deSolve, compiled     1.000000
@@ -128,17 +133,17 @@ smb.2 <- summary(mb.2)[-1] rownames(smb.2) <- c("deSolve, not compiled", "deSolve, compiled") print(smb.2)
##                             min        lq      mean    median        uq
-## deSolve, not compiled 14.202106 14.342265 14.430352 14.482424 14.544475
-## deSolve, compiled      1.363102  1.367979  1.377016  1.372857  1.383973
+## deSolve, not compiled 11.277340 11.336373 11.392883 11.395407 11.450654
+## deSolve, compiled      1.339204  1.342662  1.350783  1.346121  1.356573
 ##                             max neval
-## deSolve, not compiled 14.606526     3
-## deSolve, compiled      1.395088     3
+## deSolve, not compiled 11.505901 3 +## deSolve, compiled 1.367025 3
smb.2["median"]/smb.2["deSolve, compiled", "median"]
##                         median
-## deSolve, not compiled 10.54912
-## deSolve, compiled      1.00000
-

Here we get a performance benefit of a factor of 10.5 using the version of the differential equation model compiled from C code using the inline package!

-

This vignette was built with mkin 0.9.38 on

+## deSolve, not compiled 8.465368 +## deSolve, compiled 1.000000 +

Here we get a performance benefit of a factor of 8.5 using the version of the differential equation model compiled from C code using the inline package!

+

This vignette was built with mkin 0.9.39 on

## R version 3.2.1 (2015-06-18)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
 ## Running under: Debian GNU/Linux 8 (jessie)
diff --git a/vignettes/mkin.pdf b/vignettes/mkin.pdf index 88566e24..be82f41f 100644 Binary files a/vignettes/mkin.pdf and b/vignettes/mkin.pdf differ -- cgit v1.2.1