This package contains code to externally validate models for the prediction quesiton developed on the database .
CovCoagFullValidation is an R package.
A general guide for running a valdiation study package is available here: Skeleton Validation Study guide
# first set up the environment using the lockfile:
# If you don't have renv as an R library you need to install it:
install.packages("renv")
# renv will create an environemnt with all the R libraries and versions that
# were used by the original study developer (this is handy if the study needs to be run
# in the future when new versions are available and may have different code that
# causes a study to break)
# You need to specify a project folder for the renv (the study specific environment will be
# save here) and you need to set you R working direcory to this location before running renv
projectFolder <- "C:/CovCoagFullValidation"
if(!dir.exists(projectFolder)){
dir.create(projectFolder, recursive = T)
}
setwd(projectFolder)
# Download the lock file:
download.file("https://raw.githubusercontent.com/ohdsi-studies/CovCoagFullValidation/master/renv.lock", "renv.lock")
# Build the local library into projectFolder (takes a while):
renv::init()
# (When not in RStudio, you'll need to restart R now)
# To install the package from github:
install.packages("devtools")
devtools::install_github("ohdsi-studies/CovCoagFullValidation")
library(CovCoagFullValidation)
# add details of your database setting:
databaseName <- 'add a shareable name for the database you are currently validating on'
# add the cdm database schema with the data
cdmDatabaseSchema <- 'your cdm database schema for the validation'
# add the work database schema this requires read/write privileges
cohortDatabaseSchema <- 'your work database schema'
# if using oracle please set the location of your temp schema
oracleTempSchema <- NULL
# the name of the table that will be created in cohortDatabaseSchema to hold the cohorts
cohortTable <- 'CovCoagFullValidationCohortTable'
# the location to save the prediction models results to:
# NOTE: if you set the outputFolder to the 'Validation' directory in the
# prediction study outputFolder then the external validation will be
# saved in a format that can be used by the shiny app
outputFolder <- '../Validation'
# add connection details:
dbms <- "pdw"
user <- NULL
pw <- NULL
server <- Sys.getenv('server')
port <- Sys.getenv('port')
connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = dbms,
server = server,
user = user,
password = pw,
port = port)
# Now run the study:
CovCoagFullValidation::execute(connectionDetails = connectionDetails,
databaseName = databaseName,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
oracleTempSchema = oracleTempSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createCohorts = T,
runValidation = T,
packageResults = F,
minCellCount = 5,
sampleSize = NULL)
# If the validation study runs to completion and returns results, package it up ready to share with the study owner (but remove counts less than 10) by running:
CovCoagFullValidation::execute(connectionDetails = connectionDetails,
databaseName = databaseName,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
oracleTempSchema = oracleTempSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createCohorts = F,
runValidation = F,
packageResults = T,
minCellCount = 10,
sampleSize = NULL)
# If your target cohort is large use the sampleSize setting to sample from the cohort:
CovCoagFullValidation::execute(connectionDetails = connectionDetails,
databaseName = databaseName,
cdmDatabaseSchema = cdmDatabaseSchema,
cohortDatabaseSchema = cohortDatabaseSchema,
oracleTempSchema = oracleTempSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createCohorts = T,
runValidation = T,
packageResults = F,
minCellCount = 10,
sampleSize = 1000000)
CovCoagFullValidation is licensed under Apache License 2.0
CovCoagFullValidation is being developed in R Studio.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.