From 4c6f29fe2a3ece5a85160b891c89ce0f55299c11 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 23 Jul 2014 08:34:59 +0200 Subject: Parallel metabolite formation with formation fractions in mkinerrmin --- R/mkinerrmin.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'R/mkinerrmin.R') diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R index 9ebac6a4..09724730 100644 --- a/R/mkinerrmin.R +++ b/R/mkinerrmin.R @@ -65,11 +65,12 @@ mkinerrmin <- function(fit, alpha = 0.05) # Formation fractions are attributed to the target variable, so look # for source compartments with formation fractions for (source_var in fit$obs_vars) { + n.ff.source = length(grep(paste("^f", source_var, sep = "_"), + names(parms.optim))) + n.paths.source = length(fit$mkinmod$spec[[source_var]]$to) for (target_var in fit$mkinmod$spec[[source_var]]$to) { if (obs_var == target_var) { - n.ff.optim <- n.ff.optim + - length(grep(paste("^f", source_var, sep = "_"), - names(parms.optim))) + n.ff.optim <- n.ff.optim + n.ff.source/n.paths.source } } } -- cgit v1.2.1 From f30472ecd2afea6bd2153b8ad2bb2f663f3a2742 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 25 Aug 2014 10:39:40 +0200 Subject: Bug fix and unit tests for mkinerrmin See NEWS.md for details --- R/mkinerrmin.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'R/mkinerrmin.R') diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R index 09724730..2697d0a0 100644 --- a/R/mkinerrmin.R +++ b/R/mkinerrmin.R @@ -36,10 +36,11 @@ mkinerrmin <- function(fit, alpha = 0.05) suffixes = c("_mean", "_pred")) errdata <- errdata[order(errdata$time, errdata$name), ] - # Any value that is set to exactly zero is not really an observed value - # Remove those at time 0 - those are caused by the FOCUS recommendation - # to set metabolites occurring at time 0 to 0 - errdata <- subset(errdata, !(time == 0 & value_mean == 0)) + # Remove values at time zero for variables whose value for state.ini is fixed, + # as these will not have any effect in the optimization and should therefore not + # be counted as degrees of freedom. + fixed_initials = gsub("_0$", "", rownames(subset(fit$fixed, type = "state"))) + errdata <- subset(errdata, !(time == 0 & name %in% fixed_initials)) n.optim.overall <- length(parms.optim) -- cgit v1.2.1