Skip to content

Commit

Permalink
Adding unblind_for_evidence_synthesis field to `cm_diagnostics_summ…
Browse files Browse the repository at this point in the history
…ary` table. The `cm_diagnostics_summary` table now also contains negative controls. Fixes #153 and #154.
  • Loading branch information
schuemie committed Nov 28, 2023
1 parent e42b449 commit f401b28
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Changes:
7. Improve speed of covariate balance computation.

8. Adding one-sided (calibrated) p-values to results summary and results model.

9. Adding `unblind_for_evidence_synthesis` field to `cm_diagnostics_summary` table.

10. The `cm_diagnostics_summary` table now also contains negative controls.


Bugfixes:
Expand Down
18 changes: 11 additions & 7 deletions R/Export.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ createCmDiagnosticThresholds <- function(mdrrThreshold = 10,
checkmate::reportAssertions(collection = errorMessages)
if (!is.null(attritionFractionThreshold)) {
warning("The attritionFractionThreshold argument is deprecated and will be ignored. ",
"See generalizabilitySdmThreshold instead.")
"See generalizabilitySdmThreshold instead.")
}
thresholds <- list()
for (name in names(formals(createCmDiagnosticThresholds))) {
Expand Down Expand Up @@ -594,8 +594,8 @@ exportCmInteractionResults <- function(outputFolder,
}

exportLikelihoodProfiles <- function(outputFolder,
exportFolder,
databaseId) {
exportFolder,
databaseId) {
message("- likelihood_profile table")
reference <- getFileReference(outputFolder)
fileName <- file.path(exportFolder, "cm_likelihood_profile.csv")
Expand Down Expand Up @@ -764,7 +764,7 @@ tidyBalance <- function(balance, minCellCount) {
round(.data$targetStdDiff, 3) == 0 &
round(.data$comparatorStdDiff, 3) == 0 &
round(.data$targetComparatorStdDiff, 3) == 0)
) %>%
) %>%
enforceMinCellValue("targetMeanBefore",
minCellCount / inferredTargetBeforeSize,
silent = TRUE
Expand Down Expand Up @@ -1200,7 +1200,6 @@ exportDiagnosticsSummary <- function(outputFolder,
pull()
equipoise <- bind_rows(lapply(sharedPsFiles, getEquipoise))
results <- reference %>%
filter(.data$outcomeOfInterest) %>%
inner_join(
resultsSummary,
by = join_by("analysisId", "targetId", "comparatorId", "outcomeId")) %>%
Expand All @@ -1227,6 +1226,7 @@ exportDiagnosticsSummary <- function(outputFolder,

# Apply diagnostics thresholds:
results <- results %>%
mutate(databaseId = !!databaseId) %>%
mutate(balanceDiagnostic = case_when(
is.na(.data$maxSdm) ~ "NOT EVALUATED",
.data$maxSdm < cmDiagnosticThresholds$sdmThreshold ~ "PASS",
Expand Down Expand Up @@ -1262,8 +1262,12 @@ exportDiagnosticsSummary <- function(outputFolder,
.data$easeDiagnostic != "FAIL" &
.data$equipoiseDiagnostic != "FAIL" &
.data$balanceDiagnostic != "FAIL" &
.data$sharedBalanceDiagnostic != "FAIL", 1, 0),
databaseId = !!databaseId)
.data$sharedBalanceDiagnostic != "FAIL", 1, 0)) %>%
mutate(unblindForEvidenceSynthesis = ifelse(.data$generalizabilityDiagnostic != "FAIL" &
.data$easeDiagnostic != "FAIL" &
.data$equipoiseDiagnostic != "FAIL" &
.data$balanceDiagnostic != "FAIL" &
.data$sharedBalanceDiagnostic != "FAIL", 1, 0))

# Add deprecated fields:
results <- results %>%
Expand Down
Binary file modified inst/Results_Eunomia.zip
Binary file not shown.
1 change: 1 addition & 0 deletions inst/csv/resultsDataModelSpecification.csv
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ cm_diagnostics_summary,attrition_diagnostic,varchar(20),No,No,No,Yes,DEPRECATED:
cm_diagnostics_summary,generalizability_diagnostic,varchar(20),Yes,No,No,No,Pass / warning / fail classification of the generalizability diagnostic.
cm_diagnostics_summary,ease_diagnostic,varchar(20),Yes,No,No,No,Pass / warning / fail classification of the EASE diagnostic.
cm_diagnostics_summary,unblind,int,Yes,No,No,No,"Is unblinding the result recommended? (1 = yes, 0 = no)"
cm_diagnostics_summary,unblind_for_evidence_synthesis,int,Yes,No,No,No,"Is unblinding the result for inclusion in evidence synthesis recommended? This ignores the MDRR diagnostic. (1 = yes, 0 = no)"
cm_target_comparator_outcome,outcome_id,int,Yes,Yes,No,No,The identifier for the outcome cohort.
cm_target_comparator_outcome,outcome_of_interest,int,Yes,No,No,No,"Is the outcome of interest (1 = yes, 0 = no)"
cm_target_comparator_outcome,true_effect_size,float,No,No,No,No,The true effect size for the target-comparator-outcome. For negatitive controls this equals 1.
Expand Down
3 changes: 2 additions & 1 deletion inst/sql/sql_server/migrations/Migration_1-v5_2_0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
-- Add:
-- - generalizability_max_sdm
-- - generalizability_diagnostic
-- - unblind_for_evidence_synthesis
ALTER TABLE @database_schema.@table_prefixcm_result ADD target_estimator VARCHAR(3), one_sided_p FLOAT, calibrated_one_sided_p FLOAT;
ALTER TABLE @database_schema.@table_prefixcm_interaction_result ADD target_estimator VARCHAR(3);
ALTER TABLE @database_schema.@table_prefixcm_covariate_balance ADD mean_before FLOAT, mean_after FLOAT, target_std_diff FLOAT, comparator_std_diff FLOAT, target_comparator_std_diff FLOAT;
ALTER TABLE @database_schema.@table_prefixcm_shared_covariate_balance ADD mean_before FLOAT, mean_after FLOAT, target_std_diff FLOAT, comparator_std_diff FLOAT, target_comparator_std_diff FLOAT;
ALTER TABLE @database_schema.@table_prefixcm_diagnostics_summary ADD generalizability_max_sdm FLOAT, generalizability_diagnostic VARCHAR(20);
ALTER TABLE @database_schema.@table_prefixcm_diagnostics_summary ADD generalizability_max_sdm FLOAT, generalizability_diagnostic VARCHAR(20), unblind_for_evidence_synthesis INT;
6 changes: 6 additions & 0 deletions tests/testthat/test-eunomia.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ test_that("Multiple analyses", {
targetComparatorOutcome <- readr::read_csv(file.path(outputFolder, "export", "cm_target_comparator_outcome.csv"), show_col_types = FALSE)
expect_true(is.numeric(targetComparatorOutcome$outcome_of_interest))

# Verify negative controls have diagnostics:
ncDiagnostics <- diagnosticsSummary %>%
inner_join(targetComparatorOutcome) %>%
filter(.data$outcome_of_interest == 0)
expect_gt(nrow(ncDiagnostics), 0)

cohorts <- data.frame(
cohortId = c(1, 2, 998, 999, 3, 4),
cohortName = c("e1", "e2", "e3", "e4", "o1", "o2")
Expand Down

0 comments on commit f401b28

Please sign in to comment.