
Create a TTEPlan from a study specification
Source:R/tteplan_from_spec.R
tteplan_from_spec_and_registrystudy.RdBuilds a TTEPlan with a full ETT grid (enrollments x outcomes x
follow-up) from the parsed study specification and a pre-loaded
RegistryStudy. Also stores each enrollment's treatment implementation
details in the ETT data.table so they are available via
plan[[i]]$treatment_impl.
Usage
tteplan_from_spec_and_registrystudy(
study,
candidate_dir_spec,
candidate_dir_tteplan,
candidate_dir_results,
spec_version = NULL,
project_id = NULL,
n_skeleton_files = NULL,
global_max_isoyearweek = NULL,
period_width = 4L,
check_skeletons = TRUE
)Arguments
- study
A RegistryStudy R6 object, typically loaded via
registrystudy_load(). Owns the rawbatch and skeleton path candidates. A list MAY stand in for it, as the package tests do. The list MUST carryskeleton_files. Without awork_root, s1 readsdata_meta_dirfrom it for its work directory. A list has no$assert_skeletons_consistent(), so passcheck_skeletons = FALSEhere and to$s1_generate_enrollments_and_ipw(). Withglobal_max_isoyearweek = NULLand a first file namedskeleton_<n>.qs2, the list also needs$load_skeleton().- candidate_dir_spec
Character vector of candidate directories that contain the spec YAML
spec_vXXX.yaml. The first existing directory is used to locate the spec.- candidate_dir_tteplan
Character vector of candidate directories where
tteplan.qs2lives (or will be created byplan$save()).- candidate_dir_results
Character vector of candidate directories for the results BASE directory (without the version suffix – the plan appends
spec_versioninternally).- spec_version
Optional character scalar like
"v003"selecting the spec YAML. WhenNULL, read fromspec$study$implementation$version.- project_id
Optional character scalar for display/logging. When
NULL, read fromspec$study$implementation$project_prefix.- n_skeleton_files
Optional integer: if not NULL, only the first
n_skeleton_filesfiles are used (for faster dev iterations). Stored on the plan asn_skeleton_files_limitsotteplan_load()can re-apply it after a host transfer.- global_max_isoyearweek
Administrative censoring boundary (isoyearweek string, e.g., "2023-52"). If
NULL(default), auto-detected frommax(isoyearweek)in the first skeleton file. Also runstteplan_validate_spec()on that skeleton.- period_width
Integer, the width in weeks of the enrollment period (default: 4L). The same width sets each follow-up interval. Stored on the plan and passed through to TTEDesign.
- check_skeletons
Logical (default
TRUE). Run RegistryStudy$assert_skeletons_consistent()before reading any skeleton, so a half-rebuilt or stale skeleton store stops here rather than flowing into a TTE plan. It scans every sidecar in the skeleton directory, which on a large store is minutes over a network mount. PassFALSEonly for a dev iteration you do not intend to trust, typically alongsiden_skeleton_files.
Value
A TTEPlan object with the full ETT grid, embedded
registrystudy, and CandidatePath fields populated.
Details
It carries each enrollment's observation encoding and both arm tolerances
from the spec into the ETT data.table. plan[[i]]$design reads them back
onto a TTEDesign. See the observation contract section of
tteplan_read_spec().
Directory-resolution fields (dir_tteplan_cp, dir_spec_cp,
dir_results_cp) are stored on the plan as CandidatePath instances.
Stage scripts (s1.R, s2.R, s3.R, s4_export.R) can then re-load
the plan on any host with tteplan_locate_and_load() and call
plan$save(), plan$s1_generate_enrollments_and_ipw(), etc. without
re-specifying any paths.