Skip to content

Commit e0fa79f

Browse files
committed
fixing Char queries for v3 but also be backwards compatible
fixing Char queries for v3 but also be backwards compatible
1 parent 20832aa commit e0fa79f

File tree

50 files changed

+598
-802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+598
-802
lines changed

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ export(generateSummaryPredictionReport)
1010
export(getBinaryCaseSeries)
1111
export(getBinaryRiskFactors)
1212
export(getCMEstimation)
13-
export(getCaseBinaryFeatures)
14-
export(getCaseContinuousFeatures)
1513
export(getCaseCounts)
16-
export(getCaseTargetBinaryFeatures)
1714
export(getCaseTargetCounts)
1815
export(getCharacterizationCohortBinary)
1916
export(getCharacterizationCohortContinuous)

R/CharacterizationPlots.R

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,39 @@ plotAgeDistributions <- function(
5353
}
5454
# TODO add input checks
5555

56+
5657
# filter to Target and Cases and remove censored
57-
ageData <- ageData %>%
58-
dplyr::filter(.data$sumValue > 0) %>%
59-
dplyr::filter(.data$cohortType %in% c('Target', 'Cases'))
58+
ageData <- rbind(
59+
ageData %>%
60+
dplyr::filter(.data$caseCount > 0) %>%
61+
dplyr::select("covariateName","caseAverage",
62+
"startAnchor","endAnchor",
63+
"riskWindowStart","riskWindowEnd",
64+
"databaseName") %>%
65+
dplyr::rename(averageValue = "caseAverage") %>%
66+
dplyr::mutate(cohortType = 'Cases'),
67+
ageData %>%
68+
dplyr::filter(.data$nonCaseCount > 0) %>%
69+
dplyr::select("covariateName","nonCaseAverage",
70+
"startAnchor","endAnchor",
71+
"riskWindowStart","riskWindowEnd",
72+
"databaseName") %>%
73+
dplyr::rename(averageValue = "nonCaseAverage") %>%
74+
dplyr::mutate(
75+
averageValue = -1*.data$averageValue,
76+
cohortType = 'Non-cases')
77+
)
6078

61-
ind <- ageData$cohortType == 'Target'
62-
ageData$averageValue[ind] <- -1*ageData$averageValue[ind]
6379
ageData$tar <- addTar(ageData)
80+
81+
# order the age group
82+
covNames <- unique(ageData$covariateName)
83+
covOrder <- as.double(unlist(lapply(strsplit(covNames, '- '), function(x) x[2])))
84+
ageData$covariateName <- factor(
85+
x = ageData$covariateName,
86+
levels = covNames[order(covOrder)]
87+
)
88+
6489
result <- ggplot2::ggplot(
6590
data = ageData,
6691
ggplot2::aes(
@@ -142,12 +167,27 @@ plotSexDistributions <- function(
142167
}
143168

144169
# filter to Target and Cases and remove censored
145-
sexData <- sexData %>%
146-
dplyr::filter(.data$sumValue > 0) %>%
147-
dplyr::filter(.data$cohortType %in% c('Target', 'Cases'))
170+
sexData <- rbind(
171+
sexData %>%
172+
dplyr::filter(.data$caseCount > 0) %>%
173+
dplyr::select("covariateName","caseAverage",
174+
"startAnchor","endAnchor",
175+
"riskWindowStart","riskWindowEnd",
176+
"databaseName") %>%
177+
dplyr::rename(averageValue = "caseAverage") %>%
178+
dplyr::mutate(cohortType = 'Cases'),
179+
sexData %>%
180+
dplyr::filter(.data$nonCaseCount > 0) %>%
181+
dplyr::select("covariateName","nonCaseAverage",
182+
"startAnchor","endAnchor",
183+
"riskWindowStart","riskWindowEnd",
184+
"databaseName") %>%
185+
dplyr::rename(averageValue = "nonCaseAverage") %>%
186+
dplyr::mutate(
187+
averageValue = -1*.data$averageValue,
188+
cohortType = 'Non-cases')
189+
)
148190

149-
ind <- sexData$cohortType == 'Target'
150-
sexData$averageValue[ind] <- -1*sexData$averageValue[ind]
151191
sexData$tar <- addTar(sexData)
152192

153193
result <- ggplot2::ggplot(

0 commit comments

Comments
 (0)