Type: | Package |
Title: | Diagnostics for Lists of Codes Based on Measurements |
Version: | 0.0.1 |
Description: | Diagnostics of list of codes based on concepts from the domains measurement and observation. This package works for data mapped to the Observational Medical Outcomes Partnership Common Data Model. |
Imports: | cli, CohortConstructor (≥ 0.4.0), DBI, dplyr, magrittr, omopgenerics (≥ 1.2.0), PatientProfiles (≥ 1.4.0), purrr, rlang, tidyr |
Suggests: | CDMConnector (≥ 2.0.0), CodelistGenerator (≥ 3.5.0), visOmopResults (≥ 1.0.2), duckdb, knitr, omock (≥ 0.4.0), rmarkdown, testthat, ggplot2, gt, flextable, RPostgres, lubridate, odbc |
Depends: | R (≥ 4.1) |
License: | Apache License (≥ 2) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-07-08 15:29:30 UTC; nuriamb |
Author: | Edward Burn |
Maintainer: | Nuria Mercade-Besora <nuria.mercadebesora@ndorms.ox.ac.uk> |
Repository: | CRAN |
Date/Publication: | 2025-07-11 13:00:05 UTC |
Pipe operator
Description
See magrittr::%>%
for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling 'rhs(lhs)'.
Function to create a mock cdm reference.
Description
Creates an example dataset that can be used to show how the package works
Usage
mockMeasurementDiagnostics(
nPerson = 100,
con = DBI::dbConnect(duckdb::duckdb()),
writeSchema = "main",
seed = 111
)
Arguments
nPerson |
number of people in the cdm. |
con |
A DBI connection to create the cdm mock object. |
writeSchema |
Name of an schema on the same connection with writing permissions. |
seed |
seed to use when creating the mock data. |
Value
cdm object
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
cdm
Helper for consistent documentation of 'plot'.
Description
Helper for consistent documentation of 'plot'.
Arguments
x |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
y |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
facet |
Columns to facet by. See options with 'visOmopResults::plotColumns(result)'. Formula input is also allowed to specify rows and columns. |
colour |
Columns to color by. See options with 'visOmopResults::plotColumns(result)'. |
Plot summariseMeasurementTiming results.
Description
Plot summariseMeasurementTiming results.
Usage
plotMeasurementTimings(
result,
x = "codelist_name",
plotType = "boxplot",
timeScale = "days",
facet = visOmopResults::strataColumns(result),
colour = "cdm_name"
)
Arguments
result |
A summarised_result object. |
x |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
plotType |
Type of desired formatted table, possibilities are "boxplot" and "densityplot". |
timeScale |
Time scale to show, it can be "days" or "years". |
facet |
Columns to facet by. See options with 'visOmopResults::plotColumns(result)'. Formula input is also allowed to specify rows and columns. |
colour |
Columns to color by. See options with 'visOmopResults::plotColumns(result)'. |
Value
A ggplot.
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
codes = list("test_codelist" = c(3001467L, 45875977L))
)
plotMeasurementTimings(result)
CDMConnector::cdmDisconnect(cdm)
Plot summariseMeasurementTiming results.
Description
Plot summariseMeasurementTiming results.
Usage
plotMeasurementValueAsConcept(
result,
x = "count",
y = "codelist_name",
facet = c("cdm_name"),
colour = c("concept_name", "variable_level", visOmopResults::strataColumns(result))
)
Arguments
result |
A summarised_result object. |
x |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
y |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
facet |
Columns to facet by. See options with 'visOmopResults::plotColumns(result)'. Formula input is also allowed to specify rows and columns. |
colour |
Columns to color by. See options with 'visOmopResults::plotColumns(result)'. |
Value
A ggplot.
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
bySex = TRUE,
codes = list("test_codelist" = c(3001467L, 45875977L)))
plotMeasurementValueAsConcept(result)
CDMConnector::cdmDisconnect(cdm)
Plot summariseMeasurementTiming results.
Description
Plot summariseMeasurementTiming results.
Usage
plotMeasurementValueAsNumeric(
result,
x = c("unit_concept_name"),
facet = c("codelist_name", "concept_name"),
colour = c("cdm_name", visOmopResults::strataColumns(result))
)
Arguments
result |
A summarised_result object. |
x |
Columns to use as horizontal axes. See options with 'visOmopResults::plotColumns(result)'. |
facet |
Columns to facet by. See options with 'visOmopResults::plotColumns(result)'. Formula input is also allowed to specify rows and columns. |
colour |
Columns to color by. See options with 'visOmopResults::plotColumns(result)'. |
Value
A ggplot.
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
bySex = TRUE,
codes = list("test_codelist" = c(3001467L, 45875977L)))
plotMeasurementValueAsNumeric(result)
CDMConnector::cdmDisconnect(cdm)
Helper for consistent documentation of 'result'.
Description
Helper for consistent documentation of 'result'.
Arguments
result |
A summarised_result object. |
Diagnostics of a codelist of measurement codes within a cohort
Description
Diagnostics of a codelist of measurement codes within a cohort
Usage
summariseCohortMeasurementUse(
codes,
cohort,
timing = "during",
byConcept = TRUE,
byYear = FALSE,
bySex = FALSE,
ageGroup = NULL,
dateRange = as.Date(c(NA, NA)),
checks = c("measurement_timings", "measurement_value_as_numeric",
"measurement_value_as_concept")
)
Arguments
codes |
A codelist of measurement/observation codes for which to perform diagnostics. |
cohort |
A cohort in which to perform the diagnostics of the measurement codes provided. |
timing |
Three options: 1) "any" if the interest is on measurement recorded any time, 2) "during", if interested in measurements while the subject is in the cohort (or in observation if cohort = NULL), and 3) "cohort_start_date" for measurements occurring at cohort start date (or at "observation_period_start_date if cohort = NULL). |
byConcept |
TRUE or FALSE. If TRUE code use will be summarised by concept. |
byYear |
TRUE or FALSE. If TRUE code use will be summarised by year. |
bySex |
TRUE or FALSE. If TRUE code use will be summarised by sex. |
ageGroup |
If not NULL, a list of ageGroup vectors of length two. |
dateRange |
Two dates. The first indicating the earliest measurement date and the second indicating the latest possible measurement date. |
checks |
Diagnostics to run. Options are: "measurement_timing", "measurement_value_as_numeric", and "measurement_value_as_concept". |
Value
A summarised result
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseCohortMeasurementUse(
codes = list("test_codelist" = c(3001467L, 45875977L)),
cohort = cdm$my_cohort, timing = "cohort_start_date"
)
CDMConnector::cdmDisconnect(cdm = cdm)
Helper for consistent documentation of 'summariseMeasurement' functions.
Description
Helper for consistent documentation of 'summariseMeasurement' functions.
Arguments
cdm |
A reference to the cdm object. |
codes |
A codelist of measurement/observation codes for which to perform diagnostics. |
cohort |
A cohort in which to perform the diagnostics of the measurement codes provided. |
timing |
Three options: 1) "any" if the interest is on measurement recorded any time, 2) "during", if interested in measurements while the subject is in the cohort (or in observation if cohort = NULL), and 3) "cohort_start_date" for measurements occurring at cohort start date (or at "observation_period_start_date if cohort = NULL). |
byConcept |
TRUE or FALSE. If TRUE code use will be summarised by concept. |
byYear |
TRUE or FALSE. If TRUE code use will be summarised by year. |
bySex |
TRUE or FALSE. If TRUE code use will be summarised by sex. |
ageGroup |
If not NULL, a list of ageGroup vectors of length two. |
dateRange |
Two dates. The first indicating the earliest measurement date and the second indicating the latest possible measurement date. |
checks |
Diagnostics to run. Options are: "measurement_timing", "measurement_value_as_numeric", and "measurement_value_as_concept". |
Diagnostics of a codelist of measurement codes in the database
Description
Diagnostics of a codelist of measurement codes in the database
Usage
summariseMeasurementUse(
cdm,
codes,
byConcept = TRUE,
byYear = FALSE,
bySex = FALSE,
ageGroup = NULL,
dateRange = as.Date(c(NA, NA)),
checks = c("measurement_timings", "measurement_value_as_numeric",
"measurement_value_as_concept")
)
Arguments
cdm |
A reference to the cdm object. |
codes |
A codelist of measurement/observation codes for which to perform diagnostics. |
byConcept |
TRUE or FALSE. If TRUE code use will be summarised by concept. |
byYear |
TRUE or FALSE. If TRUE code use will be summarised by year. |
bySex |
TRUE or FALSE. If TRUE code use will be summarised by sex. |
ageGroup |
If not NULL, a list of ageGroup vectors of length two. |
dateRange |
Two dates. The first indicating the earliest measurement date and the second indicating the latest possible measurement date. |
checks |
Diagnostics to run. Options are: "measurement_timing", "measurement_value_as_numeric", and "measurement_value_as_concept". |
Value
A summarised result
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm, codes = list("test_codelist" = c(3001467L, 45875977L))
)
CDMConnector::cdmDisconnect(cdm = cdm)
Helper for consistent documentation of 'table'.
Description
Helper for consistent documentation of 'table'.
Arguments
type |
Type of table. Check supported types with 'visOmopResults::tableType()'. |
header |
Columns to use as header. See options with 'visOmopResults::tableColumns(result)'. |
groupColumn |
Columns to group by. See options with 'visOmopResults::tableColumns(result)'. |
settingsColumn |
Columns from settings to include in results. See options with 'visOmopResults::settingsColumns(result)'. |
hide |
Columns to hide from the visualisation. See options with 'visOmopResults::tableColumns(result)'. |
style |
Named list that specifies how to style the different parts of the table generated. It can either be a pre-defined style ("default" or "darwin" - the latter just for gt and flextable), NULL to get the table type default style, or custom. Keep in mind that styling code is different for all table styles. To see the different styles use visOmopResults::tableStyle(). |
.options |
A named list with additional formatting options. 'visOmopResults::tableOptions()' shows allowed arguments and their default values. |
Format a measurement_timings object into a visual table
Description
Format a measurement_timings object into a visual table
Usage
tableMeasurementTimings(
result,
type = "gt",
header = c(visOmopResults::strataColumns(result)),
groupColumn = c("codelist_name"),
settingsColumn = character(),
hide = c("variable_level"),
style = "default",
.options = list()
)
Arguments
result |
A summarised_result object. |
type |
Type of table. Check supported types with 'visOmopResults::tableType()'. |
header |
Columns to use as header. See options with 'visOmopResults::tableColumns(result)'. |
groupColumn |
Columns to group by. See options with 'visOmopResults::tableColumns(result)'. |
settingsColumn |
Columns from settings to include in results. See options with 'visOmopResults::settingsColumns(result)'. |
hide |
Columns to hide from the visualisation. See options with 'visOmopResults::tableColumns(result)'. |
style |
Named list that specifies how to style the different parts of the table generated. It can either be a pre-defined style ("default" or "darwin" - the latter just for gt and flextable), NULL to get the table type default style, or custom. Keep in mind that styling code is different for all table styles. To see the different styles use visOmopResults::tableStyle(). |
.options |
A named list with additional formatting options. 'visOmopResults::tableOptions()' shows allowed arguments and their default values. |
Value
A formatted table
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
codes = list("test_codelist" = c(3001467L, 45875977L)))
tableMeasurementTimings(result)
CDMConnector::cdmDisconnect(cdm = cdm)
Format a measurement_timings object into a visual table
Description
Format a measurement_timings object into a visual table
Usage
tableMeasurementValueAsConcept(
result,
type = "gt",
header = c(visOmopResults::strataColumns(result)),
groupColumn = c("codelist_name"),
settingsColumn = character(),
hide = character(),
style = "default",
.options = list()
)
Arguments
result |
A summarised_result object. |
type |
Type of table. Check supported types with 'visOmopResults::tableType()'. |
header |
Columns to use as header. See options with 'visOmopResults::tableColumns(result)'. |
groupColumn |
Columns to group by. See options with 'visOmopResults::tableColumns(result)'. |
settingsColumn |
Columns from settings to include in results. See options with 'visOmopResults::settingsColumns(result)'. |
hide |
Columns to hide from the visualisation. See options with 'visOmopResults::tableColumns(result)'. |
style |
Named list that specifies how to style the different parts of the table generated. It can either be a pre-defined style ("default" or "darwin" - the latter just for gt and flextable), NULL to get the table type default style, or custom. Keep in mind that styling code is different for all table styles. To see the different styles use visOmopResults::tableStyle(). |
.options |
A named list with additional formatting options. 'visOmopResults::tableOptions()' shows allowed arguments and their default values. |
Value
A formatted table
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
codes = list("test_codelist" = c(3001467L, 45875977L)))
tableMeasurementValueAsConcept(result)
CDMConnector::cdmDisconnect(cdm = cdm)
Format a measurement_timings object into a visual table
Description
Format a measurement_timings object into a visual table
Usage
tableMeasurementValueAsNumeric(
result,
type = "gt",
header = c(visOmopResults::strataColumns(result)),
groupColumn = c("codelist_name"),
settingsColumn = character(),
hide = c("variable_name", "variable_level"),
style = "default",
.options = list()
)
Arguments
result |
A summarised_result object. |
type |
Type of table. Check supported types with 'visOmopResults::tableType()'. |
header |
Columns to use as header. See options with 'visOmopResults::tableColumns(result)'. |
groupColumn |
Columns to group by. See options with 'visOmopResults::tableColumns(result)'. |
settingsColumn |
Columns from settings to include in results. See options with 'visOmopResults::settingsColumns(result)'. |
hide |
Columns to hide from the visualisation. See options with 'visOmopResults::tableColumns(result)'. |
style |
Named list that specifies how to style the different parts of the table generated. It can either be a pre-defined style ("default" or "darwin" - the latter just for gt and flextable), NULL to get the table type default style, or custom. Keep in mind that styling code is different for all table styles. To see the different styles use visOmopResults::tableStyle(). |
.options |
A named list with additional formatting options. 'visOmopResults::tableOptions()' shows allowed arguments and their default values. |
Value
A formatted table
Examples
library(MeasurementDiagnostics)
cdm <- mockMeasurementDiagnostics()
result <- summariseMeasurementUse(
cdm = cdm,
codes = list("test_codelist" = c(3001467L, 45875977L)))
tableMeasurementValueAsNumeric(result)
CDMConnector::cdmDisconnect(cdm = cdm)
Helper for consistent documentation of 'timeScale'.
Description
Helper for consistent documentation of 'timeScale'.
Arguments
timeScale |
Time scale to show, it can be "days" or "years". |
Helper for consistent documentation of 'uniqueCombinations'.
Description
Helper for consistent documentation of 'uniqueCombinations'.
Arguments
uniqueCombinations |
Whether to restrict to unique reference and comparator comparisons. |