studyGenerics provides small, tested functions for common tasks in
OMOP-CDM study packages developed at the Erasmus MC Department of
Medical Informatics.
You can install studyGenerics from CRAN or the latest development version from GitHub with:
# CRAN download
install.packages("studyGenerics")
# install.packages("remotes")
remotes::install_github("mi-erasmusmc/studyGenerics")Create the standard study-package folders, scripts, tests, and
documentation. Use n_obj to set the number of objective scripts.
studyGenerics::insertStructure(
studyName = "P1-C1-001",
path = "/path/to/P1-C1-001",
n_obj = 3
)It adds the following files and folders to an existing study package:
studyPackage/
├── R/
│ ├── createCohorts.R
│ ├── runStudy.R
│ ├── runDiagnostics.R
│ ├── utils.R
│ ├── globals.R
│ ├── merge.R
│ └── objective1.R, ..., objective<n_obj>.R
├── inst/
│ ├── cohorts/
│ └── concept_sets/
├── extras/
│ ├── CodeToRun.R
│ └── pullConceptSetsFromAtlas.R
├── man/
├── tests/
│ └── testthat/test-*.R
├── LICENSE.md
├── NEWS.md
└── README.Rmd
Use pullConceptsAtlas() to save ATLAS concept-set definitions in an
explicit output directory. It requires access to the ATLAS WebAPI.
studyGenerics::pullConceptsAtlas(
conceptSetList = c(12345),
conceptSetType = "example",
outputDir = file.path(tempdir(), "concept_sets"),
baseUrl = "https://atlas.darwin-eu.org/WebAPI"
)Use the shared functions to validate data-partner names and create, archive, or extract study results.
studyGenerics::arrangeCdmNames(labels)
studyGenerics::createResultsDir(
outputDir,
dbname
)
studyGenerics::zipStudyFiles(
resultsDirName,
outputDir,
dbname
)
studyGenerics::unZipStudyFiles(
path,
pattern,
negate,
recursive,
outputDir
)Use updateColumnValues() to replace values in a summarised-result
column, for example when preparing clearer cohort labels for
presentation.
studyGenerics::updateColumnValues(
summarised_result = summarised_result,
names_map = c(
"old_cohort_name" = "Clear cohort name"
),
variable = "group_level"
)Save packages from renv.lock to renv/cellar, then use that cellar to
restore the environment on a machine without internet access.
# Save packages in an explicit cellar directory
studyGenerics::packageCellar(path = file.path(tempdir(), "cellar"))
# Restore packages into an explicit library directory
studyGenerics::installCellar(
path = file.path(tempdir(), "cellar"),
library = file.path(tempdir(), "library")
)Configure GITHUB_PAT in .Renviron, then create an issue and branch,
open a pull request, and return to the latest develop branch.
# Create a GitHub issue and check out a branch named after it
studyGenerics::issueOpen(
title = "Add study outcome",
body = "Describe the planned change.",
newBranch = TRUE
)
# After committing and pushing the branch, create a pull request to develop
studyGenerics::pullRequest(
title = "Add study outcome",
body = "Describe the implemented change.",
base = "develop"
)
# After the pull request is merged, return to the latest develop branch
studyGenerics::devCheckout()