Skip to content

Commit

Permalink
Merge pull request #2 from ohdsi-studies/develop
Browse files Browse the repository at this point in the history
v1.0.0 release
  • Loading branch information
rossdwilliams committed Nov 6, 2023
2 parents c50be92 + 232f4d0 commit b7cb3d2
Show file tree
Hide file tree
Showing 14 changed files with 6,008 additions and 113 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: EhdenAlopecia
Version: 0.1
Version: 1.0.0
Authors@R: person("Ross", "Williams", , "r.williams@derasmusmc.nl", role = c("aut", "cre"))
Description: This package creates the cohorts for this EHDEN Alopecia study study. Based on this cohort diagnostics, incidence and prevalence rates and treatment patterns are analysis are performed.
License: Apache License (>= 2)
Expand All @@ -15,12 +15,13 @@ Imports:
zip,
magrittr,
checkmate,
duckdb,
log4r,
lubridate,
rlang
rlang,
readr
Suggests:
testthat (>= 3.0.0),
rmarkdown,
checkmate
checkmate,
duckdb,
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NAMESPACE
@@ -1,4 +1,6 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(createCohorts)
export(runStudy)
importFrom(magrittr,"%>%")
6 changes: 3 additions & 3 deletions R/createCohorts.R
Expand Up @@ -4,9 +4,8 @@
#' @param cohortTable Name of the table to be created where cohorts will be stored
#' @param cdmDatabaseSchema name of the schema where the cdm is stored
#' @param cohortDatabaseSchema name of a schema with write access for the creation of cohort table
#' @return
#'
#' @examples
#' @export
createCohorts <- function(connectionDetails,
cohortTable,
cdmDatabaseSchema,
Expand All @@ -29,7 +28,7 @@ createCohorts <- function(connectionDetails,
cohortJson <- readChar(cohortJsonFileName, file.info(cohortJsonFileName)$size)
cohortExpression <- CirceR::cohortExpressionFromJson(cohortJson)
cohortSql <- CirceR::buildCohortQuery(cohortExpression, options = CirceR::createGenerateOptions(generateStats = FALSE))
cohortsToCreate <- rbind(cohortsToCreate, data.frame(cohortId = i,
cohortsToCreate <- rbind(cohortsToCreate, data.frame(cohortId = 91+i,
cohortName = cohortName,
sql = cohortSql,
stringsAsFactors = FALSE))
Expand All @@ -54,4 +53,5 @@ createCohorts <- function(connectionDetails,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTableNames$cohortTable)
print(cohortCounts)
return(cohortsGenerated)
}
36 changes: 25 additions & 11 deletions R/runStudy.R
@@ -1,8 +1,26 @@
runStudy <- function(connectionDetails,
#' run the main elements of the study
#'
#' @param connectionDetails connection details generated using DatabaseConnector::createConnectionDetails()
#' @param cohortTable Name of the table to be created where cohorts will be stored
#' @param cdmDatabaseSchema name of the schema where the cdm is stored
#' @param cohortDatabaseSchema name of a schema with write access for the creation of cohort table
#' @param instantiateCohorts choose whether to instantiate the cohorts on your database
#' @param runDiagnostics choose whether to run the cohort diagnostics
#' @param outputFolder The folder where the results should be written
#' @param databaseId a short name that can identify the database used
#' @param minCellCount the minimum number of patients that can be shared for any single count in the results
#'
#' @export

runStudy <- function(connectionDetails,
cohortTable,
cdmDatabaseSchema,
cohortDatabaseSchema,
instantiateCohorts) {
instantiateCohorts = FALSE,
runDiagnostics = FALSE,
outputFolder,
databaseId,
minCellCount) {

if (instantiateCohorts){
createCohorts(connectionDetails = connectionDetails,
Expand All @@ -12,19 +30,15 @@ runStudy <- function(connectionDetails,
}

if (runDiagnostics){
executeDiagnostics(cohortDefinitionSet,
cohortDefinitionSet <- readr::read_csv("inst/cohortDefinitionSet.csv")
CohortDiagnostics::executeDiagnostics(cohortDefinitionSet = cohortDefinitionSet,
connectionDetails = connectionDetails,
cohortTable = cohortTable,
cohortDatabaseSchema = cohortDatabaseSchema,
cdmDatabaseSchema = cdmDatabaseSchema,
exportFolder = exportFolder,
databaseId = "MyCdm",
minCellCount = 5
)
CohortGenerator::dropCohortStatsTables(
connectionDetails = connectionDetails,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTableNames = cohortTableNames
exportFolder = outputFolder,
databaseId = databaseId,
minCellCount = minCellCount
)
}
}
116 changes: 115 additions & 1 deletion README.md
@@ -1 +1,115 @@
# EhdenAlopecia
# EHDEN Alopecia

Analytic software to perform large-scale distributed analysis of patients with Alopecia as part of the EHDEN study-athon

<img src="https://img.shields.io/badge/Study%20Status-Started-blue.svg" alt="Study Status: Started">

- Analytics use case(s): Population-Level Estimation
- Study type: Clinical Application
- Tags: -
- Study lead:
- Study lead forums tag:
- Study start date: 1 November 2023
- Study end date: -
- Protocol: To be added
- Publications: -
- Results explorer: -

# Requirements


A database in Common Data Model version 5 in one of these platforms: SQL Server, Oracle, PostgreSQL, IBM Netezza, Apache Impala, Amazon RedShift, Google BigQuery, or Microsoft APS.
R version 4.0.5
On Windows: RTools
Java
100 GB of free disk space

# How to run
See the instructions at https://ohdsi.github.io/Hades/rSetup.html for configuring your R environment, including Java and RStudio.

Clone the EhdenAlopecia package into your local R environment.

Open your study package in RStudio. Use the following code to install all the dependencies:
```R
install.packages(c("DBI",
"dplyr",
"glue",
"zip",
"magrittr",
"checkmate",
"log4r",
"lubridate",
"rlang",
"readr")
)
```

In RStudio, select 'Build' then 'Install and Restart' to install the package.

After succesfully installing the package. Open the extras/codeTorun.R and run the following code

```R
#Load the library

library(EhdenAlopecia)
# database metadata and connection details -----
# The name/ acronym for the database
databaseId <- ""

# Database connection details -----
#connection details
#User specified input


# Details for connecting to the server:
dbms <- ""
user <- ""
pw <- ""
server <- ""
port <- ""

connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = dbms,
server = server,
user = user,
password = pw,
port = port)


cdmDatabaseSchema <- ""
cohortDatabaseSchema <- ""


# Name of table prefix to use in the result schema for tables created during the study.
# Notes:
# - if there is an existing table in your results schema with the same names it
# will be overwritten
# - name must be lower case
cohortTable <- "alopecia_ehden"


# minimum counts that can be displayed according to data governance
minCellCount <- 5

#specify where to save the results
outputFolder <- "results"


#choose analysis to run
instantiateCohorts <- TRUE
runDiagnostics <- TRUE


### Do not edit below here

EhdenAlopecia::runStudy(
connectionDetails = connectionDetails,
cohortTable = cohortTable,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
instantiateCohorts = instantiateCohorts,
runDiagnostics = runDiagnostics,
outputFolder = outputFolder,
databaseId = databaseId,
minCellCount = minCellCount
)
```
100 changes: 57 additions & 43 deletions extras/codeToRun.R
Expand Up @@ -15,69 +15,83 @@
# SECTION 1: Installing
# *******************************************************
#
# 1. See the instructions at https://ohdsi.github.io/Hades/rSetup.html for configuring your R environment, including Java and RStudio.
#
# 2. In RStudio, create a new project by cloning https://github.com/darwin-eu-studies/P1C3001AsthmaBackgroundRates
#
# 3. Install renv package
install.packages("renv")
#
# 4. Build the local library. This may take a while:
renv::restore()
#
# 5. Build the R package in the Build menu -> Install
# See the instructions at https://ohdsi.github.io/Hades/rSetup.html for configuring your R environment, including Java and RStudio.
# Follow these instructions for setting up your R environment, including RTools and Java.

# Clone the EhdenAlopecia package into your local R environment.

# Open your study package in RStudio. Use the following code to install all the dependencies:

# In RStudio, select 'Build' then 'Install and Restart' to install the package.

# After succesfully installing the package, run the following code

# *******************************************************
# SECTION 2: Running the package -------------------------------------------------------------------------------
# *******************************************************
#
# Edit the variables below to the correct values for your environment:

#Load the library

# library(testthat)

library(EhdenAlopecia)
# database metadata and connection details -----
# The name/ acronym for the database
# IMPORTANT: to use names CPRD, IMASIS, IPCI, IQVIA_GERMANY_DA, SIDIAP for these databases.
dbName <- " "
databaseId <- ""

# Database connection details -----
# In this study we also use the DBI package to connect to the database
# set up the dbConnect details below (see https://dbi.r-dbi.org/articles/dbi for
# more details)
# you may need to install another package for this
# eg for postgres
# conn <- dbConnect(
# RPostgres::Postgres(),
# dbname = server_dbi,
# port = port,
# host = host,
# user = user,
# password = password
# )
conn <- DBI::dbConnect("....")

# The name of the schema that contains the OMOP CDM with patient-level data
cdmDatabaseSchema <- "...."

# The name of the schema where results tables will be created
resultsDatabaseSchema <- "...."
#connection details
#User specified input


# Details for connecting to the server:
dbms <- ""
user <- ""
pw <- ""
server <- ""
port <- ""

connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = dbms,
server = server,
user = user,
password = pw,
port = port)


cdmDatabaseSchema <- ""
cohortDatabaseSchema <- ""


# Name of table prefix to use in the result schema for tables created during the study.
# Notes:
# - if there is an existing table in your results schema with the same names it
# will be overwritten
# - name must be lower case
tablePrefix <- ""
cohortTable <- "alopecia_ehden"


# minimum counts that can be displayed according to data governance
minimumCounts <- 5
minCellCount <- 5

#specify where to save the results
outputFolder <- "results"


#choose analysis to run
instantiateCohorts <- TRUE
runDiagnostics <- FALSE
runDiagnostics <- TRUE


### Do not edit below here

runStudy(connectionDetails,
cohortTable,
cdmDatabaseSchema,
cohortDatabaseSchema,
instantiateCohorts)
EhdenAlopecia::runStudy(
connectionDetails = connectionDetails,
cohortTable = cohortTable,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
instantiateCohorts = instantiateCohorts,
runDiagnostics = runDiagnostics,
outputFolder = outputFolder,
databaseId = databaseId,
minCellCount = minCellCount
)
Binary file removed inst/__MACOSX/._cohorts
Binary file not shown.

0 comments on commit b7cb3d2

Please sign in to comment.