Skip to contents

Loads the plan in dir_tteplan, runs the stage method, then runs the steps that follow it. This is the body of the per-project s1.R, s2.R, s3.R and feasibility stage scripts as one call.

Usage

tte_stage(stage, dir_tteplan, ...)

Arguments

stage

One of "s1", "s2", "s3" or "feasibility".

dir_tteplan

Character vector of candidate directories, in priority order, where tteplan.qs2 lives. Passed to tteplan_locate_and_load(), which takes the first one that exists.

...

Arguments for the stage method. Each one MUST be named.

Value

The TTEPlan, invisibly.

Details

The stage id selects the method and the steps after it:

stagemethodsteps after the method
"s1"$s1_generate_enrollments_and_ipw()$save(), then $print_target_checklist()
"s2"$s2_generate_analysis_files_and_ipcw_pp()$save()
"s3"$s3_analyze()$results_summary(), $save(), then $print_target_checklist()
"feasibility"$s3_feasibility()$save()

Each call loads the plan from disk, and a Slurm job runs one stage per process. So every stage MUST save the plan. s2 stamps each ETT with its s2 run, and s3 refuses an ETT without that stamp.

Every element of ... MUST carry a name. tte_stage() matches each name against the formals of the stage method, and forwards by name.

The four methods take their arguments in different orders, and none of them takes .... A positional forward binds the wrong formal and reports no error. Naming every argument is what makes the forward safe.

Why an unknown name fails early

tte_stage() rejects a name that the stage method does not declare BEFORE it calls tteplan_locate_and_load(). That load reads the plan from a network share and is slow. A mistyped argument name therefore costs no load. do.call() would also reject the name, but only after the load.

The formals come from the TTEPlan generator, so the check needs no plan.

See also

Examples

if (FALSE) { # \dontrun{
swereg::tte_stage(
  "s1",
  "~/plans/003-iliadis-stroke",
  n_workers = 6L,
  swereg_dev_path = NULL
)
} # }