Skip to contents

Populates the supplied session variable for testing.

Usage

CTS_test_mksession(session = list(), full = FALSE)

Arguments

session

Shiny session variable (in app) or a list (outside of app)

full

Boolean indicating if the full test session should be created (TRUE) or a minimal test session should be created (FALSE, default)

Value

The CTS portion of the all_sess_res returned from FM_app_preload

See also

Examples

# \donttest{
session = shiny::MockShinySession$new()
sess_res = CTS_test_mksession(session=session)
#> → 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: 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: b347d1eaa2f3fb13070dd39eb2355e8d
#> → MB: module checksum updated:3edefe9cb1f5dfbd2d0de792c59e00cb
#>  
#>  
#>  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: 89c05dd5188dde953e080581a589d1b4
#> → MB: module checksum updated:e574c2da31df9cff5487fd4e981a5cae
#> → 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: 2a6a6832ace992b8f3d776574f95b6a5
#> → MB: module checksum updated:6f1d44a152d0d19e6a31b955d8b6f2cb
#> → 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: 827ba813f14595ec7b98b72c394f917e
#> → MB: module checksum updated:ff26039dc24ae865799607c53cd5db61
#> → 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: e77214b9bc3968749b9060306ea23527
#> → MB: module checksum updated:4ac101ed29b1213c6343f70bacfcc4af
#> → MB: added element idx: 2
#> → MB: module isgood: TRUE
#> → CTS: source model change detected
#> → CTS:  > covariates reset
#> → CTS: cohort checksum updated: e8830bd4c053e576cec4f5e1d6e68596
#> → CTS: module checksum updated: 82d7cd510c833086e5a4c94a989dce8c
#> → 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: 7af6fad94b71377562f053bd13ee1ca6
#> → CTS: module checksum updated: 5b2d2ff6d4acf44c786647dbe6482c5e
#> → CTS: adding rule: first_dose
#> → CTS: add rule success
#> → CTS: rule added
#> → CTS: cohort checksum updated: e262a2f32370ed31e7fb024ea96d313b
#> → CTS: module checksum updated: 346b398f1e8bd3476af5baaf56fc79ec
#>  
#>  
#>  
#>  
#> 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: 5b44727636856dbc4683ec526125122f
#> → CTS: module checksum updated: 33e92215ec8c65723df19c744f03307a
#> → 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.
# }