generated from ohdsi-studies/EmptyStudyRepository
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathevidenceSynthesis.R
74 lines (65 loc) · 2.86 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
library(dplyr)
library(Strategus)
outputLocation <- 'D:/git/ohdsi-studies/SemaglutideNaion'
# Specify the connection to the results database
resultsConnectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = 'postgresql',
user = keyring::key_get("OHDSI_RESULTS_USER"),
password = keyring::key_get("OHDSI_RESULTS_PASSWORD"),
server = keyring::key_get("OHDSI_RESULTS_SERVER")
)
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)
if (!dir.exists(outputLocation)) {
dir.create(outputLocation, recursive = TRUE)
}
ParallelLogger::saveSettingsToJson(esAnalysisSpecifications, file.path(outputLocation, "inst/esAnalysisSpecification.json"))
resultsExecutionSettings <- Strategus::createResultsExecutionSettings(
resultsDatabaseSchema = "semanaion",
resultsFolder = file.path(outputLocation, "results", "evidence_sythesis", "results_folder"),
workFolder = file.path(outputLocation, "results", "evidence_sythesis", "work_folder")
)
Strategus::execute(
analysisSpecifications = esAnalysisSpecifications,
executionSettings = resultsExecutionSettings,
connectionDetails = resultsConnectionDetails
)
resultsDataModelSettings <- Strategus::createResultsDataModelSettings(
resultsDatabaseSchema = "semanaion",
resultsFolder = resultsExecutionSettings$resultsFolder,
)
Strategus::createResultDataModel(
analysisSpecifications = esAnalysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)
Strategus::uploadResults(
analysisSpecifications = esAnalysisSpecifications,
resultsDataModelSettings = resultsDataModelSettings,
resultsConnectionDetails = resultsConnectionDetails
)