- Execute the study by running the code in (extras/CodeToRun.R) :
library(SkeletonPredictionStudy)
# USER INPUTS
#=======================
# The folder where the study intermediate and result files will be written:
outputFolder <- "C:/SkeletonPredictionStudyResults"
# Details for connecting to the server:
dbms <- "you dbms"
user <- 'your username'
pw <- 'your password'
server <- 'your server'
port <- 'your port'
connectionDetails <- DatabaseConnector::createConnectionDetails(dbms = dbms,
server = server,
user = user,
password = pw,
port = port)
# Add the database containing the OMOP CDM data
cdmDatabaseSchema <- 'cdm database schema'
# Add a sharebale name for the database containing the OMOP CDM data
cdmDatabaseName <- 'a friendly shareable name for your database'
# Add a database with read/write access as this is where the cohorts will be generated
cohortDatabaseSchema <- 'work database schema'
oracleTempSchema <- NULL
# table name where the cohorts will be generated
cohortTable <- 'SkeletonPredictionStudyCohort'
# replace NULL with number to sample if needed
sampleSize <- NULL
#=======================
execute(connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
cdmDatabaseName = cdmDatabaseName,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
oracleTempSchema = oracleTempSchema,
outputFolder = outputFolder,
createProtocol = F,
runDiagnostic = F,
viewDiagnostic = F,
createCohorts = T,
runAnalyses = T,
createResultsDoc = F,
packageResults = F,
createValidationPackage = F,
minCellCount= 5,
sampleSize = sampleSize)
The 'createCohorts' option will create the target and outcome cohorts into cohortDatabaseSchema.cohortTable if set to T. The 'runAnalyses' option will create/extract the data for each prediction problem setting (each Analysis), develop a prediction model, internally validate it if set to T. The results of each Analysis are saved in the 'outputFolder' directory under the subdirectories 'Analysis_1' to 'Analysis_N', where N is the total analyses specified. After running execute with 'runAnalyses set to T, a 'Validation' subdirectory will be created in the 'outputFolder' directory where you can add the external validation results to make them viewable in the shiny app or journal document that can be automatically generated.
- You can now view the models by running:
PatientLevelPrediction::viewMultiplePlp(outputFolder)
- You can then easily transport all the trained models into a network validation study package by running:
execute(connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
cdmDatabaseName = cdmDatabaseName,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createValidationPackage = T)
- To pick specific models (e.g., models from Analysis 1 and 3) to export to a validation study run:
execute(connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
cdmDatabaseName = cdmDatabaseName,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createValidationPackage = T,
analysesToValidate = c(1,3))
This will create a new subdirectory in 'outputFolder' that has the name Validation. For example, if your prediction study package was named 'bestPredictionEver' and you run the execute with 'createValidationPackage' set to T with 'outputFolder'= 'C:/myResults', then you will find a new R package at the directory: 'C:/myResults/bestPredictionEverValidation'. This package can be executed similarly but will validate the developed model/s rather than develop new model/s. If you set the validation package outputFolder to the Validation directory of the prediction package results (e.g., 'C:/myResults/Validation'), then the results will be saved in a way that can be viewed by shiny.
- To create the shiny app for sharing on data.ohdsi.org, run the following after successfully developing the models (you will then need to add the shiny app directory to the OHDSI github shinyDeploy repository):
execute(connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
cdmDatabaseName = cdmDatabaseName,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createShiny = T,
minCellCount= 5)
If you saved the validation results into the validation folder in the directory you called 'outputFolder' in the structure: '/Validation//Analysis_N' then shiny and the journal document creator will automatically include any validation results. The validation package will automatically save the validation results in this structure if you set the outputFolder for the validation results to: '/Validation'.
- To create the journal document for the Analysis 1:
execute(connectionDetails = connectionDetails,
cdmDatabaseSchema = cdmDatabaseSchema,
cdmDatabaseName = cdmDatabaseName,
cohortDatabaseSchema = cohortDatabaseSchema,
cohortTable = cohortTable,
outputFolder = outputFolder,
createJournalDocument = F,
analysisIdDocument = 1
minCellCount= 5)