Skip to content

Commit

Permalink
A few additional fixes for data.table usage
Browse files Browse the repository at this point in the history
  • Loading branch information
keesvanbochove committed Oct 1, 2021
1 parent 873199c commit 0809ace
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions R/FeatureConstruction.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ featureWindowsTempTableSql <- function(connection, featureWindows, oracleTempSch
getAllFeatures <- function() {
colNames <- c("name", "cohortId") # Use this to subset to the columns of interest
cohortBasedStrata <- getCohortBasedStrata()
cohortBasedStrata <- cohortBasedStrata[, match(colNames, names(cohortBasedStrata))]
cohortBasedStrata <- cohortBasedStrata[, ..colNames]
cohortBasedFeatures <- getFeatures()
cohortBasedFeatures <- cohortBasedFeatures[, match(colNames, names(cohortBasedFeatures))]
cohortBasedFeatures <- cohortBasedFeatures[, ..colNames]
features <- rbind(cohortBasedStrata, cohortBasedFeatures)
return(features)
}
12 changes: 6 additions & 6 deletions R/ResourceFiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ getCohortsToCreate <- function(cohortGroups = getCohortGroups()) {
getAllStrata <- function() {
colNames <- c("name", "cohortId", "generationScript") # Use this to subset to the columns of interest
bulkStrata <- getBulkStrata()
bulkStrata <- bulkStrata[, match(colNames, names(bulkStrata))]
bulkStrata <- bulkStrata[, ..colNames]
atlasCohortStrata <- getCohortBasedStrata()
atlasCohortStrata$generationScript <- paste0(atlasCohortStrata$cohortId, ".sql")
atlasCohortStrata <- atlasCohortStrata[, match(colNames, names(atlasCohortStrata))]
atlasCohortStrata <- atlasCohortStrata[, ..colNames]
strata <- rbind(bulkStrata, atlasCohortStrata)
return(strata)
}
Expand All @@ -64,8 +64,8 @@ getAllStudyCohorts <- function() {
cohortsToCreate <- getCohortsToCreate()
targetStrataXref <- getTargetStrataXref()
colNames <- c("name", "cohortId")
cohortsToCreate <- cohortsToCreate[, match(colNames, names(cohortsToCreate))]
targetStrataXref <- targetStrataXref[, match(colNames, names(targetStrataXref))]
cohortsToCreate <- cohortsToCreate[, ..colNames]
targetStrataXref <- targetStrataXref[, ..colNames]
allCohorts <- rbind(cohortsToCreate, targetStrataXref)
return(allCohorts)
}
Expand All @@ -82,12 +82,12 @@ getAllStudyCohortsWithDetails <- function() {
cohortsToCreate$strataCohortId <- 0
cohortsToCreate$strataCohortName <- "All"
cohortsToCreate <- dplyr::rename(cohortsToCreate, cohortName = "name")
cohortsToCreate <- cohortsToCreate[, match(colNames, names(cohortsToCreate))]
cohortsToCreate <- cohortsToCreate[, ..colNames]
# Format - targetStrataXref
stratifiedCohorts <- dplyr::inner_join(targetStrataXref, cohortsToCreate[,c("targetCohortId", "targetCohortName")], by = c("targetId" = "targetCohortId"))
stratifiedCohorts <- dplyr::inner_join(stratifiedCohorts, allStrata[,c("cohortId", "name")], by=c("strataId" = "cohortId"))
stratifiedCohorts <- dplyr::rename(stratifiedCohorts, targetCohortId="targetId",strataCohortId="strataId",cohortName="name.x",strataCohortName="name.y")
stratifiedCohorts <- stratifiedCohorts[,match(colNames, names(stratifiedCohorts))]
stratifiedCohorts <- stratifiedCohorts[,..colNames]
# Bind
allCohorts <- rbind(cohortsToCreate, stratifiedCohorts)
return(allCohorts)
Expand Down
4 changes: 2 additions & 2 deletions R/RunStudy.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ runStudy <- function(connectionDetails = NULL,
for(analysis in DistribAnalyses){
outcome <- gsub("TimeTo", "", analysis)
outcome <- substring(SqlRender::camelCaseToTitleCase(outcome), 2)
outcomeId <- outcomes[tolower(outcomes$name) == tolower(outcome), "cohortId"]
outcomeId <- outcomes[tolower(outcomes$name) == tolower(outcome), "cohortId"][[1]]

if (length(outcomeId) == 0 & analysis %in% outcomeBasedAnalyses){
next
Expand Down Expand Up @@ -537,7 +537,7 @@ loadCohortsForExportFromPackage <- function(cohortIds) {
strataId = NULL)

cols <- names(cohorts)
cohorts <- rbind(cohorts, targetStrataXref[cols])
cohorts <- rbind(cohorts, targetStrataXref[,..cols])

if (!is.null(cohortIds)) {
cohorts <- cohorts[cohorts$cohortId %in% cohortIds, ]
Expand Down
1 change: 0 additions & 1 deletion inst/shiny/PioneerWatchfulWaitingExplorer/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ shinyServer(function(input, output, session) {


getMetricsTable <- reactive ({
browser()
target_id <- cohortCount[cohortCount$databaseId %in% input$databasesMetricsDistribution
& cohortCount$cohortId %in% cohortIdMetricsDistribution(), ][[1]]
metricsTable <- metricsDistribution %>% dplyr::filter(cohortDefinitionId == target_id,
Expand Down

0 comments on commit 0809ace

Please sign in to comment.