forked from dkaschek/dMod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestPexpl.R
More file actions
57 lines (44 loc) · 1.77 KB
/
testPexpl.R
File metadata and controls
57 lines (44 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
rm(list = ls(all.names = TRUE))
# Create and set a specific working directory inside your project folder
.workingDir <- file.path(purrr::reduce(1:1, ~dirname(.x), .init = rstudioapi::getSourceEditorContext()$path), "wd")
if (!dir.exists(.workingDir)) dir.create(.workingDir)
setwd(.workingDir)
unlink(list.files(".", pattern = "\\.(cpp|c|o|so|dll)$", full.names = TRUE), force = TRUE)
set.seed(5555)
library(dMod)
library(ggplot2)
library(dplyr)
# Set up reactions
r <- eqnvec() %>%
addReaction("", "Stim", "0") %>%
addReaction("", "R", "k_act_R_bas + k_act_R * Stim", "stim act R") %>%
addReaction("R", "", "k_deact_R * R", "deact R") %>%
addReaction("A", "pA", "k1 * A * R / (Km + A)", "phos A") %>%
addReaction("pA", "A", "k2 * pA / (Km2 + pA)", "dephos pA")
mysteadies <- steadyStates(r, forcings = "Stim", resolve = T)
trafo <- eqnvec() %>%
define("x~x", x = getParameters(r)) %>%
define("Stim~1") %>%
insert("x~y", x = names(mysteadies), y = mysteadies) %>%
insert("x~10^x", x = .currentSymbols[!grepl("Stim", .currentSymbols)]) %>%
{.}
p <- P(trafo, compile = T, condition = "cond1", attach.input = T)
outerpars <- setdiff(getParameters(p), "k2")
pars <- structure(rep(-1, length(outerpars)), names = outerpars)
fixed = c(k2 = -1)
pout <- p(pars, fixed = fixed)
pout
p(pars, fixed = fixed) %>% getDerivs()
x.boost <- odemodel(r, modelname = "test_boost", solver = "boost", compile = F) %>% Xs()
x.dS <- odemodel(r, modelname = "test_dS", compile = F) %>% Xs()
compile(x.boost, x.dS, cores = 4)
times <- seq(0,100,len = 300)
prd.bs <- x.boost*p
prd.dS <- x.dS*p
# debugonce(x.dS)
out.bs <- prd.bs(times, pars, fixed = fixed)
out.dS <- prd.dS(times, pars, fixed = fixed)
out.bs %>% plot()
out.dS %>% plot()
getDerivs(out.bs) %>% plot()
getDerivs(out.dS) %>% plot()