- Analytics use case(s): Characterization
- Study type: Clinical Application
- Tags: -
- Study lead: -
- Study lead forums tag: -
- Study start date: -
- Study end date: -
- Protocol: -
- Publications: -
- Results explorer: -
Can-BUILD is a Strategus study that produces incidence rates: how often each outcome of interest occurs per 100 person-years, in each calendar year.
All cohorts are defined in ATLAS and downloaded by
scriptsForStudyDesigner/DownloadAssets.R into inst/. There is no hand-written
cohort SQL in the study.
| Cohort | ID | ATLAS id | Role |
|---|---|---|---|
| Fiscal year cohort with 365 days prior observation | 1 | 1798688 | target |
| Fiscal year cohort with 1095 days prior observation | 2 | 1798701 | target |
| Dummy outcome | 3 | 1797622 | outcome (placeholder) |
Targets are the two fiscal-year cohorts: anyone with observation on 1 April of each calendar year, with the fiscal year running to the following 31 March. They differ only in how much prior observation they require (365 vs 1095 days).
Outcomes are the events being counted. Cohort 3 is a dummy outcome used to exercise the pipeline until the real outcome cohorts are defined; see Placeholders.
Analysis is done with the HADES Characterization package (v4 settings API):
| Module | What it contributes |
|---|---|
| CohortGenerator | Builds the cohorts |
| CohortDiagnostics | Checks the cohorts (inclusion rules, orphan concepts, incidence rate, ...) |
| Characterization | Baseline characteristics of each target, the incidence rates (c_incidence_summary) and a point-prevalence design |
The specification runs two designs side by side, each across 12 study periods (an unrestricted period plus 11 fiscal years from 2016/17 to 2026/27):
| Design | Washout | Time at risk |
|---|---|---|
| Incidence rate | 99999 days (one event per person) | day 1 to day 365 after cohort start |
| Point prevalence | 0 days | day 0 to day 1 after cohort start |
There is no population-level estimation and no patient-level prediction in this study, so CohortMethod, SelfControlledCaseSeries and PatientLevelPrediction are not used.
ExecuteAnalyses.R Run the study (edit the INPUTS section)
ShareResults.R Zip the results for the study coordinator
config.yml Study name, folders, results database
inst/analysisSpecifications.json Generated by CreateStrategusAnalysisSpecifications.R
inst/Cohorts.csv The ATLAS cohorts in the study (the outcome cohorts)
inst/cohorts/<id>.json Circe definitions for the outcome cohorts
inst/sql/sql_server/<id>.sql SQL definitions for the ATLAS cohorts
scriptsForStudyDesigner/ Study design: cohorts, analysis specification
scriptsForStudyCoordinator/ Results database, results model, Shiny app
template_docs/ Generic documentation for this study template
If you are running this study at your site, follow PARTICIPANT-GUIDE.md. In short:
# 1. environment (once)
renv::restore() # then restart R
# NEVER renv::snapshot() - see renv/README.md
# 2. check your database setup (or run the wizard)
source("DatabaseSetup.R")
# 3. run
source("ExecuteAnalyses.R")You never edit a checked-in file: your database details live in
config.user.yml and the password in .Renviron, both gitignored.
Settings are split by whether they are secret:
| File | Checked in? | Holds |
|---|---|---|
config.yml |
yes | Study defaults: result/work folders, file names, study name |
config.user.yml |
no | Your database server, user, schema names, JDBC driver folder |
.Renviron |
no | Your database password only |
Keeping the password out of the YAML means it cannot be committed by accident,
and config.user.yml stays readable and diffable.
Check your setup at any time, or have it set up for you:
source("DatabaseSetup.R") # checks what you have, prints exactly what to fixIf anything is missing it offers the wizard. Or call it directly:
runDatabaseWizard()Both entry points are documented in the participant guide.
source("scriptsForStudyDesigner/getStudyConfig.R")
config <- getStudyConfig() # config.yml + config.user.yml
db <- studyDatabaseSettings() # just the database settings, password resolved
details <- studyConnectionDetails() # ConnectionDetails, ready to connectA named variable, so several databases can sit side by side:
OHDSI_PASSWORD_<DATABASE_NAME>="your password"<DATABASE_NAME> is the databaseName from config.user.yml, uppercased, with
anything that is not a letter or digit replaced by _. A plain
OHDSI_DB_PASSWORD also works.
R reads .Renviron only at startup, so restart R after editing it.
DatabaseSetup.R detects the case where the variable is present in the file but
not yet loaded and tells you to restart, rather than reporting the password as
missing.
-
Install R 4.6.2 and restore the package versions pinned in
renv.lock:renv::restore()
Restart R afterwards.
renv.lockis frozen before any site execution. Sites restore it as it is; a change to the lock goes through a pull request tomainbefore sites run, never during a site run.Read renv/README.md before
renv::snapshot(). The lock file pins HADES packages the study scripts neverlibrary()directly - CohortDiagnostics, OhdsiShinyAppBuilder, OhdsiShinyModules, OhdsiReportGenerator - because the results app and the report generator need them at run time.StudyPackages.Rin the project root lists them so a snapshot keeps them; without it, a snapshot would drop them. -
Install Java 17 or newer and point
JAVA_HOMEat it (this is also set from the environment). The pinned DatabaseConnector 8.0.0 fails on Java 8 (NoSuchMethodError: java.nio.ByteBuffer.clear()). -
Create
config.user.ymland.Renvironfor your machine, by runningsource("DatabaseSetup.R")and following the prompts (see Configuration). -
Create the analysis specification (only needed after a design change):
source("scriptsForStudyDesigner/CreateStrategusAnalysisSpecifications.R")This writes
inst/analysisSpecifications.json. -
Run the study:
source("ExecuteAnalyses.R")Results are written to
results/<databaseName>/.
The scripts expect to be run from the project root, because config.yml uses
getwd() as the project folder.
On the local OHDSI Lab (a 4 GB Docker VM) the run takes about 17 minutes:
about 5.5 minutes of cohort diagnostics and 10.5 minutes of characterization.
Stop the WebAPI and Atlas containers (docker stop ohdsi-lab-webapi ohdsi-lab-atlas3) while it runs if Postgres is short of memory, and start them
again afterwards.
The primary output is
results/<databaseName>/CharacterizationModule/c_incidence_summary.csv: one row
per target cohort, outcome, age group and gender, with persons at risk, person
days, events and incidence_rate_p_100py.
Characterization numbers the target cohorts internally (10, 20, ...), so join
back to c_target_settings.csv to get the calendar year:
path <- "results/SYNTHEA10K/CharacterizationModule"
incidence <- readr::read_csv(file.path(path, "c_incidence_summary.csv"))
targets <- readr::read_csv(file.path(path, "c_target_settings.csv"))
outcomes <- readr::read_csv(file.path(path, "c_outcome_def.csv"))
overall <- incidence |>
dplyr::filter(is.na(age_group_id), is.na(gender_name)) |> # not a stratum
dplyr::left_join(
targets |> dplyr::select(characterization_target_id, target_id),
by = "characterization_target_id"
) |>
dplyr::left_join(
outcomes |> dplyr::select(outcome_id, outcome_cohort_definition_id),
by = "outcome_id"
) |>
dplyr::select(
year = target_id,
outcome = outcome_cohort_definition_id,
persons_at_risk,
person_days,
outcomes,
incidence_rate_p_100py
)ExecuteAnalyses.R is pre-filled with the local OHDSI Lab settings:
PostgreSQL 127.0.0.1:5432, database postgres, user postgres, password mypass
CDM cdm_vocab, work schema can_build
The lab keeps the clinical schema (cdm) and the vocabulary (vocab) apart,
while HADES analyses expect both in the CDM schema. cdm_vocab is a view layer
that presents them as one. It is created once with:
CREATE SCHEMA IF NOT EXISTS cdm_vocab;
DO $$
DECLARE r record;
BEGIN
FOR r IN SELECT table_name FROM information_schema.tables
WHERE table_schema = 'vocab' AND table_type = 'BASE TABLE' LOOP
EXECUTE format('CREATE OR REPLACE VIEW cdm_vocab.%I AS SELECT * FROM vocab.%I',
r.table_name, r.table_name);
END LOOP;
FOR r IN SELECT table_name FROM information_schema.tables
WHERE table_schema = 'cdm' AND table_type = 'BASE TABLE' LOOP
IF NOT EXISTS (SELECT 1 FROM information_schema.views
WHERE table_schema = 'cdm_vocab' AND table_name = r.table_name) THEN
EXECUTE format('CREATE OR REPLACE VIEW cdm_vocab.%I AS SELECT * FROM cdm.%I',
r.table_name, r.table_name);
END IF;
END LOOP;
END $$;If your site has a normal OMOP CDM with the vocabulary tables inside it, set
cdmDatabaseSchema in ExecuteAnalyses.R to that schema instead.
Cohort 3 is a dummy outcome (ATLAS 1797622). To swap in the real outcome
cohorts:
- Define them in ATLAS.
- Add them to the
cohortsToDownloadtable inscriptsForStudyDesigner/DownloadAssets.Rand run that script. It rewritesinst/Cohorts.csv,inst/cohorts/andinst/sql/sql_server/. - Point
outcomesinCreateStrategusAnalysisSpecifications.Rat the new cohort IDs and re-create the analysis specification.
The script stops if an outcome ID is not in inst/Cohorts.csv, so a mismatch is
caught immediately.