-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSettingsFunctions.R
143 lines (132 loc) · 4.86 KB
/
SettingsFunctions.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# This file has been autogenerated in 'extras/ModuleMaintenance.R'. Do not change by hand.
createCharacterizationModuleSpecifications <- function(
targetIds,
outcomeIds, # a vector of ids
outcomeWashoutDays = c(365), # same length as outcomeIds with the outcomeWashout
minPriorObservation = 365,
dechallengeStopInterval = 30,
dechallengeEvaluationWindow = 30,
riskWindowStart = c(1, 1),
startAnchor = c("cohort start", "cohort start"),
riskWindowEnd = c(0, 365),
endAnchor = c("cohort end", "cohort end"),
minCharacterizationMean = 0.01,
covariateSettings = FeatureExtraction::createCovariateSettings(
useDemographicsGender = T,
useDemographicsAge = T,
useDemographicsAgeGroup = T,
useDemographicsRace = T,
useDemographicsEthnicity = T,
useDemographicsIndexYear = T,
useDemographicsIndexMonth = T,
useDemographicsTimeInCohort = T,
useDemographicsPriorObservationTime = T,
useDemographicsPostObservationTime = T,
useConditionGroupEraLongTerm = T,
useDrugGroupEraOverlapping = T,
useDrugGroupEraLongTerm = T,
useProcedureOccurrenceLongTerm = T,
useMeasurementLongTerm = T,
useObservationLongTerm = T,
useDeviceExposureLongTerm = T,
useVisitConceptCountLongTerm = T,
useConditionGroupEraShortTerm = T,
useDrugGroupEraShortTerm = T,
useProcedureOccurrenceShortTerm = T,
useMeasurementShortTerm = T,
useObservationShortTerm = T,
useDeviceExposureShortTerm = T,
useVisitConceptCountShortTerm = T,
endDays = 0,
longTermStartDays = -365,
shortTermStartDays = -30
),
caseCovariateSettings = Characterization::createDuringCovariateSettings(
useConditionGroupEraDuring = T,
useDrugGroupEraDuring = T,
useProcedureOccurrenceDuring = T,
useDeviceExposureDuring = T,
useMeasurementDuring = T,
useObservationDuring = T,
useVisitConceptCountDuring = T
),
casePreTargetDuration = 365,
casePostOutcomeDuration = 365,
incremental = T
) {
# input checks
if(!inherits(outcomeIds, "numeric")){
stop("outcomeIds must be a numeric or a numeric vector")
}
if(!inherits(outcomeWashoutDays, "numeric")){
stop("outcomeWashoutDays must be a numeric or a numeric vector")
}
if(length(outcomeIds) != length(outcomeWashoutDays)){
stop("outcomeWashoutDaysVector and outcomeIds must be same length")
}
if(length(minPriorObservation) != 1){
stop("minPriorObservation needs to be length 1")
}
if(length(riskWindowStart) != length(startAnchor) |
length(riskWindowEnd) != length(startAnchor) |
length(endAnchor) != length(startAnchor))
{
stop("Time-at-risk settings must be same length")
}
# group the outcomeIds with the same outcomeWashoutDays
outcomeWashoutDaysVector <- unique(outcomeWashoutDays)
outcomeIdsList <- lapply(
outcomeWashoutDaysVector,
function(x){
ind <- which(outcomeWashoutDays == x)
unique(outcomeIds[ind])
}
)
timeToEventSettings <- Characterization::createTimeToEventSettings(
targetIds = targetIds,
outcomeIds = outcomeIds
)
dechallengeRechallengeSettings <- Characterization::createDechallengeRechallengeSettings(
targetIds = targetIds,
outcomeIds = outcomeIds,
dechallengeStopInterval = dechallengeStopInterval,
dechallengeEvaluationWindow = dechallengeEvaluationWindow
)
aggregateCovariateSettings <- list()
for(i in 1:length(riskWindowStart)){
for(j in 1:length(outcomeIdsList)){
aggregateCovariateSettings[[length(aggregateCovariateSettings) + 1]] <- Characterization::createAggregateCovariateSettings(
targetIds = targetIds,
outcomeIds = outcomeIdsList[[j]],
minPriorObservation = minPriorObservation,
outcomeWashoutDays = outcomeWashoutDaysVector[j],
riskWindowStart = riskWindowStart[i],
startAnchor = startAnchor[i],
riskWindowEnd = riskWindowEnd[i],
endAnchor = endAnchor[i],
covariateSettings = covariateSettings,
caseCovariateSettings = caseCovariateSettings,
casePreTargetDuration = casePreTargetDuration,
casePostOutcomeDuration = casePostOutcomeDuration
)
}
}
analysis <- Characterization::createCharacterizationSettings(
timeToEventSettings = list(timeToEventSettings),
dechallengeRechallengeSettings = list(dechallengeRechallengeSettings),
aggregateCovariateSettings = aggregateCovariateSettings
)
specifications <- list(
module = "CharacterizationModule",
version = "2.0.1",
remoteRepo = "github.com",
remoteUsername = "ohdsi",
settings = list(
analysis = analysis,
minCharacterizationMean = minCharacterizationMean,
incremental = incremental
)
)
class(specifications) <- c("CharacterizationModuleSpecifications", "ModuleSpecifications")
return(specifications)
}