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: 5dce152d6e6a1a26a176ac0859279607
#> → MB: module checksum updated:e706d15a99b857e88a36c69a1b212a56
#>  
#>  
#>  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: a4aaa9a779f7b0f88b192f2e60864574
#> → MB: module checksum updated:9090972a184131f6e5bc401b27ef5493
#> → 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: 1fcdf4fb13af2f5f8d7333d063237a8c
#> → MB: module checksum updated:5f6948a856cfa4118ccf769551c19792
#> → 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: 115e670b238fd942381b7f14660e0c2e
#> → MB: module checksum updated:7e04dce736b824efecb9ae3727490d75
#> → 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: 698be09fca9d2b7865e9e0b5b952e20b
#> → MB: module checksum updated:61bc31f7fea500254be3c6d244a7b0bd
#> → MB: added element idx: 2
#> → MB: module isgood: TRUE
#> → CTS: source model change detected
#> → CTS:  > covariates reset
#> → CTS: cohort checksum updated: 9263d621f04df3d8132a9e567964678d
#> → CTS: module checksum updated: 45de3fe0cfbbb5b22a93bd4bbec55de8
#> → 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: d65027cab71918aac27a6c63fa8f2725
#> → CTS: module checksum updated: 66eb05d6a0c20114e1f1b72b2ddcc622
#> → CTS: adding rule: first_dose
#> → CTS: add rule success
#> → CTS: rule added
#> → CTS: cohort checksum updated: 6f8616d0b8eabf0afde7080f28100239
#> → CTS: module checksum updated: 38acbf5060f93e86c3782d9388d562a8
#>  
#>  
#>  
#>  
#> 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: cec02c7c3f936ad51382a72c369f3bc0
#> → CTS: module checksum updated: 98eda334109a0783366e826fca7c5d67
#> → 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.
# }