diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-04-02 10:58:34 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-04-03 10:53:07 +0200 |
commit | 47ba9ea512b82fb8b31da8ec5558f3c0952d86d4 (patch) | |
tree | 775b56488b5f040132d00a962c6f7f876ed15b7c /R | |
parent | 1d01aa6e40bdb3e338638b9239153cf82713d634 (diff) |
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()
Diffstat (limited to 'R')
-rw-r--r-- | R/endpoints.R | 20 | ||||
-rw-r--r-- | R/plot.mmkin.R | 6 |
2 files changed, 16 insertions, 10 deletions
diff --git a/R/endpoints.R b/R/endpoints.R index 14beadea..f7ee483a 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -1,12 +1,12 @@ #' Function to calculate endpoints for further use from kinetic models fitted #' with mkinfit -#' +#' #' This function calculates DT50 and DT90 values as well as formation fractions #' from kinetic models fitted with mkinfit. If the SFORB model was specified #' for one of the parents or metabolites, the Eigenvalues are returned. These #' are equivalent to the rate constantes of the DFOP model, but with the #' advantage that the SFORB model can also be used for metabolites. -#' +#' #' @param fit An object of class \code{\link{mkinfit}}. #' @importFrom stats optimize #' @return A list with the components mentioned above. @@ -14,10 +14,10 @@ #' @author Johannes Ranke #' @keywords manip #' @examples -#' +#' #' fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) -#' endpoints(fit) -#' +#' endpoints(fit) +#' #' @export endpoints <- function(fit) { # Calculate dissipation times DT50 and DT90 and formation @@ -29,8 +29,9 @@ endpoints <- function(fit) { parms.all <- c(fit$bparms.optim, fit$bparms.fixed) ep$ff <- vector() ep$SFORB <- vector() - ep$distimes <- data.frame(DT50 = rep(NA, length(obs_vars)), - DT90 = rep(NA, length(obs_vars)), + ep$distimes <- data.frame( + DT50 = rep(NA, length(obs_vars)), + DT90 = rep(NA, length(obs_vars)), row.names = obs_vars) for (obs_var in obs_vars) { type = names(fit$mkinmod$map[[obs_var]])[1] @@ -41,8 +42,8 @@ endpoints <- function(fit) { f_values = parms.all[f_names] f_to_sink = 1 - sum(f_values) names(f_to_sink) = ifelse(type == "SFORB", - paste(obs_var, "free", "sink", sep = "_"), - paste(obs_var, "sink", sep = "_")) + paste(obs_var, "free", "sink", sep = "_"), + paste(obs_var, "sink", sep = "_")) for (f_name in f_names) { ep$ff[[sub("f_", "", sub("_to_", "_", f_name))]] = f_values[[f_name]] } @@ -195,5 +196,6 @@ endpoints <- function(fit) { } ep$distimes[obs_var, c("DT50", "DT90")] = c(DT50, DT90) } + if (length(ep$SFORB) == 0) ep$SFORB <- NULL return(ep) } diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index 182e74ca..15ea86eb 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -15,6 +15,9 @@ #' @param resplot Should the residuals plotted against time, using #' \code{\link{mkinresplot}}, or as squared residuals against predicted #' values, with the error model, using \code{\link{mkinerrplot}}. +#' @param standardized Should the residuals be standardized? This option +#' is passed to \code{\link{mkinresplot}}, it only takes effect if +#' `resplot = "time"`. #' @param show_errmin Should the chi2 error level be shown on top of the plots #' to the left? #' @param errmin_var The variable for which the FOCUS chi2 error value should @@ -51,6 +54,7 @@ #' @export plot.mmkin <- function(x, main = "auto", legends = 1, resplot = c("time", "errmod"), + standardized = FALSE, show_errmin = TRUE, errmin_var = "All data", errmin_digits = 3, cex = 0.7, rel.height.middle = 0.9, @@ -136,7 +140,7 @@ plot.mmkin <- function(x, main = "auto", legends = 1, } if (resplot == "time") { - mkinresplot(fit, legend = FALSE, ...) + mkinresplot(fit, legend = FALSE, standardized = standardized, ...) } else { mkinerrplot(fit, legend = FALSE, ...) } |