-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathanalysis_repeat_dosing.r
More file actions
92 lines (68 loc) · 3.37 KB
/
analysis_repeat_dosing.r
File metadata and controls
92 lines (68 loc) · 3.37 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#clearing the workspace
rm(list=ls())
graphics.off()
options(show.error.locations = TRUE)
require("ggplot2")
# If we are in a stand alone ubiquity distribution we run
# from there otherwise we try to load the package
if(file.exists(file.path('library', 'r_general', 'ubiquity.R'))){
source(file.path('library', 'r_general', 'ubiquity.R'))
} else {
library(ubiquity) }
# Creating the mAb system file
system_new(file_name="system.txt", system_file="mab_pk", overwrite = TRUE)
# For documentation explaining how to modify the commands below
# See the "R Workflow" section at the link below:
# http://presentation.ubiquity.grok.tv
# Rebuilding the system (R scripts and compiling C code)
cfg = build_system(output_directory = file.path(".", "output"),
temporary_directory = file.path(".", "transient"))
# set name | Description
# -------------------------------------------------------
# default | TMDD: Membrane bound target
cfg = system_select_set(cfg, "default")
# fetching the parameter values
parameters = system_fetch_parameters(cfg)
# The following applies to both individual and stochastic simulations:
# Define the solver to use
cfg=system_set_option(cfg,group = "simulation", option = "solver", value = "lsoda")
# Specify the output times
cfg=system_set_option(cfg, group = "simulation",
option = "output_times",
seq(0,10*7,1))
# -------------------------------------------------------------------------
# Fixed dosing
cfg = system_zero_inputs(cfg)
cfg = system_set_bolus(cfg, state = "Cc",
times = c(0, 14, 28, 42, 56), # days
values = c(500, 500, 500, 500, 500)) # mg
som_fix = run_simulation_ubiquity(parameters, cfg)
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# Same dosing using titration
# Enabling titration
cfg=system_set_option(cfg,
group = "titration",
option = "titrate",
value = TRUE)
# Creating a titration event
cfg=system_new_tt_rule(cfg,
name = "ivdose",
times = c(0, 2, 4, 6, 8),
timescale = "weeks")
cfg=system_set_tt_cond(cfg,
name = "ivdose",
cond = "TRUE",
action = "SI_TT_BOLUS[state='Cc', values=500, times=0]",
value = "1")
som_tt = run_simulation_titrate(parameters, cfg)
# -------------------------------------------------------------------------
myfig = ggplot() +
geom_line(data=som_fix$simout, aes(x=ts.days, y=Cc, color="Fixed Dosing"), linetype=1) +
geom_line(data=som_tt$simout, aes(x=ts.days, y=Cc, color="Titration" ), linetype=2) +
scale_colour_manual(values=c("Fixed Dosing"="darkblue", "Titration"="firebrick3")) +
theme(legend.title = element_blank()) +
theme(legend.position = 'bottom')
myfig = prepare_figure('present', myfig)
plot(myfig)
ggsave(sprintf('output%srepeat_dosing.png', .Platform$file.sep), width=8, height=3.4, plot=myfig)