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: 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: /private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/RtmpajgEZL/preload_8ef8402db661/user_model.R not found (skipping)
#> ! MB: User-defined model: /private/var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T/RtmpajgEZL/preload_8ef8402db661/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: dbe2b51528cd80c016e14caab704cce9
#> → MB: module checksum updated:7bd92b322e49d245920d8daac113bb26
#>  
#>  
#>  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: 03c4bee0db67bd8f526af7a9df3772e7
#> → MB: module checksum updated:8aebff15b1ec474b31590c1aebe52c0d
#> → 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: 2d736a3a9a0f0815893b7ec8d599b8b5
#> → MB: module checksum updated:d06b067e9fc68a8fbae038a2dd2a8720
#> → 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: cae61cd7b23273ac980e8eba5604eecf
#> → MB: module checksum updated:5b0c9b61d23568e60447e343110e8b25
#> → 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: f8a442963fac79351e3c7b6dab6da095
#> → MB: module checksum updated:20402c34573afa5b0b37175f7f889025
#> → 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: 38981d1da1b3c187c95de3759abed7c8
#> → CTS: module checksum updated: 81896673e7b29e992489716a29f92833
#> → 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: a4e7326112d60c98e3ac10d9432ad64c
#> → CTS: module checksum updated: 63f6042ded7947f23b114d1b7d920e25
#> → CTS: adding rule: first_dose
#> → CTS: add rule success
#> → CTS: rule added
#> → CTS: cohort checksum updated: e75b1b23ba79fb50b1f3861b21fd5400
#> → CTS: module checksum updated: 83c0a94413895e5b71c08c66a9413369
#>  
#>  
#>  
#>  
#> 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: b9d6c14298eea0d6057a03b76683b745
#> → CTS: module checksum updated: 77922ca75314a9b1631b04df9edeb3a1
#> → 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.
# }