From 678e2bc87a0dc67bf5bfe0a59c61c0a5104c17ce Mon Sep 17 00:00:00 2001 From: edward-burn <9583964+edward-burn@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:29:20 +0100 Subject: [PATCH 1/3] placeholder for pop diagnostics --- NAMESPACE | 1 + R/phenotypeDiagnostics.R | 11 ++++++++++- R/populationDiagnostics.R | 19 +++++++++++++++++++ man/phenotypeDiagnostics.Rd | 4 ++++ man/populationDiagnostics.Rd | 17 +++++++++++++++++ tests/testthat/test-populationDiagnostics.R | 3 +++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 R/populationDiagnostics.R create mode 100644 man/populationDiagnostics.Rd create mode 100644 tests/testthat/test-populationDiagnostics.R diff --git a/NAMESPACE b/NAMESPACE index 5f678a3..271156f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(exportSummarisedResult) export(importSummarisedResult) export(matchedDiagnostics) export(phenotypeDiagnostics) +export(populationDiagnostics) export(settings) export(shinyDiagnostics) export(summariseAchillesCodeUse) diff --git a/R/phenotypeDiagnostics.R b/R/phenotypeDiagnostics.R index a80b49f..7dba0d1 100644 --- a/R/phenotypeDiagnostics.R +++ b/R/phenotypeDiagnostics.R @@ -5,6 +5,7 @@ #' @param databaseDiagnostics If TRUE, database diagnostics will be run. #' @param codelistDiagnostics If TRUE, codelist diagnostics will be run. #' @param cohortDiagnostics If TRUE, cohort diagnostics will be run. +#' @param populationDiagnostics description #' @param matchedDiagnostics If TRUE, cohort to population #' diagnostics will be run. #' @param nSample The number of people to take a random sample for matching to @@ -19,8 +20,11 @@ phenotypeDiagnostics <- function(cohort, databaseDiagnostics = TRUE, codelistDiagnostics = TRUE, cohortDiagnostics = TRUE, + populationDiagnostics = TRUE, + populationSample = 1000000, matchedDiagnostics = TRUE, nSample = 1000) { + cdm <- omopgenerics::cdmReference(cohort) results <- list() @@ -36,9 +40,14 @@ phenotypeDiagnostics <- function(cohort, cli::cli("Running cohort diagnostics") results[["cohort_diag"]] <- cohortDiagnostics(cohort) } + if (isTRUE(populationDiagnostics)) { + cli::cli("Running population diagnostics") + results[["pop_diag"]] <- populationDiagnostics(cohort, + populationSample = populationSample) + } if (isTRUE(matchedDiagnostics)) { cli::cli("Running matched diagnostics") - results[["cohort_to_pop_diag"]] <- matchedDiagnostics(cohort, + results[["matched_diag"]] <- matchedDiagnostics(cohort, nSample = nSample ) } diff --git a/R/populationDiagnostics.R b/R/populationDiagnostics.R new file mode 100644 index 0000000..7c0f27c --- /dev/null +++ b/R/populationDiagnostics.R @@ -0,0 +1,19 @@ + + +#' Population-level diagnostics +#' +#' @param cohort Cohort +#' @param populationSample N of people from the cdm to sample. If NULL no +#' sampling will be performed +#' +#' @return +#' @export +#' +#' @examples +populationDiagnostics <- function(cohort, + populationSample = 1000000) { + +cli::cli_inform("populationDiagnostics not yet implemented") +omopgenerics::emptySummarisedResult() + +} diff --git a/man/phenotypeDiagnostics.Rd b/man/phenotypeDiagnostics.Rd index 9386e6a..dd376dc 100644 --- a/man/phenotypeDiagnostics.Rd +++ b/man/phenotypeDiagnostics.Rd @@ -9,6 +9,8 @@ phenotypeDiagnostics( databaseDiagnostics = TRUE, codelistDiagnostics = TRUE, cohortDiagnostics = TRUE, + populationDiagnostics = TRUE, + populationSample = 1e+06, matchedDiagnostics = TRUE, nSample = 1000 ) @@ -22,6 +24,8 @@ phenotypeDiagnostics( \item{cohortDiagnostics}{If TRUE, cohort diagnostics will be run.} +\item{populationDiagnostics}{description} + \item{matchedDiagnostics}{If TRUE, cohort to population diagnostics will be run.} diff --git a/man/populationDiagnostics.Rd b/man/populationDiagnostics.Rd new file mode 100644 index 0000000..4383b30 --- /dev/null +++ b/man/populationDiagnostics.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/populationDiagnostics.R +\name{populationDiagnostics} +\alias{populationDiagnostics} +\title{Population-level diagnostics} +\usage{ +populationDiagnostics(cohort, populationSample = 1e+06) +} +\arguments{ +\item{cohort}{Cohort} + +\item{populationSample}{N of people from the cdm to sample. If NULL no +sampling will be performed} +} +\description{ +Population-level diagnostics +} diff --git a/tests/testthat/test-populationDiagnostics.R b/tests/testthat/test-populationDiagnostics.R new file mode 100644 index 0000000..8849056 --- /dev/null +++ b/tests/testthat/test-populationDiagnostics.R @@ -0,0 +1,3 @@ +test_that("multiplication works", { + expect_equal(2 * 2, 4) +}) From 838302001bd903a4218144ffc122a6394e274371 Mon Sep 17 00:00:00 2001 From: edward-burn <9583964+edward-burn@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:32:21 +0100 Subject: [PATCH 2/3] update pkgdown --- _pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index deabb93..9ca9b8c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -12,7 +12,7 @@ reference: - matches("phenotypeDiagnostics") - subtitle: Run individual diagnostics - contents: - - matches("databaseDiagnostics|codelistDiagnostics|cohortDiagnostics|matchedDiagnostics") + - matches("databaseDiagnostics|codelistDiagnostics|cohortDiagnostics|populationDiagnostics|matchedDiagnostics") - subtitle: Visualise results - contents: - matches("shinyDiagnostics") From 3faf6f74ea3fb7269d6a8cd46fe17e3da2a1bcbd Mon Sep 17 00:00:00 2001 From: edward-burn <9583964+edward-burn@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:37:21 +0100 Subject: [PATCH 3/3] docs --- R/phenotypeDiagnostics.R | 4 +++- man/phenotypeDiagnostics.Rd | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/phenotypeDiagnostics.R b/R/phenotypeDiagnostics.R index 7dba0d1..6237e4f 100644 --- a/R/phenotypeDiagnostics.R +++ b/R/phenotypeDiagnostics.R @@ -5,7 +5,9 @@ #' @param databaseDiagnostics If TRUE, database diagnostics will be run. #' @param codelistDiagnostics If TRUE, codelist diagnostics will be run. #' @param cohortDiagnostics If TRUE, cohort diagnostics will be run. -#' @param populationDiagnostics description +#' @param populationDiagnostics If TRUE, population diagnostics will be run. +#' @param populationSample N of people from the cdm to sample. If NULL no +#' sampling will be performed #' @param matchedDiagnostics If TRUE, cohort to population #' diagnostics will be run. #' @param nSample The number of people to take a random sample for matching to diff --git a/man/phenotypeDiagnostics.Rd b/man/phenotypeDiagnostics.Rd index dd376dc..8882df3 100644 --- a/man/phenotypeDiagnostics.Rd +++ b/man/phenotypeDiagnostics.Rd @@ -24,7 +24,10 @@ phenotypeDiagnostics( \item{cohortDiagnostics}{If TRUE, cohort diagnostics will be run.} -\item{populationDiagnostics}{description} +\item{populationDiagnostics}{If TRUE, population diagnostics will be run.} + +\item{populationSample}{N of people from the cdm to sample. If NULL no +sampling will be performed} \item{matchedDiagnostics}{If TRUE, cohort to population diagnostics will be run.}