Skip to content

Commit

Permalink
Merge pull request #170 from OHDSI/checkExamples
Browse files Browse the repository at this point in the history
Use visOmopResults in plotCompareLsc
  • Loading branch information
edward-burn authored Dec 13, 2024
2 parents 4bce963 + b54b870 commit 56e29f8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
3 changes: 2 additions & 1 deletion R/matchedDiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#' mockObservation() |>
#' mockMeasurement() |>
#' mockVisitOccurrence() |>
#' mockProcedureOccurrence() |>
#' mockCohort(name = "my_cohort")
#'
#' con <- DBI::dbConnect(duckdb::duckdb(), ":memory:")
Expand All @@ -42,7 +43,7 @@
#' schema = "main")
#' attr(cdm, "write_schema") <- "main"
#'
#' result <- cdm$my_cohort |> phenotypeDiagnostics()
#' result <- cdm$my_cohort |> matchedDiagnostics()
#' CDMConnector::cdmDisconnect(cdm = cdm)
#' }
matchedDiagnostics <- function(cohort,
Expand Down
39 changes: 21 additions & 18 deletions inst/shiny/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if(file.exists(here::here("data", "appData.RData"))){
}

plotComparedLsc <- function(lsc, cohorts, imputeMissings, colour = NULL, facet = NULL){

plot_data <- lsc |>
filter(group_level %in% c(cohorts
)) |>
Expand All @@ -63,27 +64,29 @@ plotComparedLsc <- function(lsc, cohorts, imputeMissings, colour = NULL, facet =
plot_data <- plot_data |>
mutate(across(c(cohorts[1], cohorts[2]), ~if_else(is.na(.x), 0, .x)))
}

plot <- plot_data |>
ggplot(aes(text = paste("<br>Database:", database,
"<br>Concept:", variable_name,
"<br>Concept ID:", concept_id,
"<br>Time window:", time_window,
"<br>Table:", table,
"<br>Cohorts: "))) +
geom_point(aes(x = !!sym(cohorts[1]),
y = !!sym(cohorts[2]),
colour = !!sym(colour))
) +

plot <- plot_data |>
mutate("Details" = paste("<br>Database:", database,
"<br>Concept:", variable_name,
"<br>Concept ID:", concept_id,
"<br>Time window:", time_window,
"<br>Table:", table,
"<br>Cohorts: ",
"<br> - ", cohorts[1],": ", !!sym(cohorts[1]),
"<br> - ", cohorts[2],": ", !!sym(cohorts[2]))) |>
visOmopResults::scatterPlot(x = cohorts[1],
y = cohorts[2],
colour = colour,
facet = facet,
ribbon = FALSE,
line = FALSE,
point = TRUE,
label = "Details") +
geom_abline(slope = 1, intercept = 0,
color = "red", linetype = "dashed") +
theme_bw()

if(!is.null(facet)){
plot <- plot +
ggplot2::facet_wrap(facet)
}
ggplotly(plot)

ggplotly(plot, tooltip = "Details")

}

Expand Down

0 comments on commit 56e29f8

Please sign in to comment.