The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

initStudy

Introduction

initStudy() is the starting point for building a study project with the OMOP Common Data Model (CDM) using the OmopStudyBuilder package.

It generates a fully structured project folder containing:

This allows you to immediately focus on writing study-specific code instead of manually assembling the surrounding infrastructure.

In this vignette you will learn how to:


Basic usage

The simplest way to use initStudy() is to provide a directory path. If the directory:

To avoid modifying your real project directories, this vignette uses a temporary folder.

# Create a temporary root for this vignette
study_root <- file.path(tempdir(), "SampleStudy")

initStudy(study_root)

# Show top-level contents created by initStudy()
list.files(study_root)
#> [1] "INSTRUCTIONS.md"  "README.md"        "diagnosticsCode"  "diagnosticsShiny"
#> [5] "studyCode"        "studyShiny"

You should see something like:

To inspect the full structure:

list.files(study_root, recursive = TRUE)
#>  [1] "INSTRUCTIONS.md"                             
#>  [2] "README.md"                                   
#>  [3] "diagnosticsCode/README.md"                   
#>  [4] "diagnosticsCode/codeToRun.R"                 
#>  [5] "diagnosticsCode/cohorts/instantiateCohorts.R"
#>  [6] "diagnosticsCode/diagnosticsCode.Rproj"       
#>  [7] "diagnosticsCode/results/README.md"           
#>  [8] "diagnosticsCode/runStudy.R"                  
#>  [9] "diagnosticsShiny/README.md"                  
#> [10] "diagnosticsShiny/diagnosticsShiny.Rproj"     
#> [11] "studyCode/README.md"                         
#> [12] "studyCode/analyses/cohortCharacteristics.R"  
#> [13] "studyCode/analyses/cohortSurvival.R"         
#> [14] "studyCode/analyses/drugUtilisation.R"        
#> [15] "studyCode/analyses/incidencePrevalence.R"    
#> [16] "studyCode/codeToRun.R"                       
#> [17] "studyCode/codelist/codelistCreation.R"       
#> [18] "studyCode/cohorts/instantiateCohorts.R"      
#> [19] "studyCode/results/README.md"                 
#> [20] "studyCode/runStudy.R"                        
#> [21] "studyCode/studyCode.Rproj"                   
#> [22] "studyShiny/README.md"                        
#> [23] "studyShiny/studyShiny.Rproj"

Diagnostics-only and study-only setups

You can control which parts of the template are created with the diagnostics and study arguments.

Diagnostics-only project

diag_root <- file.path(tempdir(), "DiagnosticsOnly")

initStudy(
  directory   = diag_root,
  diagnostics = TRUE,
  study       = FALSE
)

list.files(diag_root)
#> [1] "INSTRUCTIONS.md"  "README.md"        "diagnosticsCode"  "diagnosticsShiny"

Study-only project (no diagnostics templates)

study_only_root <- file.path(tempdir(), "StudyOnly")

initStudy(
  directory   = study_only_root,
  diagnostics = FALSE,
  study       = TRUE
)

list.files(study_only_root)
#> [1] "INSTRUCTIONS.md" "README.md"       "studyCode"       "studyShiny"

What to do after initStudy()

After generating the project structure, you will mainly work with these folders and files:


Building and Distributing Your Study

Once your study code is ready, OmopStudyBuilder provides functions to package it into a Docker image and distribute it to data partners.

Building the Docker Image

# Build a Docker image containing your study code
dockeriseStudy(
  image_name = "omop-study-study-code",
  path = file.path(study_root, "studyCode")
)
#> Building Docker image: omop-study-study-code
#> This may take some minutes on first build...
#> ✔ Image built successfully: omop-study-study-code

The image contains: - Your exact R version - All package dependencies (from renv.lock) - Your study code - Database drivers and system dependencies

Distribution Options

Option 1: Docker Hub (Online)

Push to Docker Hub for easy sharing with connected partners:

pushDockerImage(
  image_name = "omop-study-study-code",
  repo = "yourusername/myomopstudy"
)
#> ✔ Image pushed to Docker Hub!

Data partners can then pull and run the image.

They can then run either an interactive RStudio Server session, or run the study in automated mode.

library(OmopStudyBuilder)

# Interactive (requires image built with dockeriseStudy(useRStudio = TRUE)):
runRStudio(
  image_name = "yourusername/myomopstudy:latest",
  results_path = "./results"
)

Interactive vs Automated Execution

RStudio Server runs the Docker image and opens a browser to the RStudio Server URL:

# Requires image built with dockeriseStudy(useRStudio = TRUE)
runRStudio(
  image_name = "omop-study-study-code",
  results_path = "./results"
)

Partners edit credentials in codeToRun.R and run the study interactively.

Automated execution (for programmatic workflows):

runStudy(
  image_name = "omop-study-study-code",
  results_path = "./results",
  data_path = "path/to/data"
)

To stop any running OmopStudyBuilder containers, use:

stopStudy(image_name = "omop-study-study-code")

For more operational details, see the README files generated into your study folders (for example studyCode/README.md and diagnosticsCode/README.md).


These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.