Skip to contents

Reads in the app state from yaml files.

Usage

CTS_mk_preload(state)

Arguments

state

CTS state object

Value

list with the following elements

  • isgood: Boolean indicating the exit status of the function.

  • msgs: Messages to be passed back to the user.

  • yaml_list: Lists with preload components.

Examples

# \donttest{
sess_res = CTS_test_mksession()
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → ASM:   dest:   file.path("config","report.docx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → ASM:   dest:   file.path("config","report.pptx")
#> → ASM: including file
#> → ASM:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → ASM:   dest:   file.path("config","report.yaml")
#> → ASM: State initialized
#> → ASM: setting word placeholders: 
#> → ASM:   -> setting docx ph: HEADERLEFT = left header
#> → ASM:   -> setting docx ph: HEADERRIGHT = right header
#> → ASM:   -> setting docx ph: FOOTERLEFT = left footer
#> → ASM: module isgood: TRUE
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → MB:   dest:   file.path("config","report.docx")
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → MB:   dest:   file.path("config","report.pptx")
#> → MB: including file
#> → MB:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → MB:   dest:   file.path("config","report.yaml")
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.R not found (skipping)
#> ! MB: User-defined model: /Users/jmh/projects/ruminate/github/ruminate/docs/reference/user_model.ctl not found (skipping)
#> → MB: module checksum updated:f7de2055542d3ff1b085fafc2d30a1f8
#> → MB: State initialized
#> → MB: loading model idx: 1
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> → MB: model checksum updated: 5ea0976f8d62691f7a03207f8ca0f85b
#> → MB: module checksum updated:011e2b8a3d785232690357d6c61b03f1
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> → MB: model checksum updated: fe37ccaac4f04a3e7ba1d6d50f37abab
#> → MB: module checksum updated:f9eb4b7b2bc2dff8604f4bc32d9c8b46
#> → MB:   -> setting name: One compartment model
#> → MB:   -> setting time scale: hours
#> → MB:   -> setting base from: user
#> → MB:   -> setting catalog selection: 
#> → MB:   -> setting base model id: manual
#> → MB:   -> setting base model name: manual
#> → MB: model checksum updated: c76b840990b3774d52aef41b1db8ba4e
#> → MB: module checksum updated:3592efa6396266b948a4b78d751beabb
#> → MB: added element idx: 1
#> → MB: loading model idx: 2
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> → MB: model checksum updated: 7fb02099c1893f5afba085ff876bd5c5
#> → MB: module checksum updated:33be0c60ce97bdcabfc1e42bb6be5e61
#> → MB:   -> setting name: PK Biomarker
#> → MB:   -> setting time scale: days
#> → MB:   -> setting base from: user
#> → MB:   -> setting catalog selection: 
#> → MB:   -> setting base model id: manual
#> → MB:   -> setting base model name: manual
#> → MB: model checksum updated: aade4261cb88c97b0f131fc1e5f3771d
#> → MB: module checksum updated:ad8304d1868051704c4fb80dfd723147
#> → MB: added element idx: 2
#> → MB: module isgood: TRUE
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → CTS:   dest:   file.path("config","report.docx")
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → CTS:   dest:   file.path("config","report.pptx")
#> → CTS: including file
#> → CTS:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → CTS:   dest:   file.path("config","report.yaml")
#> → CTS: source model change detected
#> → CTS:  > covariates reset
#> → CTS: cohort checksum updated: a3459a098d2030272d8533d0af89f234
#> → CTS: module checksum updated: c6d681e7c09056362a8acf2ec5ed984f
#> → CTS: State initialized
#> → CTS: loading element idx: 1
#> → CTS: setting cohort name: Single dose
#> → CTS: setting model source: MB_obj_1_rx
#> → CTS: setting trial options:
#> → CTS:   - nsub: 3
#> → CTS:   - visit_times: 0
#> → CTS:   - trial_end: 100
#> → CTS:   - fpage: 1
#> → CTS:   - dvcols: Cc
#> → CTS:   - time_scale: 
#> → CTS:   - tc_dim: d2x4
#> → CTS:   - evplot: 1
#> → CTS:   - cts_config_atol: 1e-8
#> → CTS:   - cts_config_rtol: 1e-6
#> → CTS:   - cts_config_sigdig: NULL
#> → CTS:   - cts_config_seed: 5446
#> → CTS:   - cts_config_nsteps: 5
#> → CTS:   - cts_config_preamble: 
#> → CTS: cohort checksum updated: a81fc49400e47e620eaa6681bac49a1d
#> → CTS: module checksum updated: 5465c40ad33e50f82485b06b346ec5b2
#> → CTS: adding rule: first_dose
#> → CTS: add rule success
#> → CTS: rule added
#> → CTS: cohort checksum updated: 43695bc7a2a2b95c4bcd8af99e55d82e
#> → CTS: module checksum updated: a2c8825052d305544b044a928f9ceaa1
#>  
#>  
#> using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
#> using SDK: ‘’
#>  
#>  
#> using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
#> using SDK: ‘’
#> Warning: multi-subject simulation without without 'omega'
#> → CTS: CTS_simulate_element()
#> → CTS: 
#> → CTS: # Setting the random seeds
#> → CTS: set.seed(5446)
#> → CTS: rxode2::rxSetSeed(5446)
#> → CTS: 
#> → CTS: # Define the number of subjects to simulate for this cohort 
#> → CTS: CTS_obj_1_nsub = 3
#> → CTS: 
#> → CTS: # User defined functions used in the simulations
#> → CTS: CTS_obj_1_preamble = ""
#> → CTS: 
#> → CTS: # Fetching the system information
#> → CTS: CTS_obj_1_rx_details = fetch_rxinfo(MB_obj_1_rx)
#> → CTS: 
#> → CTS: # Defining covariates
#> → CTS: CTS_obj_1_cov = list()
#> → CTS: 
#> → CTS: # Generating the subjects
#> → CTS: CTS_obj_1_subs = mk_subjects(object = MB_obj_1_rx,
#> → CTS:   nsub   = CTS_obj_1_nsub,
#> → CTS:   covs   = CTS_obj_1_cov)
#> → CTS: 
#> → CTS: # Creating rules
#> → CTS: CTS_obj_1_rules = list()
#> → CTS: 
#> → CTS: CTS_obj_1_rules[["first_dose"]] = 
#> → CTS: list(condition = "time == 0", action = list(type = "dose", state = "central", 
#> → CTS:     values = "c(1)", times = "c(0)", durations = "c(0)"))
#> → CTS: 
#> → CTS: # rxSolve options
#> → CTS: CTS_obj_1_rxopts = list(
#> → CTS:   atol = 1e-8,
#> → CTS:   rtol = 1e-6,
#> → CTS:   sigdig = NULL)
#> → CTS: 
#> → CTS: # Output times
#> → CTS: CTS_obj_1_output_times = formods::linspace(0,100,5)
#> → CTS: 
#> → CTS: # Running simulation
#> → CTS: CTS_obj_1_simres =                                 
#> → CTS:  simulate_rules(object            = MB_obj_1_rx,
#> → CTS:                 subjects          = CTS_obj_1_subs[["subjects"]],
#> → CTS:                 eval_times        = c(0),
#> → CTS:                 output_times      = CTS_obj_1_output_times,
#> → CTS:                 time_scales       = MB_obj_1_ts,
#> → CTS:                 preamble          = CTS_obj_1_preamble,
#> → CTS:                 rules             = CTS_obj_1_rules,
#> → CTS:                 rx_options        = CTS_obj_1_rxopts)
#> → CTS: 
#> → CTS: # Collecting the simulation and event history values
#> → CTS: CTS_obj_1_sim_tc = CTS_obj_1_simres[["simall"]]
#> → CTS: CTS_obj_1_sim_ev = CTS_obj_1_simres[["ev_history"]]
#> → CTS: message: could not find function "model"
#> → CTS: call:    model
#> → CTS: call:    object
#> → CTS: call:    {     depot(0) = 0 }
#> → CTS: simulate failed
#> → CTS: CTS_plot_element()
#> → CTS: # Plotting timecourse
#> → CTS: CTS_obj_1_fgtc =                                 
#> → CTS:   plot_sr_tc(sro = CTS_obj_1_simres,
#> → CTS:     xcol         = "time",         
#> → CTS:     xlab_str     = "Time",         
#> → CTS:     fncol        = 4,                       
#> → CTS:     fnrow        = 2,                       
#> → CTS:     dvcols       = "Cc",
#> → CTS:     fpage        = 1)
#> → CTS: 
#> → CTS: # Plotting events
#> → CTS: CTS_obj_1_fgev =                                 
#> → CTS:   plot_sr_ev(sro = CTS_obj_1_simres,
#> → CTS:     xcol         = "time",         
#> → CTS:     xlab_str     = "Time",         
#> → CTS:     fncol        = 4,                       
#> → CTS:     fnrow        = 2,                       
#> → CTS:     evplot       = 1,
#> → CTS:     fpage        = 1)
#> → CTS: There was a problem with the simulation.
#> → CTS: simulate failed
#> → CTS: cohort checksum updated: 121a66d67fa23097cdfb8e94c308498f
#> → CTS: module checksum updated: af22c8eed3189eb810d9918e40cdee52
#> → CTS: module isgood: FALSE
#>  Failure to preload module ID: CTS
#>  failed to add element idx: 1
#>  simulation failed
#>  message: could not find function "model"
#>  call:    model
#>  call:    object
#>  call:    {     depot(0) = 0 }
#>  plot failed
#>  There was a problem with the simulation.
#> → # preload_complete is good: FALSE -----------------------------------------
#> → # failed to add element idx: 1
#> → # simulation failed
#> → # message: could not find function "model"
#> → # call:    model
#> → # call:    object
#> → # call:    {     depot(0) = 0 }
#> → # plot failed
#> → # There was a problem with the simulation.
state = sess_res$state
res = CTS_mk_preload(state)
#> → CTS: saving element (1) Single dose
#> → CTS:   -> rule dose
#> → CTS: mk_preload isgood: TRUE
# }