| Title: | Build Reproducible Network Studies for OMOP Common Data Model |
|---|---|
| Description: | Streamlines the setup and execution of network studies using the Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM). Creates standardised project structures with template code, manages dependencies with 'renv', provides code review utilities, and supports containerised execution with 'Docker' for reproducible multi-site studies. Includes 'GitHub' integration for collaboration and version control. |
| Authors: | Folu Akintola [aut, cre] (ORCID: <https://orcid.org/0000-0002-0588-2298>), Edward Burn [aut] (ORCID: <https://orcid.org/0000-0002-9286-1128>), Martí Català [aut] (ORCID: <https://orcid.org/0000-0003-3308-9905>), Marta Alcalde-Herraiz [ctb] (ORCID: <https://orcid.org/0009-0002-4405-1814>) |
| Maintainer: | Folu Akintola <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.1.1 |
| Built: | 2026-06-04 17:11:20 UTC |
| Source: | https://github.com/oxford-pharmacoepi/omopstudybuilder |
Build a Docker image for an OMOP study
dockeriseStudy( image_name = NULL, path = ".", useRStudio = FALSE, r_version = NULL, snapshot = TRUE, github_token = NULL )dockeriseStudy( image_name = NULL, path = ".", useRStudio = FALSE, r_version = NULL, snapshot = TRUE, github_token = NULL )
image_name |
Name for the Docker image (default: auto-detected from directory) |
path |
Path to study directory (default: current directory) |
useRStudio |
Use RStudio Server base (TRUE) or r-ver base (FALSE, default) |
r_version |
R version override (default: auto-detected from renv.lock) |
snapshot |
Update renv.lock before building (default: TRUE) |
github_token |
Optional GitHub token for installing GitHub packages during build |
Image name (invisibly - already printed to console)
Creates initial directory for an OMOP CDM network study
initStudy( directory, diagnostics = TRUE, study = TRUE, studyTitle = NULL, studyLeads = NULL, studyDescription = NULL, repository = NULL, organisation = NULL, private = TRUE )initStudy( directory, diagnostics = TRUE, study = TRUE, studyTitle = NULL, studyLeads = NULL, studyDescription = NULL, repository = NULL, organisation = NULL, private = TRUE )
directory |
Path to a directory that will be used as the root folder for the study. If it does not exist, it will be created. The directory must be empty if it already exists. |
diagnostics |
A single TRUE or FALSE value. If TRUE (the default), the function creates the 'diagnosticsCode/' and 'diagnosticsShiny/' folders using the package templates. If FALSE, these diagnostics folders are not created. |
study |
A single TRUE or FALSE value. If TRUE (the default), the function creates the 'studyCode/' and 'studyShiny/' folders using the package templates. If FALSE, these study folders are not created. |
studyTitle |
Character string with the study title. If NULL (default), uses the directory basename. |
studyLeads |
Character string with study leads. If NULL (default), leaves a placeholder. |
studyDescription |
Character string with study description. If NULL (default), leaves a placeholder. |
repository |
Optional GitHub repository name. If provided, creates a GitHub
repository and links it to the study. Requires the |
organisation |
Optional GitHub organisation name. If NULL (default), creates
repository under your personal account. Only used when |
private |
Logical. If TRUE (default), creates a private GitHub repository.
Only used when |
Project directory will be created
# Create a study called "SampleStudy" in a temporary directory study_root <- file.path(tempdir(), "SampleStudy") initStudy(study_root) # Inspect the top-level contents list.files(study_root) # Create another study with custom metadata study_root2 <- file.path(tempdir(), "DiabetesStudy") initStudy(study_root2, studyTitle = "Diabetes Prevalence Study", studyLeads = "Dr. Smith, Dr. Jones") ## Not run: # Create study with GitHub integration (requires GITHUB_PAT) # Set PAT for current session: Sys.setenv(GITHUB_PAT = "your_token_here") study_root3 <- file.path(tempdir(), "GitHubStudy") initStudy( directory = study_root3, repository = "my-omop-study", organisation = "oxford-pharmacoepi", private = TRUE ) ## End(Not run)# Create a study called "SampleStudy" in a temporary directory study_root <- file.path(tempdir(), "SampleStudy") initStudy(study_root) # Inspect the top-level contents list.files(study_root) # Create another study with custom metadata study_root2 <- file.path(tempdir(), "DiabetesStudy") initStudy(study_root2, studyTitle = "Diabetes Prevalence Study", studyLeads = "Dr. Smith, Dr. Jones") ## Not run: # Create study with GitHub integration (requires GITHUB_PAT) # Set PAT for current session: Sys.setenv(GITHUB_PAT = "your_token_here") study_root3 <- file.path(tempdir(), "GitHubStudy") initStudy( directory = study_root3, repository = "my-omop-study", organisation = "oxford-pharmacoepi", private = TRUE ) ## End(Not run)
Creates a new GitHub repository and connects it to an existing study directory. Initializes git, creates .gitignore, commits all files, and pushes to GitHub.
linkGitHub( directory, repository, organisation = NULL, private = TRUE, description = NULL )linkGitHub( directory, repository, organisation = NULL, private = TRUE, description = NULL )
directory |
Path to study directory |
repository |
GitHub repository name (will be sanitised if needed) |
organisation |
GitHub organisation name. If NULL (default), creates repo under your personal account |
private |
Logical. If TRUE (default), creates a private repository |
description |
Repository description. If NULL, auto-generated from directory name |
GitHub repository URL (invisibly)
GitHub authentication: Set up via GITHUB_PAT, gh CLI, or git credentials
R package 'gh': Install with install.packages("gh")
R package 'gert': Install with install.packages("gert")
This function needs credentials for both:
GitHub API access: used by gh to check your account and create the repository
Git transport authentication: used by gert to push the local repository to GitHub
Recommended setup:
GITHUB_PAT environment variable: recommended for HTTPS authentication and works for both GitHub API calls and Git pushes to GitHub
Stored Git credentials: credentials in your OS credential store or Git credential helper can also work for both the API and push steps
gh CLI: may help set up GitHub authentication, but you may still need Git credentials available for the final push
SSH: supported when your remote/auth setup is configured accordingly
To create a Personal Access Token (PAT):
Generate a token with repo scope
Set for current session: Sys.setenv(GITHUB_PAT = "your_token_here")
Or add to .Renviron: GITHUB_PAT='your_token_here' and restart R
## Not run: library(OmopStudyBuilder) library(here) # Authenticate (choose one method): # 1. Set GITHUB_PAT for current session Sys.setenv(GITHUB_PAT = "your_token_here") # 2. Or use gh CLI: gh auth login # Create repo under personal account linkGitHub( directory = here::here(), repository = "my-omop-study" ) # Create repo under organisation linkGitHub( directory = here::here(), repository = "diabetes-study", organisation = "oxford-pharmacoepi", private = TRUE ) ## End(Not run)## Not run: library(OmopStudyBuilder) library(here) # Authenticate (choose one method): # 1. Set GITHUB_PAT for current session Sys.setenv(GITHUB_PAT = "your_token_here") # 2. Or use gh CLI: gh auth login # Create repo under personal account linkGitHub( directory = here::here(), repository = "my-omop-study" ) # Create repo under organisation linkGitHub( directory = here::here(), repository = "diabetes-study", organisation = "oxford-pharmacoepi", private = TRUE ) ## End(Not run)
Push a Docker image to Docker Hub
pushDockerImage( image_name = NULL, repo, tag = "latest", username = NULL, password = NULL, logout = TRUE )pushDockerImage( image_name = NULL, repo, tag = "latest", username = NULL, password = NULL, logout = TRUE )
image_name |
Name of Docker image to push (default: auto-detected from directory) |
repo |
Docker Hub repository (e.g., "username/repo" or "repo") |
tag |
Tag to push (default: "latest") |
username |
Docker Hub username (prompted if NULL) |
password |
Docker Hub password or token (prompted if NULL, hidden input) |
logout |
If TRUE, logs out after pushing |
Pushed image reference (invisibly)
Summarises the code and/or renv dependencies in a study directory.
reviewStudy(dir, code = TRUE, dependencies = TRUE, type = "analysis")reviewStudy(dir, code = TRUE, dependencies = TRUE, type = "analysis")
dir |
Path to the study directory. |
code |
If 'TRUE', summarises R, JSON, CSV, and Excel files found in the directory. |
dependencies |
If 'TRUE', summarises the renv.lock dependencies. |
type |
Whether the R project is for analysis code or study reporting. Only used when 'dependencies = TRUE'. |
Invisibly returns 'NULL'. Called for its side effects of printing summaries to the console.
Note: The Docker image must include RStudio Server (i.e., be built with 'dockeriseStudy(useRStudio = TRUE)' which uses a 'rocker/rstudio' base image).
runRStudio( image_name = NULL, results_path = "./results", env_file = NULL, port = 8787, password = NULL )runRStudio( image_name = NULL, results_path = "./results", env_file = NULL, port = 8787, password = NULL )
image_name |
Name of Docker image to run (default: auto-detected from directory) |
results_path |
Path to save results (default: "./results") |
env_file |
Optional path to a .env file (passed to Docker via –env-file). If NULL and a '.env' file exists in the current working directory, it will be used automatically. |
port |
Port for RStudio Server (default: 8787, auto-finds next available if busy) |
password |
RStudio password (default: auto-generated and displayed) |
Container ID (invisibly)
Run study in automated mode with real-time log streaming
runStudy( image_name = NULL, results_path = "./results", env_file = NULL, data_path = NULL, script_path = "codeToRun.R" )runStudy( image_name = NULL, results_path = "./results", env_file = NULL, data_path = NULL, script_path = "codeToRun.R" )
image_name |
Name of Docker image to run (default: auto-detected from directory) |
results_path |
Path to save results (default: "./results") |
env_file |
Optional path to a .env file (passed to Docker via –env-file). If NULL and a '.env' file exists in the current working directory, it will be used automatically. |
data_path |
Optional path to data directory (mounted at /data) |
script_path |
Path to R script to execute (default: "codeToRun.R") |
Exit status (0 = success, non-zero = failure)
Stops containers started by runStudy() and/or runRStudio().
By default it stops containers for the image inferred from the current
directory name.
stopStudy( container = NULL, image_name = NULL, mode = c("any", "rstudio", "run"), all = FALSE )stopStudy( container = NULL, image_name = NULL, mode = c("any", "rstudio", "run"), all = FALSE )
container |
Optional container name or ID to stop directly. |
image_name |
Optional Docker image name. Defaults to current directory name. |
mode |
Which container(s) to stop: "any" (default), "rstudio", or "run". |
all |
If TRUE, stops all running containers started by OmopStudyBuilder. |
TRUE if at least one container was stopped (invisibly)