From efab37957381919c21d874906ce870f4941c760a Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 9 May 2020 21:18:42 +0200 Subject: Avoid the call to merge for analytical solutions This increases performance up to a factor of five! --- man/mkinfit.Rd | 6 ------ man/mkinmod.Rd | 2 +- man/mkinpredict.Rd | 35 ++++++++++++++++++++--------------- man/plot.mkinfit.Rd | 1 + 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'man') diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index b728aded..db3f5f3e 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -26,7 +26,6 @@ mkinfit( quiet = FALSE, atol = 1e-08, rtol = 1e-10, - n.outtimes = 10, error_model = c("const", "obs", "tc"), error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep", "fourstep", "IRLS", "OLS"), @@ -141,11 +140,6 @@ is 1e-8, lower than in \code{\link{lsoda}}.} \item{rtol}{Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-10, much lower than in \code{\link{lsoda}}.} -\item{n.outtimes}{The length of the dataseries that is produced by the model -prediction function \code{\link{mkinpredict}}. This impacts the accuracy -of the numerical solver if that is used (see \code{solution_type} -argument.} - \item{error_model}{If the error model is "const", a constant standard deviation is assumed. diff --git a/man/mkinmod.Rd b/man/mkinmod.Rd index 2ba917d6..a5736be7 100644 --- a/man/mkinmod.Rd +++ b/man/mkinmod.Rd @@ -82,7 +82,7 @@ The IORE submodel is not well tested for metabolites. When using this \examples{ # Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) -SFO <- mkinmod(parent = list(type = "SFO")) +SFO <- mkinmod(parent = mkinsub("SFO")) # One parent compound, one metabolite, both single first order SFO_SFO <- mkinmod( diff --git a/man/mkinpredict.Rd b/man/mkinpredict.Rd index f7e4acfc..1ba5b5f8 100644 --- a/man/mkinpredict.Rd +++ b/man/mkinpredict.Rd @@ -91,7 +91,7 @@ FALSE).} solver is used.} } \value{ -A matrix in the same format as the output of \code{\link{ode}}. +A data frame with the solution in wide format } \description{ This function produces a time series for all the observed variables in a @@ -131,30 +131,35 @@ mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), # Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"), use_of_ff = "min") + m1 = list(type = "SFO"), use_of_ff = "max") if(require(rbenchmark)) { - benchmark( - eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), + benchmark(replications = 10, order = "relative", columns = c("test", "relative", "elapsed"), + eigen = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "eigen")[201,], - deSolve_compiled = mkinpredict(SFO_SFO, - c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), + deSolve_compiled = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve")[201,], - deSolve = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), - c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), - solution_type = "deSolve", use_compiled = FALSE)[201,], - replications = 10) + deSolve = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "deSolve", use_compiled = FALSE)[201,], + analytical = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "analytical", use_compiled = FALSE)[201,]) } - -# Since mkin 0.9.49.11 we also have analytical solutions for some models, including SFO-SFO -# deSolve = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), -# c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), -# solution_type = "analytical", use_compiled = FALSE)[201,], + analytical = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "analytical", use_compiled = FALSE)[201,] \dontrun{ # Predict from a fitted model f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE) + f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE, solution_type = "analytical") head(mkinpredict(f)) } diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd index c3f3134a..4235557e 100644 --- a/man/plot.mkinfit.Rd +++ b/man/plot.mkinfit.Rd @@ -144,6 +144,7 @@ latex is being used for the formatting of the chi2 error level, if \dontrun{ SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"), m1 = mkinsub("SFO", full = "Metabolite M1" )) +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc") plot(fit) plot_res(fit) -- cgit v1.2.1