From 47ba9ea512b82fb8b31da8ec5558f3c0952d86d4 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 2 Apr 2020 10:58:34 +0200 Subject: Compiled models article, reduce distractions - Added a section with platform specific notes on getting compiled models to work to the compiled models article - Don't return empty SFORB parameter list from endpoints() if there is no SFORB model - Avoid warnings when using standardized = TRUE in plot.mmkin() --- vignettes/web_only/FOCUS_Z.html | 332 ++++++++++++++++++++++++++-------------- 1 file changed, 217 insertions(+), 115 deletions(-) (limited to 'vignettes/web_only/FOCUS_Z.html') diff --git a/vignettes/web_only/FOCUS_Z.html b/vignettes/web_only/FOCUS_Z.html index d7f0f88c..e8e6e2b4 100644 --- a/vignettes/web_only/FOCUS_Z.html +++ b/vignettes/web_only/FOCUS_Z.html @@ -1,17 +1,17 @@ - + - + - + Example evaluation of FOCUS dataset Z @@ -69,8 +69,6 @@ overflow: auto; margin-left: 2%; position: fixed; border: 1px solid #ccc; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; } @@ -98,10 +96,15 @@ font-size: 12px; .tocify-subheader .tocify-subheader { text-indent: 30px; } - .tocify-subheader .tocify-subheader .tocify-subheader { text-indent: 40px; } +.tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { +text-indent: 50px; +} +.tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { +text-indent: 60px; +} .tocify .tocify-item > a, .tocify .nav-list .nav-header { margin: 0px; @@ -504,13 +507,13 @@ float: none; item.append($("", { - "text": self.text() + "html": self.html() })); } else { - item.text(self.text()); + item.html(self.html()); } @@ -1280,12 +1283,12 @@ window.initializeCodeFolding = function(show) { var currentIndex = 1; // select all R code blocks - var rCodeBlocks = $('pre.r, pre.python, pre.bash, pre.sql, pre.cpp, pre.stan'); + var rCodeBlocks = $('pre.r, pre.python, pre.bash, pre.sql, pre.cpp, pre.stan, pre.julia'); rCodeBlocks.each(function() { // create a collapsable div to wrap the code in var div = $('
'); - if (show) + if (show || $(this)[0].classList.contains('fold-show')) div.addClass('in'); var id = 'rcode-643E0F36' + currentIndex++; div.attr('id', id); @@ -1387,9 +1390,7 @@ h6 { - - -
- - - - +.tabset-dropdown > .nav-tabs { + display: inline-table; + max-height: 500px; + min-height: 44px; + overflow-y: auto; + background: white; + border: 1px solid #ddd; + border-radius: 4px; +} +.tabset-dropdown > .nav-tabs > li.active:before { + content: ""; + font-family: 'Glyphicons Halflings'; + display: inline-block; + padding: 10px; + border-right: 1px solid #ddd; +} +.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before { + content: ""; + border: none; +} +.tabset-dropdown > .nav-tabs.nav-tabs-open:before { + content: ""; + font-family: 'Glyphicons Halflings'; + display: inline-block; + padding: 10px; + border-right: 1px solid #ddd; +} - + + + + + + + +
+ +
@@ -1547,8 +1582,8 @@ div.tocify {

Example evaluation of FOCUS dataset Z

-

Johannes Ranke

-

2018-09-14

+

Johannes Ranke

+

2020-04-02

@@ -1579,44 +1614,53 @@ FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z)
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)
-

+
m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
plot_sep(m.Z.2a)
+

summary(m.Z.2a, data = FALSE)$bpar
-
##             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
+
##             Estimate se_notrans    t value     Pr(>t)    Lower    Upper
+## Z0_0      9.7015e+01   3.394528 2.8580e+01 6.4978e-21 91.66556 102.3642
+## k_Z0_sink 1.6067e-10   0.225471 7.1261e-10 5.0000e-01  0.00000      Inf
+## k_Z0_Z1   2.2360e+00   0.159156 1.4049e+01 1.1405e-13  1.95303   2.5600
+## k_Z1_sink 4.8212e-01   0.065492 7.3616e+00 5.1697e-08  0.40341   0.5762
+## sigma     4.8041e+00   0.637651 7.5341e+00 3.4463e-08  3.52677   6.0815

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:

Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
                    Z1 = mkinsub("SFO"),
                    use_of_ff = "max")
## 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)
-

+
m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
plot_sep(m.Z.2a.ff)
+

summary(m.Z.2a.ff, data = FALSE)$bpar
-
##            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
+
##            Estimate se_notrans t value     Pr(>t)    Lower    Upper
+## Z0_0       97.01488   3.301084 29.3888 3.2971e-21 91.66556 102.3642
+## k_Z0        2.23601   0.207078 10.7979 3.3309e-11  1.95303   2.5600
+## k_Z1        0.48212   0.063265  7.6207 2.8155e-08  0.40341   0.5762
+## f_Z0_to_Z1  1.00000   0.094764 10.5525 5.3560e-11  0.00000   1.0000
+## sigma       4.80411   0.635638  7.5579 3.2592e-08  3.52677   6.0815

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)
-

+
m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
plot_sep(m.Z.3)
+

summary(m.Z.3, data = FALSE)$bpar
-
##      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
+
##       Estimate se_notrans t value     Pr(>t)    Lower    Upper
+## Z0_0  97.01488   2.597342  37.352 2.0106e-24 91.67597 102.3538
+## k_Z0   2.23601   0.146904  15.221 9.1477e-15  1.95354   2.5593
+## k_Z1   0.48212   0.041727  11.554 4.8268e-12  0.40355   0.5760
+## sigma  4.80411   0.620208   7.746 1.6110e-08  3.52925   6.0790

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

@@ -1626,9 +1670,11 @@ plot_sep(m.Z.3) 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)
-

+
m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
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),
@@ -1639,32 +1685,30 @@ plot_sep(m.Z.5)
m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin,
                      parms.ini = m.Z.5$bparms.ode,
                      quiet = TRUE)
-
## 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)
+
## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, :
+## Observations with value of zero were removed from the data
plot_sep(m.Z.FOCUS)
-

+

summary(m.Z.FOCUS, data = FALSE)$bpar
##             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
+## Z0_0 96.838599 1.994271 48.5584 4.0281e-42 92.826628 100.850570 +## k_Z0 2.215405 0.118459 18.7019 1.0415e-23 1.989466 2.467003 +## k_Z1 0.478298 0.028257 16.9268 6.2399e-22 0.424701 0.538660 +## k_Z2 0.451618 0.042137 10.7177 1.6306e-14 0.374328 0.544866 +## k_Z3 0.058693 0.015246 3.8499 1.7803e-04 0.034805 0.098977 +## f_Z2_to_Z3 0.471509 0.058352 8.0804 9.6629e-11 0.357739 0.588318 +## sigma 3.984431 0.383402 10.3923 4.5575e-14 3.213126 4.755736
endpoints(m.Z.FOCUS)
## $ff
 ##   Z2_Z3 Z2_sink 
-## 0.47152 0.52848 
-## 
-## $SFORB
-## logical(0)
+## 0.47151 0.52849 
 ## 
 ## $distimes
 ##        DT50    DT90
 ## Z0  0.31288  1.0394
-## Z1  1.44918  4.8141
+## Z1  1.44919  4.8141
 ## Z2  1.53481  5.0985
-## Z3 11.80973 39.2311
+## Z3 11.80963 39.2308

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.

@@ -1676,9 +1720,11 @@ plot_sep(m.Z.5) 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)
-

+
m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
plot_sep(m.Z.mkin.1)
+

summary(m.Z.mkin.1, data = FALSE)$cov.unscaled
## 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.

@@ -1686,9 +1732,11 @@ plot_sep(m.Z.mkin.1) 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)
-

+
m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+
## Warning in mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
+## value of zero were removed from the data
+
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),
@@ -1698,9 +1746,11 @@ plot_sep(m.Z.mkin.3)
## Successfully compiled differential equation model from auto-generated C code.
m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin,
                       parms.ini = m.Z.mkin.3$bparms.ode,
-                      quiet = TRUE)
-plot_sep(m.Z.mkin.4)
-

+ quiet = TRUE) +
## Warning in mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin, parms.ini = m.Z.mkin.
+## 3$bparms.ode, : Observations with value of zero were removed from the data
+
plot_sep(m.Z.mkin.4)
+

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),
@@ -1709,21 +1759,25 @@ plot_sep(m.Z.mkin.4)
## Successfully compiled differential equation model from auto-generated C code.
m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
                       parms.ini = m.Z.mkin.4$bparms.ode[1:4],
-                      quiet = TRUE)
-plot_sep(m.Z.mkin.5)
-

+ quiet = TRUE) +
## Warning in mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, parms.ini = m.Z.mkin.
+## 4$bparms.ode[1:4], : Observations with value of zero were removed from the data
+
plot_sep(m.Z.mkin.5)
+

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.

m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
                        parms.ini = c(m.Z.mkin.5$bparms.ode[1:7],
                                      k_Z3_bound_free = 0),
                        fixed_parms = "k_Z3_bound_free",
-                       quiet = TRUE)
-plot_sep(m.Z.mkin.5a)
-

+ quiet = TRUE) +
## Warning in mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, parms.ini = c(m.Z.mkin.
+## 5$bparms.ode[1:7], : Observations with value of zero were removed from the data
+
plot_sep(m.Z.mkin.5a)
+

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
@@ -1732,14 +1786,14 @@ plot_sep(m.Z.mkin.5a)
## ## $SFORB ## Z0_b1 Z0_b2 Z3_b1 Z3_b2 -## 2.4471382 0.0075127 0.0800075 0.0000000 +## 2.4471363 0.0075126 0.0800072 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 +## Z0 0.3043 1.1848 0.28325 92.265 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 +## Z3 NA NA NA NA 8.6636 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.

@@ -1772,6 +1826,54 @@ $(document).ready(function () { + + + + + + + + +