From db9ae6a0c9cecb92048fde6f06af1da183c09b5f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 19 Nov 2020 15:41:24 +0100 Subject: Depend on parallel, doc improvements By depending on parallel instead of importing it, functions to set up and stop a cluster are always available when mkin is loaded. The use of multicore processing in mmkin on Windows is now documented in the help file, which brings mkin closer to a version 1.0 #9. --- DESCRIPTION | 6 +- R/mkinmod.R | 18 +- R/mkinsub.R | 20 +- R/mmkin.R | 11 + _pkgdown.yml | 15 +- docs/dev/articles/FOCUS_D.html | 113 ++--- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ .../articles/FOCUS_D_files/figure-html/plot-1.png | Bin 101350 -> 81432 bytes .../FOCUS_D_files/figure-html/plot_2-1.png | Bin 15733 -> 24025 bytes docs/dev/articles/FOCUS_L.html | 248 ++++++----- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ .../figure-html/unnamed-chunk-10-1.png | Bin 29158 -> 43110 bytes .../figure-html/unnamed-chunk-12-1.png | Bin 54890 -> 84605 bytes .../figure-html/unnamed-chunk-13-1.png | Bin 22017 -> 33489 bytes .../figure-html/unnamed-chunk-15-1.png | Bin 38622 -> 59507 bytes .../figure-html/unnamed-chunk-4-1.png | Bin 23429 -> 35964 bytes .../figure-html/unnamed-chunk-5-1.png | Bin 14826 -> 21999 bytes .../figure-html/unnamed-chunk-6-1.png | Bin 23881 -> 36379 bytes .../figure-html/unnamed-chunk-8-1.png | Bin 27992 -> 42221 bytes .../figure-html/unnamed-chunk-9-1.png | Bin 28432 -> 41739 bytes docs/dev/articles/mkin.html | 11 +- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ .../mkin_files/figure-html/unnamed-chunk-2-1.png | Bin 92716 -> 92716 bytes docs/dev/articles/twa.html | 13 +- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ docs/dev/articles/web_only/FOCUS_Z.html | 245 ++++++----- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ .../figure-html/FOCUS_2006_Z_fits_1-1.png | Bin 88629 -> 69227 bytes .../figure-html/FOCUS_2006_Z_fits_10-1.png | Bin 133233 -> 109820 bytes .../figure-html/FOCUS_2006_Z_fits_11-1.png | Bin 132503 -> 109050 bytes .../figure-html/FOCUS_2006_Z_fits_11a-1.png | Bin 99562 -> 79154 bytes .../figure-html/FOCUS_2006_Z_fits_11b-1.png | Bin 22624 -> 35734 bytes .../figure-html/FOCUS_2006_Z_fits_2-1.png | Bin 88629 -> 69227 bytes .../figure-html/FOCUS_2006_Z_fits_3-1.png | Bin 88213 -> 69006 bytes .../figure-html/FOCUS_2006_Z_fits_5-1.png | Bin 104162 -> 83658 bytes .../figure-html/FOCUS_2006_Z_fits_6-1.png | Bin 133001 -> 108890 bytes .../figure-html/FOCUS_2006_Z_fits_7-1.png | Bin 132462 -> 108277 bytes .../figure-html/FOCUS_2006_Z_fits_9-1.png | Bin 110760 -> 91586 bytes docs/dev/articles/web_only/NAFTA_examples.html | 321 +++++++------- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ .../NAFTA_examples_files/figure-html/p10-1.png | Bin 80950 -> 80950 bytes .../NAFTA_examples_files/figure-html/p13-1.png | Bin 79358 -> 79355 bytes .../NAFTA_examples_files/figure-html/p15a-1.png | Bin 78259 -> 78261 bytes .../NAFTA_examples_files/figure-html/p16-1.png | Bin 95465 -> 95466 bytes .../NAFTA_examples_files/figure-html/p7-1.png | Bin 103768 -> 103771 bytes docs/dev/articles/web_only/benchmarks.html | 54 +-- docs/dev/articles/web_only/compiled_models.html | 122 +++--- .../anchor-sections-1.0/anchor-sections.css | 4 + .../anchor-sections-1.0/anchor-sections.js | 33 ++ docs/dev/news/index.html | 8 +- docs/dev/pkgdown.yml | 2 +- docs/dev/reference/AIC.mmkin.html | 41 +- docs/dev/reference/D24_2014.html | 251 +++++++++++ docs/dev/reference/DFOP.solution-1.png | Bin 19369 -> 31078 bytes docs/dev/reference/DFOP.solution.html | 13 +- docs/dev/reference/FOMC.solution-1.png | Bin 18630 -> 28900 bytes docs/dev/reference/FOMC.solution.html | 13 +- docs/dev/reference/HS.solution-1.png | Bin 18893 -> 29354 bytes docs/dev/reference/HS.solution.html | 13 +- docs/dev/reference/IORE.solution-1.png | Bin 18668 -> 30028 bytes docs/dev/reference/IORE.solution.html | 33 +- docs/dev/reference/Rplot001.png | Bin 1011 -> 14324 bytes docs/dev/reference/Rplot002.png | Bin 16843 -> 56035 bytes docs/dev/reference/Rplot003.png | Bin 28735 -> 55725 bytes docs/dev/reference/Rplot004.png | Bin 49269 -> 57095 bytes docs/dev/reference/Rplot005.png | Bin 57095 -> 56740 bytes docs/dev/reference/Rplot006.png | Bin 13474 -> 56330 bytes docs/dev/reference/Rplot007.png | Bin 18546 -> 25161 bytes docs/dev/reference/SFO.solution-1.png | Bin 18661 -> 29201 bytes docs/dev/reference/SFO.solution.html | 13 +- docs/dev/reference/SFORB.solution-1.png | Bin 20190 -> 31408 bytes docs/dev/reference/SFORB.solution.html | 13 +- docs/dev/reference/add_err-1.png | Bin 111359 -> 111360 bytes docs/dev/reference/add_err.html | 4 +- docs/dev/reference/confint.mkinfit.html | 225 +++++----- docs/dev/reference/create_deg_func.html | 56 +-- docs/dev/reference/experimental_data_for_UBA-1.png | Bin 107152 -> 103559 bytes docs/dev/reference/experimental_data_for_UBA.html | 85 ++-- docs/dev/reference/f_time_norm_focus.html | 283 +++++++++++++ docs/dev/reference/focus_soil_moisture.html | 206 +++++++++ docs/dev/reference/ilr.html | 44 +- docs/dev/reference/index.html | 63 ++- docs/dev/reference/logLik.mkinfit.html | 30 +- docs/dev/reference/logistic.solution-1.png | Bin 80598 -> 80293 bytes docs/dev/reference/logistic.solution-2.png | Bin 29336 -> 43807 bytes docs/dev/reference/logistic.solution.html | 67 +-- docs/dev/reference/max_twa_parent.html | 26 +- docs/dev/reference/mkinds.html | 63 +-- docs/dev/reference/mkindsg.html | 460 +++++++++++++++++++++ docs/dev/reference/mkinerrplot-1.png | Bin 41458 -> 41094 bytes docs/dev/reference/mkinerrplot.html | 46 ++- docs/dev/reference/mkinfit.html | 20 +- docs/dev/reference/mkinmod.html | 164 ++++++-- docs/dev/reference/mkinparplot-1.png | Bin 16468 -> 25707 bytes docs/dev/reference/mkinparplot.html | 24 +- docs/dev/reference/mkinpredict.html | 6 +- docs/dev/reference/mkinresplot-1.png | Bin 14861 -> 23819 bytes docs/dev/reference/mkinresplot.html | 48 ++- docs/dev/reference/mkinsub.html | 34 +- docs/dev/reference/mmkin.html | 28 +- docs/dev/reference/nafta-1.png | Bin 41379 -> 64838 bytes docs/dev/reference/nafta.html | 22 +- docs/dev/reference/nlme-1.png | Bin 68086 -> 69449 bytes docs/dev/reference/nlme-2.png | Bin 86504 -> 89236 bytes docs/dev/reference/nlme.html | 18 +- docs/dev/reference/nlme.mmkin.html | 12 +- docs/dev/reference/parms.html | 67 +-- docs/dev/reference/plot.mixed.mmkin-3.png | Bin 164014 -> 162677 bytes docs/dev/reference/plot.mixed.mmkin.html | 4 +- docs/dev/reference/plot.mkinfit-1.png | Bin 53973 -> 53731 bytes docs/dev/reference/plot.mkinfit-2.png | Bin 75079 -> 73830 bytes docs/dev/reference/plot.mkinfit-3.png | Bin 70266 -> 69215 bytes docs/dev/reference/plot.mkinfit-4.png | Bin 74166 -> 73285 bytes docs/dev/reference/plot.mkinfit-5.png | Bin 68692 -> 68646 bytes docs/dev/reference/plot.mkinfit-6.png | Bin 75012 -> 74042 bytes docs/dev/reference/plot.mkinfit-7.png | Bin 75692 -> 75294 bytes docs/dev/reference/plot.mkinfit.html | 123 +++--- docs/dev/reference/plot.mmkin-1.png | Bin 34584 -> 50628 bytes docs/dev/reference/plot.mmkin-2.png | Bin 34972 -> 50911 bytes docs/dev/reference/plot.mmkin-3.png | Bin 32445 -> 47267 bytes docs/dev/reference/plot.mmkin-4.png | Bin 25896 -> 34181 bytes docs/dev/reference/plot.mmkin-5.png | Bin 39246 -> 58620 bytes docs/dev/reference/plot.mmkin.html | 59 +-- docs/dev/reference/saem-5.png | Bin 164443 -> 163636 bytes docs/dev/reference/saem-6.png | Bin 0 -> 164696 bytes docs/dev/reference/saem.html | 244 +++++++++-- docs/dev/reference/summary.mkinfit.html | 6 +- docs/dev/reference/summary.nlme.mmkin.html | 23 +- docs/dev/reference/summary.saem.mmkin.html | 357 ++++++++-------- docs/dev/reference/transform_odeparms.html | 2 +- docs/dev/sitemap.xml | 21 +- man/mkinmod.Rd | 57 ++- man/mkinsub.Rd | 52 --- man/mmkin.Rd | 11 + man/print.mkinmod.Rd | 26 -- vignettes/FOCUS_D.html | 124 ++++-- vignettes/FOCUS_L.html | 143 ++++--- vignettes/web_only/mkin_benchmarks.rda | Bin 1001 -> 1011 bytes 144 files changed, 3637 insertions(+), 1572 deletions(-) create mode 100644 docs/dev/articles/FOCUS_D_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/FOCUS_D_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/FOCUS_L_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/FOCUS_L_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/mkin_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/mkin_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/twa_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/twa_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/web_only/FOCUS_Z_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/web_only/FOCUS_Z_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/web_only/NAFTA_examples_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/web_only/NAFTA_examples_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/articles/web_only/compiled_models_files/anchor-sections-1.0/anchor-sections.css create mode 100644 docs/dev/articles/web_only/compiled_models_files/anchor-sections-1.0/anchor-sections.js create mode 100644 docs/dev/reference/D24_2014.html create mode 100644 docs/dev/reference/f_time_norm_focus.html create mode 100644 docs/dev/reference/focus_soil_moisture.html create mode 100644 docs/dev/reference/mkindsg.html create mode 100644 docs/dev/reference/saem-6.png delete mode 100644 man/mkinsub.Rd delete mode 100644 man/print.mkinmod.Rd diff --git a/DESCRIPTION b/DESCRIPTION index e85cf3d1..853332b1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 0.9.50.4 -Date: 2020-11-12 +Date: 2020-11-19 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", comment = c(ORCID = "0000-0003-4371-6538")), @@ -16,8 +16,8 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006, equation models are solved using automatically generated C functions. Please note that no warranty is implied for correctness of results or fitness for a particular purpose. -Depends: R (>= 2.15.1) -Imports: stats, graphics, methods, deSolve, R6, inline, parallel, numDeriv, +Depends: R (>= 2.15.1), parallel +Imports: stats, graphics, methods, deSolve, R6, inline, numDeriv, lmtest, pkgbuild, nlme (>= 3.1-150.1), purrr, saemix (>= 3.1.9000) Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr, vdiffr, benchmarkme, tibble, stats4 diff --git a/R/mkinmod.R b/R/mkinmod.R index a410c02d..1af72db5 100644 --- a/R/mkinmod.R +++ b/R/mkinmod.R @@ -29,11 +29,12 @@ #' (default) and the model for the compartment is "SFO" or "SFORB", an #' additional [mkinsub()] argument can be \code{sink = FALSE}, effectively #' fixing the flux to sink to zero. +#' In print.mkinmod, this argument is currently not used. #' @param use_of_ff Specification of the use of formation fractions in the -#' model equations and, if applicable, the coefficient matrix. If "min", a -#' minimum use of formation fractions is made in order to avoid fitting the -#' product of formation fractions and rate constants. If "max", formation -#' fractions are always used. +#' model equations and, if applicable, the coefficient matrix. If "max", +#' formation fractions are always used (default). If "min", a minimum use of +#' formation fractions is made, i.e. each pathway to a metabolite has its +#' own rate constant. #' @param speclist The specification of the observed variables and their #' submodel types and pathways can be given as a single list using this #' argument. Default is NULL. @@ -91,6 +92,11 @@ #' m1 = mkinsub("SFO")) #' #' \dontrun{ +#' # Now supplying full names used for plotting +#' SFO_SFO.2 <- mkinmod( +#' parent = mkinsub("SFO", "m1", full_name = "Test compound"), +#' m1 = mkinsub("SFO", full_name = "Metabolite M1")) +#' #' # The above model used to be specified like this, before the advent of mkinsub() #' SFO_SFO <- mkinmod( #' parent = list(type = "SFO", to = "m1"), @@ -111,7 +117,7 @@ #' parent = mkinsub("DFOP", c("M1", "M2")), #' M1 = mkinsub("SFO"), #' M2 = mkinsub("SFO"), -#' use_of_ff = "max", quiet = TRUE) +#' quiet = TRUE) #' #' fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par, #' synthetic_data_for_UBA_2014[[12]]$data, @@ -451,8 +457,8 @@ mkinmod <- function(..., use_of_ff = "max", speclist = NULL, quiet = FALSE, verb #' Print mkinmod objects in a way that the user finds his way to get to its #' components. #' +#' @rdname mkinmod #' @param x An \code{\link{mkinmod}} object. -#' @param \dots Not used. #' @examples #' #' m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), diff --git a/R/mkinsub.R b/R/mkinsub.R index f87c230a..886f712c 100644 --- a/R/mkinsub.R +++ b/R/mkinsub.R @@ -3,6 +3,7 @@ #' This is a convenience function to set up the lists used as arguments for #' \code{\link{mkinmod}}. #' +#' @rdname mkinmod #' @param submodel Character vector of length one to specify the submodel type. #' See \code{\link{mkinmod}} for the list of allowed submodel names. #' @param to Vector of the names of the state variable to which a @@ -14,25 +15,6 @@ #' your R code will not be portable, \emph{i.e.} may produce unintended plot #' results on other operating systems or system configurations. #' @return A list for use with \code{\link{mkinmod}}. -#' @author Johannes Ranke -#' @examples -#' -#' # One parent compound, one metabolite, both single first order. -#' SFO_SFO <- mkinmod( -#' parent = list(type = "SFO", to = "m1"), -#' m1 = list(type = "SFO")) -#' -#' # The same model using mkinsub -#' SFO_SFO.2 <- mkinmod( -#' parent = mkinsub("SFO", "m1"), -#' m1 = mkinsub("SFO")) -#' -#' \dontrun{ -#' # Now supplying full names -#' SFO_SFO.2 <- mkinmod( -#' parent = mkinsub("SFO", "m1", full_name = "Test compound"), -#' m1 = mkinsub("SFO", full_name = "Metabolite M1")) -#' } #' @export mkinsub <- function(submodel, to = NULL, sink = TRUE, full_name = NA) { diff --git a/R/mmkin.R b/R/mmkin.R index 96453e1d..bb111efe 100644 --- a/R/mmkin.R +++ b/R/mmkin.R @@ -60,6 +60,17 @@ #' # Plotting with mmkin (single brackets, extracting an mmkin object) does not #' # allow to plot the observed variables separately #' plot(fits.0[1, 1]) +#' +#' # On Windows, we can use multiple cores by making a cluster using the parallel +#' # package, which gets loaded with mkin, and passing it to mmkin, e.g. +#' cl <- makePSOCKcluster(12) +#' f <- mmkin(c("SFO", "FOMC", "DFOP"), +#' list(A = FOCUS_2006_A, B = FOCUS_2006_B, C = FOCUS_2006_C, D = FOCUS_2006_D), +#' cluster = cl, quiet = TRUE) +#' print(f) +#' # We get false convergence for the FOMC fit to FOCUS_2006_A because this +#' # dataset is really SFO, and the FOMC fit is overparameterised +#' stopCluster(cl) #' } #' #' @export mmkin diff --git a/_pkgdown.yml b/_pkgdown.yml index 75296568..cb3fa078 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -51,6 +51,8 @@ reference: - saemix_model - title: Datasets and known results contents: + - focus_soil_moisture + - D24_2014 - FOCUS_2006_A - FOCUS_2006_SFO_ref_A_to_F - FOCUS_2006_FOMC_ref_A_to_F @@ -64,23 +66,23 @@ reference: - experimental_data_for_UBA_2019 - test_data_from_UBA_2014 - mkinds - - print.mkinds + - mkindsg - title: NAFTA guidance contents: - nafta - print.nafta - plot.nafta - - title: Helper functions mainly used internally + - title: Utility functions contents: - - mkinsub + - f_time_norm_focus - max_twa_parent - - mkinpredict - mkin_wide_to_long - mkin_long_to_wide - - print.mkinmod + - title: Helper functions mainly used internally + contents: + - mkinpredict - transform_odeparms - ilr - - sigma_twocomp - logLik.mkinfit - residuals.mkinfit - nobs.mkinfit @@ -101,6 +103,7 @@ reference: - title: Generate synthetic datasets contents: - add_err + - sigma_twocomp - title: Deprecated functions desc: Functions that have been superseded contents: diff --git a/docs/dev/articles/FOCUS_D.html b/docs/dev/articles/FOCUS_D.html index 02701431..e526b3a7 100644 --- a/docs/dev/articles/FOCUS_D.html +++ b/docs/dev/articles/FOCUS_D.html @@ -32,7 +32,7 @@ mkin - 0.9.50.3 + 0.9.50.4 @@ -80,7 +80,7 @@