ds <- lapply(experimental_data_for_UBA_2019[6:10],
function(x) subset(x$data[c("name", "time", "value")], name == "parent"))
if (FALSE) {
f <- mmkin(c("SFO", "DFOP"), ds, quiet = TRUE, cores = 1)
library(nlme)
f_nlme_sfo <- nlme(f["SFO", ])
f_nlme_dfop <- nlme(f["DFOP", ])
anova(f_nlme_sfo, f_nlme_dfop)
print(f_nlme_dfop)
plot(f_nlme_dfop)
endpoints(f_nlme_dfop)
ds_2 <- lapply(experimental_data_for_UBA_2019[6:10],
function(x) x$data[c("name", "time", "value")])
m_sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"),
A1 = mkinsub("SFO"), use_of_ff = "min", quiet = TRUE)
m_sfo_sfo_ff <- mkinmod(parent = mkinsub("SFO", "A1"),
A1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE)
m_dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"),
A1 = mkinsub("SFO"), quiet = TRUE)
f_2 <- mmkin(list("SFO-SFO" = m_sfo_sfo,
"SFO-SFO-ff" = m_sfo_sfo_ff,
"DFOP-SFO" = m_dfop_sfo),
ds_2, quiet = TRUE)
f_nlme_sfo_sfo <- nlme(f_2["SFO-SFO", ])
plot(f_nlme_sfo_sfo)
# With formation fractions this does not coverge with defaults
# f_nlme_sfo_sfo_ff <- nlme(f_2["SFO-SFO-ff", ])
#plot(f_nlme_sfo_sfo_ff)
# For the following, we need to increase pnlsMaxIter and the tolerance
# to get convergence
f_nlme_dfop_sfo <- nlme(f_2["DFOP-SFO", ],
control = list(pnlsMaxIter = 120, tolerance = 5e-4))
plot(f_nlme_dfop_sfo)
anova(f_nlme_dfop_sfo, f_nlme_sfo_sfo)
endpoints(f_nlme_sfo_sfo)
endpoints(f_nlme_dfop_sfo)
if (length(findFunction("varConstProp")) > 0) { # tc error model for nlme available
# Attempts to fit metabolite kinetics with the tc error model are possible,
# but need tweeking of control values and sometimes do not converge
f_tc <- mmkin(c("SFO", "DFOP"), ds, quiet = TRUE, error_model = "tc")
f_nlme_sfo_tc <- nlme(f_tc["SFO", ])
f_nlme_dfop_tc <- nlme(f_tc["DFOP", ])
AIC(f_nlme_sfo, f_nlme_sfo_tc, f_nlme_dfop, f_nlme_dfop_tc)
print(f_nlme_dfop_tc)
}
f_2_obs <- update(f_2, error_model = "obs")
f_nlme_sfo_sfo_obs <- nlme(f_2_obs["SFO-SFO", ])
print(f_nlme_sfo_sfo_obs)
f_nlme_dfop_sfo_obs <- nlme(f_2_obs["DFOP-SFO", ],
control = list(pnlsMaxIter = 120, tolerance = 5e-4))
f_2_tc <- update(f_2, error_model = "tc")
# f_nlme_sfo_sfo_tc <- nlme(f_2_tc["SFO-SFO", ]) # No convergence with 50 iterations
# f_nlme_dfop_sfo_tc <- nlme(f_2_tc["DFOP-SFO", ],
# control = list(pnlsMaxIter = 120, tolerance = 5e-4)) # Error in X[, fmap[[nm]]] <- gradnm
anova(f_nlme_dfop_sfo, f_nlme_dfop_sfo_obs)
}
Run the code above in your browser using DataLab