From 70d158c4dd919f4f77bc12f8ace333d29d249b79 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 14 Sep 2018 16:57:17 +0200 Subject: Remove two vignettes from the package but not from docs - Rebuild static documentation - Adapt test to new approach to two component error model where the model is inadequate --- docs/articles/web_only/FOCUS_Z.html | 332 +++++++++++++++++++++ .../figure-html/FOCUS_2006_Z_fits_1-1.png | Bin 0 -> 86312 bytes .../figure-html/FOCUS_2006_Z_fits_10-1.png | Bin 0 -> 129920 bytes .../figure-html/FOCUS_2006_Z_fits_11-1.png | Bin 0 -> 129452 bytes .../figure-html/FOCUS_2006_Z_fits_11a-1.png | Bin 0 -> 97933 bytes .../figure-html/FOCUS_2006_Z_fits_11b-1.png | Bin 0 -> 22321 bytes .../figure-html/FOCUS_2006_Z_fits_2-1.png | Bin 0 -> 86923 bytes .../figure-html/FOCUS_2006_Z_fits_3-1.png | Bin 0 -> 86529 bytes .../figure-html/FOCUS_2006_Z_fits_5-1.png | Bin 0 -> 102872 bytes .../figure-html/FOCUS_2006_Z_fits_6-1.png | Bin 0 -> 130096 bytes .../figure-html/FOCUS_2006_Z_fits_7-1.png | Bin 0 -> 130164 bytes .../figure-html/FOCUS_2006_Z_fits_9-1.png | Bin 0 -> 109280 bytes docs/articles/web_only/compiled_models.html | 201 +++++++++++++ 13 files changed, 533 insertions(+) create mode 100644 docs/articles/web_only/FOCUS_Z.html create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png create mode 100644 docs/articles/web_only/compiled_models.html (limited to 'docs/articles/web_only') diff --git a/docs/articles/web_only/FOCUS_Z.html b/docs/articles/web_only/FOCUS_Z.html new file mode 100644 index 00000000..381c9e4f --- /dev/null +++ b/docs/articles/web_only/FOCUS_Z.html @@ -0,0 +1,332 @@ + + + + + + + +Example evaluation of FOCUS dataset Z • mkin + + + + + + + + + +
+
+ + + +
+
+ + + + +

Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
Privatdozent at the University of Bremen

+ +
+

+Parent and one metabolite

+

The next step is to set up the models used for the kinetic analysis. As the simultaneous fit of parent and the first metabolite is usually straightforward, Step 1 (SFO for parent only) is skipped here. We start with the model 2a, with formation and decline of metabolite Z1 and the pathway from parent directly to sink included (default in mkin).

+
Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
+                Z1 = mkinsub("SFO"))
+
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.2a)
+

+ +
##             Estimate se_notrans    t value     Pr(>t) Lower Upper
+## Z0_0      9.7015e+01   3.553140 2.7304e+01 1.6793e-21    NA    NA
+## k_Z0_sink 1.2790e-11   0.226895 5.6368e-11 5.0000e-01    NA    NA
+## k_Z0_Z1   2.2360e+00   0.165073 1.3546e+01 7.3938e-14    NA    NA
+## k_Z1_sink 4.8212e-01   0.065854 7.3212e+00 3.5520e-08    NA    NA
+

As obvious from the parameter summary (the component of the summary), the kinetic rate constant from parent compound Z to sink is very small and the t-test for this parameter suggests that it is not significantly different from zero. This suggests, in agreement with the analysis in the FOCUS kinetics report, to simplify the model by removing the pathway to sink.

+

A similar result can be obtained when formation fractions are used in the model formulation:

+ +
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.2a.ff)
+

+ +
##            Estimate se_notrans t value     Pr(>t) Lower Upper
+## Z0_0       97.01488   3.553145 27.3039 1.6793e-21    NA    NA
+## k_Z0        2.23601   0.216849 10.3114 3.6623e-11    NA    NA
+## k_Z1        0.48212   0.065854  7.3211 3.5520e-08    NA    NA
+## f_Z0_to_Z1  1.00000   0.101473  9.8548 9.7068e-11    NA    NA
+

Here, the ilr transformed formation fraction fitted in the model takes a very large value, and the backtransformed formation fraction from parent Z to Z1 is practically unity. Here, the covariance matrix used for the calculation of confidence intervals is not returned as the model is overparameterised.

+

A simplified model is obtained by removing the pathway to the sink.

+

In the following, we use the parameterisation with formation fractions in order to be able to compare with the results in the FOCUS guidance, and as it makes it easier to use parameters obtained in a previous fit when adding a further metabolite.

+
Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+               Z1 = mkinsub("SFO"), use_of_ff = "max")
+
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.3)
+

+ +
##      Estimate se_notrans t value     Pr(>t)    Lower   Upper
+## Z0_0 97.01488   2.681772  36.176 2.3636e-25 91.52152 102.508
+## k_Z0  2.23601   0.146861  15.225 2.2464e-15  1.95453   2.558
+## k_Z1  0.48212   0.042687  11.294 3.0686e-12  0.40216   0.578
+

As there is only one transformation product for Z0 and no pathway to sink, the formation fraction is internally fixed to unity.

+
+
+

+Metabolites Z2 and Z3

+

As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as well in the next step. While this step appears questionable on the basis of the above results, it is followed here for the purpose of comparison. Also, in the FOCUS report, it is assumed that there is additional empirical evidence that Z1 quickly and exclusively hydrolyses to Z2.

+
Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+               Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+               Z2 = mkinsub("SFO"), use_of_ff = "max")
+
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.5)
+

+

Finally, metabolite Z3 is added to the model. We use the optimised differential equation parameter values from the previous fit in order to accelerate the optimization.

+
Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+                   Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                   Z2 = mkinsub("SFO", "Z3"),
+                   Z3 = mkinsub("SFO"),
+                   use_of_ff = "max")
+
## Successfully compiled differential equation model from auto-generated C code.
+ +
## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, : Optimisation by method Port did not converge:
+## false convergence (8)
+
plot_sep(m.Z.FOCUS)
+

+ +
##             Estimate se_notrans t value     Pr(>t)     Lower      Upper
+## Z0_0       96.837112   2.058861 47.0343 5.5877e-44 92.703779 100.970445
+## k_Z0        2.215368   0.118098 18.7587 7.6563e-25  1.990525   2.465609
+## k_Z1        0.478302   0.029289 16.3302 3.3408e-22  0.422977   0.540864
+## k_Z2        0.451617   0.044214 10.2144 3.1133e-14  0.371034   0.549702
+## k_Z3        0.058693   0.014296  4.1056 7.2924e-05  0.035994   0.095705
+## f_Z2_to_Z3  0.471516   0.057057  8.2639 2.8156e-11  0.360381   0.585548
+
endpoints(m.Z.FOCUS)
+
## $ff
+##   Z2_Z3 Z2_sink 
+## 0.47152 0.52848 
+## 
+## $SFORB
+## logical(0)
+## 
+## $distimes
+##        DT50    DT90
+## Z0  0.31288  1.0394
+## Z1  1.44918  4.8141
+## Z2  1.53481  5.0985
+## Z3 11.80973 39.2311
+

This fit corresponds to the final result chosen in Appendix 7 of the FOCUS report. Confidence intervals returned by mkin are based on internally transformed parameters, however.

+
+
+

+Using the SFORB model

+

As the FOCUS report states, there is a certain tailing of the time course of metabolite Z3. Also, the time course of the parent compound is not fitted very well using the SFO model, as residues at a certain low level remain.

+

Therefore, an additional model is offered here, using the single first-order reversible binding (SFORB) model for metabolite Z3. As expected, the \(\chi^2\) error level is lower for metabolite Z3 using this model and the graphical fit for Z3 is improved. However, the covariance matrix is not returned.

+
Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFORB"))
+
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.mkin.1)
+

+ +
## NULL
+

Therefore, a further stepwise model building is performed starting from the stage of parent and two metabolites, starting from the assumption that the model fit for the parent compound can be improved by using the SFORB model.

+
Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO"))
+
## Successfully compiled differential equation model from auto-generated C code.
+
m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.mkin.3)
+

+

This results in a much better representation of the behaviour of the parent compound Z0.

+

Finally, Z3 is added as well. These models appear overparameterised (no covariance matrix returned) if the sink for Z1 is left in the models.

+
Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFO"))
+
## Successfully compiled differential equation model from auto-generated C code.
+ +

+

The error level of the fit, but especially of metabolite Z3, can be improved if the SFORB model is chosen for this metabolite, as this model is capable of representing the tailing of the metabolite decline phase.

+
Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFORB"))
+
## Successfully compiled differential equation model from auto-generated C code.
+ +

+

The summary view of the backtransformed parameters shows that we get no confidence intervals due to overparameterisation. As the optimized is excessively small, it seems reasonable to fix it to zero.

+ +

+

As expected, the residual plots for Z0 and Z3 are more random than in the case of the all SFO model for which they were shown above. In conclusion, the model is proposed as the best-fit model for the dataset from Appendix 7 of the FOCUS report.

+

A graphical representation of the confidence intervals can finally be obtained.

+
mkinparplot(m.Z.mkin.5a)
+

+

The endpoints obtained with this model are

+
endpoints(m.Z.mkin.5a)
+
## $ff
+##   Z0_free_Z1        Z1_Z2      Z2_sink   Z2_Z3_free Z3_free_sink 
+##      1.00000      1.00000      0.46344      0.53656      1.00000 
+## 
+## $SFORB
+##     Z0_b1     Z0_b2     Z3_b1     Z3_b2 
+## 2.4471382 0.0075127 0.0800075 0.0000000 
+## 
+## $distimes
+##      DT50   DT90 DT50_Z0_b1 DT50_Z0_b2 DT50_Z3_b1 DT50_Z3_b2
+## Z0 0.3043 1.1848    0.28325     92.264         NA         NA
+## Z1 1.5148 5.0320         NA         NA         NA         NA
+## Z2 1.6414 5.4526         NA         NA         NA         NA
+## Z3     NA     NA         NA         NA     8.6635        Inf
+

It is clear the degradation rate of Z3 towards the end of the experiment is very low as DT50_Z3_b2 (the second Eigenvalue of the system of two differential equations representing the SFORB system for Z3, corresponding to the slower rate constant of the DFOP model) is reported to be infinity. However, this appears to be a feature of the data.

+
+
+

+References

+ +
+
+

FOCUS Work Group on Degradation Kinetics. 2014. Generic Guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in Eu Registration. 1.1 ed. http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics.

+
+
+
+
+ + + +
+ + +
+ +
+

Site built with pkgdown.

+
+ +
+
+ + + + + diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png new file mode 100644 index 00000000..53f2ce85 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png new file mode 100644 index 00000000..90eab945 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png new file mode 100644 index 00000000..f44737ad Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png new file mode 100644 index 00000000..98562168 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png new file mode 100644 index 00000000..27e7eb52 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png new file mode 100644 index 00000000..236cdbfe Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png new file mode 100644 index 00000000..693c9c2c Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png new file mode 100644 index 00000000..180f44f9 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png new file mode 100644 index 00000000..a67e9c1d Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png new file mode 100644 index 00000000..80452f9f Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png new file mode 100644 index 00000000..e6ce97cd Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png differ diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html new file mode 100644 index 00000000..e941bea3 --- /dev/null +++ b/docs/articles/web_only/compiled_models.html @@ -0,0 +1,201 @@ + + + + + + + +Performance benefit by using compiled model definitions in mkin • mkin + + + + + + + + + +
+
+ + + +
+
+ + + + +
+

+Model that can also be solved with Eigenvalues

+

This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The mkinmod() function checks for presence of the gcc compiler using

+ +
##            gcc 
+## "/usr/bin/gcc"
+

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

+ +
## Successfully compiled differential equation model from auto-generated C code.
+

We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package.

+ +
## Lade nötiges Paket: rbenchmark
+
##                    test replications elapsed relative user.self sys.self
+## 3     deSolve, compiled            3   2.120    1.000     2.118    0.000
+## 1 deSolve, not compiled            3  17.195    8.111    17.187    0.000
+## 2      Eigenvalue based            3   2.589    1.221     2.582    0.004
+##   user.child sys.child
+## 3          0         0
+## 1          0         0
+## 2          0         0
+

We see that using the compiled model is by a factor of around 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.

+
+
+

+Model that can not be solved with Eigenvalues

+

This evaluation is also taken from the example section of mkinfit.

+ +
## Successfully compiled differential equation model from auto-generated C code.
+
##                    test replications elapsed relative user.self sys.self
+## 2     deSolve, compiled            3   3.761    1.000     3.758    0.000
+## 1 deSolve, not compiled            3  36.462    9.695    36.441    0.004
+##   user.child sys.child
+## 2          0         0
+## 1          0         0
+

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

+

This vignette was built with mkin 0.9.47.5 on

+
## R version 3.5.1 (2018-07-02)
+## Platform: x86_64-pc-linux-gnu (64-bit)
+## Running under: Debian GNU/Linux 9 (stretch)
+
## CPU model: AMD Ryzen 7 1700 Eight-Core Processor
+
+
+ + + +
+ + + +
+ + + + + -- cgit v1.2.1