extras/createJSON/Table1PredSkelJson.R

# code to create the json prediction:
webApi <- # To be completed

populationSettings <- list(PatientLevelPrediction::createStudyPopulationSettings(binary = T, 
                                                                                 includeAllOutcomes = T, 
                                                                                 firstExposureOnly = T, 
                                                                                 washoutPeriod = 365, 
                                                                                 removeSubjectsWithPriorOutcome = T, 
                                                                                 priorOutcomeLookback = 99999, 
                                                                                 requireTimeAtRisk = T, 
                                                                                 minTimeAtRisk = 1824, 
                                                                                 riskWindowStart = 1, 
                                                                                 startAnchor = 'cohort start', 
                                                                                 endAnchor = 'cohort start', 
                                                                                 riskWindowEnd = 1825, 
                                                                                 verbosity = 'INFO',
                                                                                 addExposureDaysToEnd = F,
                                                                                 addExposureDaysToStart = F))
modelList <- list(list("LassoLogisticRegressionSettings" = list("variance" = 0.01))
)
covariateSettings <- list(list(list(fnct = 'createCovariateSettings',
                                    settings = FeatureExtraction::createCovariateSettings(useDemographicsGender = T,
                                                                                          useDemographicsAge = T,
                                                                                          useDemographicsAgeGroup = T)),
                               list(fnct = 'createCohortCovariateSettings', 
                                    settings = list(covariateName = 'Cancer', 
                                                    covariateId = 22322,
                                                    cohortId = 22322,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'COPD', 
                                                    covariateId = 22323,
                                                    cohortId = 22323,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Diabetes', 
                                                    covariateId = 22324,
                                                    cohortId = 22324,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Heart disease', 
                                                    covariateId = 22325,
                                                    cohortId = 22325,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Hypertension', 
                                                    covariateId = 22326,
                                                    cohortId = 22326,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Hyperlipidemia', 
                                                    covariateId = 22327,
                                                    cohortId = 22327,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Kidney disease', 
                                                    covariateId = 22328,
                                                    cohortId = 22328,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Depression', 
                                                    covariateId = 22329,
                                                    cohortId = 22329,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)),
                               list(fnct = 'createCohortCovariateSettings',
                                    settings = list(covariateName = 'Ischemic stroke', 
                                                    covariateId = 22330,
                                                    cohortId = 22330,
                                                    startDay= -99999,
                                                    endDay= 0,
                                                    count=F, 
                                                    ageInteraction = F)))
)

# resrictOutcomePops <- data.frame(outcomeId = c(16428,16435),
#                                  populationSettingId = c(1,2))
# resrictModelCovs = data.frame(modelSettingId = c(1,1,2),
#                               covariateSettingId = c(1,2,1))

executionSettings <- list(washoutPeriod = 365,
                          minCovariateFraction = 0.001,
                          normalizeData = T,
                          testSplit = "stratified",
                          testFraction = 0.25,
                          splitSeed = 1000,
                          nfold = 3)

json <- createDevelopmentStudyJson(packageName = 'EmcDementiaPredictionTable1',
                                   packageDescription = 'A package to populate journal Table 1',
                                   createdBy = 'Henrik John',
                                   organizationName = 'Erasmus MC',
                                   targets = data.frame(targetId = c(22337),
                                                        cohortId = c(22337),
                                                        targetName = c('Target')),
                                   outcomes = data.frame(outcomeId = c(7414),
                                                         cohortId = c(7414),
                                                         outcomeName = c('Outcome')),
                                   populationSettings = populationSettings,
                                   modelList = modelList,
                                   covariateSettings = covariateSettings,
                                   resrictOutcomePops = NULL,
                                   resrictModelCovs = NULL,
                                   executionSettings = executionSettings,
                                   webApi = webApi,
                                   outputLocation = 'D:/hjohn/Table1',
                                   jsonName = 'predictionAnalysisList.json')

specifications <- Hydra::loadSpecifications(file.path('D:/hjohn/Table1', 'predictionAnalysisList.json'))
Hydra::hydrate(specifications = specifications, outputFolder = 'D:/hjohn/Table1/EmcDementiaPredictionTable1')
mi-erasmusmc/EmcDementiaPredictionTable1 documentation built on Dec. 21, 2021, 5:55 p.m.