Skip to content

Commit

Permalink
changes for data model
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Jan 7, 2025
1 parent c5a32f6 commit 7dcbebd
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Suggests:
DiagrammeR,
tidyr,
R.utils
Remotes:
OHDSI/ResultModelManager@big_int_type_check
License: Apache License 2.0
RoxygenNote: 7.3.2
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions R/RunAnalyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ runSccAnalyses <- function(connectionDetails,
outputFolder = "./SelfControlledCohortOutput",
sccAnalysisList,
exposureOutcomeList,
databaseId,
controlType = "outcome",
analysisThreads = 1,
computeThreads = 1) {
Expand Down Expand Up @@ -116,6 +117,7 @@ runSccAnalyses <- function(connectionDetails,
cdmVersion = cdmVersion,
exposureIds = exposureIds,
outcomeIds = outcomeId,
databaseId = databaseId,
controlType = controlType,
analysisId = refRow$analysisId,
tempEmulationSchema = tempEmulationSchema,
Expand Down
17 changes: 8 additions & 9 deletions R/SelfControlledCohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ computeIrrs <- function(estimates) {
timeAtRiskExposed = estimates$time_at_risk_exposed,
timeAtRiskUnexposed = estimates$time_at_risk_unexposed)

estimates$irr <- irrs[1,]
estimates$irrLb95 <- irrs[2,]
estimates$irrUb95 <- irrs[3,]
estimates$rr <- irrs[1,]
estimates$irr_lb_95 <- irrs[2,]
estimates$irr_ub_95 <- irrs[3,]

estimates$logRr <- log(estimates$irr)
estimates$seLogRr <- (log(estimates$irrUb95) - log(estimates$irrLb95)) / (2 * qnorm(0.975))
zTest <- stats::pnorm(estimates$logRr / estimates$seLogRr)
estimates$log_rr <- log(estimates$rr)
estimates$se_log_rr <- (log(estimates$irr_ub_95) - log(estimates$irr_lb_95)) / (2 * qnorm(0.975))
zTest <- stats::pnorm(estimates$log_rr / estimates$se_log_rr)
estimates$p <- 2 * pmin(zTest, 1 - zTest)
return(estimates)
}
Expand Down Expand Up @@ -135,7 +135,6 @@ batchComputeEstimates <- function(connection,
ncPairsDf |>
dplyr::group_by(.data$outcomeCohortId) |>
dplyr::group_map(function(data, outcomeCohortId) {
browser()
estimates <- andromeda$estimates |>
dplyr::filter(.data$outcomeCohortId == outcomeCohortId)

Expand Down Expand Up @@ -266,7 +265,7 @@ batchComputeEstimates <- function(connection,
#' confidence intervals.
#' @param resultExportPath Folder where result files are exported
#' @param outputFolder Folder where intermediate files are stored
#' @param databaseId Unique identifier for database
#' @param databaseId Unique identifier for database - required
#' @param resultExportManager ResultModelManager::ResultExportManager instance - customize this to implement
#' an alternative mechanism for exporting results
#'
Expand Down Expand Up @@ -325,7 +324,7 @@ runSelfControlledCohort <- function(connectionDetails = NULL,
resultsDatabaseSchema = NULL,
resultExportPath = "scc_result",
outputFolder = "scc_work",
databaseId = NULL,
databaseId,
analysisId = 1,
resultExportManager = ResultModelManager::createResultExportManager(
tableSpecification = getResultsDataModelSpecifications(),
Expand Down
11 changes: 5 additions & 6 deletions inst/resultsDataModelSpecification.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ scc_result,calibrated_lb_95,float,0,0,0,Lower bound of the 95% confidence interv
scc_result,calibrated_ub_95,float,0,0,0,Upper bound of the 95% confidence interval for calibrated results
scc_result,calibrated_p_value,float,0,0,0,P-value for calibrated results
scc_result,exposure_calibrated,int,0,0,0,Is the result calibrated with exposure negative controls or outcomes?
scc_result,c_pt,float,0,0,0,Unexposed pt
scc_result,t_pt,float,0,0,0,Exposed pt
scc_result,t_at_risk,float,0,0,0,Time at risk exposed
scc_result,c_at_risk,float,0,0,0,Time at risk unexposed
scc_result,t_cases,float,0,0,1,Cases while exposed
scc_result,c_cases,float,0,0,1,Cases while unexposed
scc_result,num_persons,float,0,0,0,person count
scc_result,time_at_risk_exposed,float,0,0,0,Time at risk exposed
scc_result,time_at_risk_unexposed,float,0,0,0,Time at risk unexposed
scc_result,num_outcomes_exposed,float,0,0,1,Cases while exposed
scc_result,num_outcomes_unexposed,float,0,0,1,Cases while unexposed
scc_result,num_exposures,float,0,0,1,Number of exposures
scc_result,i_2,float,0,0,0,I² statistic for heterogeneity
scc_stat,database_id,int,1,1,0,Unique identifier for the database
Expand Down
2 changes: 1 addition & 1 deletion man/getSccRiskWindowStats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/runSccAnalyses.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/runSelfControlledCohort.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/test-RunAnalyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test_that("multiple analyses", {
sccAnalysisList = sccAnalysisList,
exposureOutcomeList = exposureOutcomeList,
outputFolder = outputFolder,
databaseId = 1,
computeThreads = 1)

expect_s3_class(rr, "data.frame")
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-SelfControlledCohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ test_that("SCC method runs on Eunomia", {
cdmDatabaseSchema = "main",
exposureIds = '',
outcomeIds = '',
databaseId = 1,
riskWindowEndExposed = 1,
riskWindowStartExposed = 30,
addLengthOfExposureExposed = F),
Expand Down

0 comments on commit 7dcbebd

Please sign in to comment.