forked from ohdsi-studies/ExampleStrategusStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EvidenceSynthesis.R
82 lines (72 loc) · 3.42 KB
/
EvidenceSynthesis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
################################################################################
# INSTRUCTIONS: The code below assumes you uploaded results to a PostgreSQL
# database per the UploadResults.R script.This script will create the
# analysis specification for running the EvidenceSynthesis module, execute
# EvidenceSynthesis, create the results tables and upload the results.
#
# Review the code below and note the "sourceMethod" parameter used in the
# esModuleSettingsCreator$createEvidenceSynthesisSource() function. If your
# study is not using CohortMethod and/or SelfControlledCaseSeries you should
# remove that from the evidenceSynthesisAnalysisList.
#
# Make sure you have set the connection details to your results database in
# scriptsForStudyCoordinator/SetConnectionDetails.R.
# ##############################################################################
library(dplyr)
library(Strategus)
source("scriptsForStudyCoordinator/SetConnectionDetails.R")
outputLocation <- "scriptsForStudyCoordinator" # Where the intermediate and output files will be written
esModuleSettingsCreator = EvidenceSynthesisModule$new()
evidenceSynthesisSourceCm <- esModuleSettingsCreator$createEvidenceSynthesisSource(
sourceMethod = "CohortMethod",
likelihoodApproximation = "adaptive grid"
)
metaAnalysisCm <- esModuleSettingsCreator$createBayesianMetaAnalysis(
evidenceSynthesisAnalysisId = 1,
alpha = 0.05,
evidenceSynthesisDescription = "Bayesian random-effects alpha 0.05 - adaptive grid",
evidenceSynthesisSource = evidenceSynthesisSourceCm
)
evidenceSynthesisSourceSccs <- esModuleSettingsCreator$createEvidenceSynthesisSource(
sourceMethod = "SelfControlledCaseSeries",
likelihoodApproximation = "adaptive grid"
)
metaAnalysisSccs <- esModuleSettingsCreator$createBayesianMetaAnalysis(
evidenceSynthesisAnalysisId = 2,
alpha = 0.05,
evidenceSynthesisDescription = "Bayesian random-effects alpha 0.05 - adaptive grid",
evidenceSynthesisSource = evidenceSynthesisSourceSccs
)
evidenceSynthesisAnalysisList <- list(metaAnalysisCm, metaAnalysisSccs)
evidenceSynthesisAnalysisSpecifications <- esModuleSettingsCreator$createModuleSpecifications(
evidenceSynthesisAnalysisList
)
esAnalysisSpecifications <- Strategus::createEmptyAnalysisSpecificiations() |>
Strategus::addModuleSpecifications(evidenceSynthesisAnalysisSpecifications)
ParallelLogger::saveSettingsToJson(
esAnalysisSpecifications,
file.path("inst/esAnalysisSpecification.json"))
resultsExecutionSettings <- Strategus::createResultsExecutionSettings(
resultsDatabaseSchema = resultsDatabaseSchema,
resultsFolder = file.path(outputLocation, "evidenceSynthesis", "strategusOutput"),
workFolder = file.path(outputLocation, "evidenceSynthesis", "strategusWork")
)
Strategus::execute(
analysisSpecifications = esAnalysisSpecifications,
executionSettings = resultsExecutionSettings,
connectionDetails = resultsConnectionDetails
)
resultsDataModelSettings <- Strategus::createResultsDataModelSettings(
resultsDatabaseSchema = resultsDatabaseSchema,
resultsFolder = resultsExecutionSettings$resultsFolder,
)
Strategus::createResultDataModel(
analysisSpecifications = esAnalysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)
Strategus::uploadResults(
analysisSpecifications = esAnalysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)