-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathanalysis_multiple_file.r
More file actions
107 lines (89 loc) · 4.05 KB
/
Copy pathanalysis_multiple_file.r
File metadata and controls
107 lines (89 loc) · 4.05 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#clearing the workspace
rm(list=ls())
graphics.off()
options(show.error.locations = TRUE)
# 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) }
# 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 | mAb in Humans
# Selecting the default paraemter set
cfg = system_select_set(cfg, 'default')
# Fetching the parameter values
parameters = system_fetch_parameters(cfg)
# To overwrite the default dosing uncomment
cfg = system_zero_inputs(cfg)
cfg = system_set_bolus(cfg, state = "At",
times = c( 0.0, 14.0, 28.0),
values = c(400.0, 400.0, 400.0))
# 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",
value = seq(0,80,.1))
# -------------------------------------------------------------------------
# # Stochastic Simulation:
cfg=system_set_option(cfg, group = "stochastic",
option = "nsub",
value = 400)
# Loading dataset with subjects
cfg = system_load_data(cfg, dsname = "SUBS",
data_file = "mab_pk_subjects.csv")
# Linking the subjects dataset with the simulation routines
cfg=system_set_option(cfg, group = "stochastic",
option = "sub_file",
value = "SUBS")
cfg=system_set_option(cfg, group = "stochastic",
option = "sub_file_sample",
value = "with replacement")
# Uncomment the following to parallelize the simulations
# library(doParallel)
#
# cfg=system_set_option(cfg, group = "simulation",
# option = "parallel",
# value = "multicore")
#
# cfg=system_set_option(cfg, group = "simulation",
# option = "compute_cores",
# value = detectCores() - 1)
# This strips the output collected down to only the output C_ng_ml
# cfg = system_set_option(cfg, group="stochastic", option="ssp", value=list())
# cfg = system_set_option(cfg, group="stochastic", option="states", value=list())
# cfg = system_set_option(cfg, group="stochastic", option="outputs", value=c("C_ng_ml"))
som = simulate_subjects(parameters, cfg)
#
# graphics.off()
# library(ggplot2)
# myfig = ggplot(som$tcsummary, aes(x=ts.days, y=o.C_ng_ml.mean)) +
# geom_ribbon(aes(ymin=o.C_ng_ml.lb_ci,
# ymax=o.C_ng_ml.ub_ci),
# fill="lightblue",
# alpha=0.6) +
# geom_line(linetype="solid", size=0.7, color="blue") +
# geom_line(aes(x=ts.days, y=o.C_ng_ml.ub_ci), linetype="dashed", size=0.2, color="blue") +
# geom_line(aes(x=ts.days, y=o.C_ng_ml.lb_ci), linetype="dashed", size=0.2, color="blue") +
# xlab("Time (days)")+
# ylab("C (ng/ml) (units)")+
# #scale_y_log10(limits=c(100, 200000)) +
# guides(fill=FALSE)
#
#
# myfig = gg_log10_yaxis(myfig, ylim_min=1e3, ylim_max=3e5)
# myfig = prepare_figure("print", myfig)
# print(myfig)
#
#
# ggsave(sprintf('output%smultiple.png', .Platform$file.sep), width=8, height=3.4, plot=myfig)
# sdf = som_to_df(cfg, som)
# -------------------------------------------------------------------------