| Title: | Summarise and Visualise Characteristics of Patients in the OMOP CDM |
|---|---|
| Description: | Summarise and visualise the characteristics of patients in data mapped to the Observational Medical Outcomes Partnership (OMOP) common data model (CDM). |
| Authors: | Martí Català [aut, cre] (ORCID: <https://orcid.org/0000-0003-3308-9905>), Yuchen Guo [aut] (ORCID: <https://orcid.org/0000-0002-0847-4855>), Mike Du [ctb] (ORCID: <https://orcid.org/0000-0002-9517-8834>), Kim Lopez-Guell [aut] (ORCID: <https://orcid.org/0000-0002-8462-8668>), Edward Burn [aut] (ORCID: <https://orcid.org/0000-0002-9286-1128>), Nuria Mercade-Besora [aut] (ORCID: <https://orcid.org/0009-0006-7948-3747>), Marta Alcalde [aut] (ORCID: <https://orcid.org/0009-0002-4405-1814>) |
| Maintainer: | Martí Català <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 1.1.1 |
| Built: | 2026-06-07 07:16:42 UTC |
| Source: | https://github.com/darwin-eu/cohortcharacteristics |
facet and colour arguments in plot functions.Available columns to use in facet and colour arguments in plot functions.
availablePlotColumns(result)availablePlotColumns(result)
result |
A summarised_result object. |
Character vector with the available columns.
{ cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) availablePlotColumns(result) }{ cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) availablePlotColumns(result) }
header, groupColumn and hide arguments in
table functions.Available columns to use in header, groupColumn and hide arguments in
table functions.
availableTableColumns(result)availableTableColumns(result)
result |
A summarised_result object. |
Character vector with the available columns.
{ cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) availableTableColumns(result) }{ cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) availableTableColumns(result) }
Benchmark the main functions of CohortCharacteristics package.
benchmarkCohortCharacteristics( cohort, analysis = c("count", "attrition", "characteristics", "overlap", "timing", "large scale characteristics") )benchmarkCohortCharacteristics( cohort, analysis = c("count", "attrition", "characteristics", "overlap", "timing", "large scale characteristics") )
cohort |
A cohort_table from a cdm_reference. |
analysis |
Set of analysis to perform, must be a subset of: "count", "attrition", "characteristics", "overlap", "timing" and "large scale characteristics". |
A summarised_result object.
## Not run: library(CohortCharacteristics) library(omock) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(sinusitis = 40481087, pharyngitis = 4112343), name = "my_cohort" ) benchmarkCohortCharacteristics(cdm$my_cohort) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(sinusitis = 40481087, pharyngitis = 4112343), name = "my_cohort" ) benchmarkCohortCharacteristics(cdm$my_cohort) ## End(Not run)
It creates a mock database for testing CohortCharacteristics package
mockCohortCharacteristics( numberIndividuals = 10, ..., source = "local", con = lifecycle::deprecated(), writeSchema = lifecycle::deprecated(), seed = lifecycle::deprecated() )mockCohortCharacteristics( numberIndividuals = 10, ..., source = "local", con = lifecycle::deprecated(), writeSchema = lifecycle::deprecated(), seed = lifecycle::deprecated() )
numberIndividuals |
Number of individuals to create in the cdm reference. |
... |
User self defined tables to put in cdm, it can input as many as the user want. |
source |
Source for the mock cdm, it can either be 'local' or 'duckdb'. |
con |
deprecated. |
writeSchema |
deprecated. |
seed |
deprecated. |
A mock cdm_reference object created following user's specifications.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics()library(CohortCharacteristics) cdm <- mockCohortCharacteristics()
plotCharacteristics( result, plotType = "barplot", facet = NULL, colour = NULL, style = NULL, plotStyle = lifecycle::deprecated() )plotCharacteristics( result, plotType = "barplot", facet = NULL, colour = NULL, style = NULL, plotStyle = lifecycle::deprecated() )
result |
A summarised_result object. |
plotType |
Either |
facet |
Columns to facet by. See options with
|
colour |
Columns to color by. See options with
|
style |
Visual theme to apply. Character, or |
plotStyle |
deprecated. |
A ggplot.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() results <- summariseCharacteristics( cohort = cdm$cohort1, ageGroup = list(c(0, 19), c(20, 39), c(40, 59), c(60, 79), c(80, 150)), tableIntersectCount = list( tableName = "visit_occurrence", window = c(-365, -1) ), cohortIntersectFlag = list( targetCohortTable = "cohort2", window = c(-365, -1) ) ) results |> filter( variable_name == "Cohort2 flag -365 to -1", estimate_name == "percentage" ) |> plotCharacteristics( plotType = "barplot", colour = "variable_level", facet = c("cdm_name", "cohort_name") ) results |> filter(variable_name == "Age", estimate_name == "mean") |> plotCharacteristics( plotType = "scatterplot", facet = "cdm_name" ) results |> filter(variable_name == "Age", group_level == "cohort_1") |> plotCharacteristics( plotType = "boxplot", facet = "cdm_name", colour = "cohort_name" )library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() results <- summariseCharacteristics( cohort = cdm$cohort1, ageGroup = list(c(0, 19), c(20, 39), c(40, 59), c(60, 79), c(80, 150)), tableIntersectCount = list( tableName = "visit_occurrence", window = c(-365, -1) ), cohortIntersectFlag = list( targetCohortTable = "cohort2", window = c(-365, -1) ) ) results |> filter( variable_name == "Cohort2 flag -365 to -1", estimate_name == "percentage" ) |> plotCharacteristics( plotType = "barplot", colour = "variable_level", facet = c("cdm_name", "cohort_name") ) results |> filter(variable_name == "Age", estimate_name == "mean") |> plotCharacteristics( plotType = "scatterplot", facet = "cdm_name" ) results |> filter(variable_name == "Age", group_level == "cohort_1") |> plotCharacteristics( plotType = "boxplot", facet = "cdm_name", colour = "cohort_name" )
plotCohortAttrition( result, show = c("subjects", "records"), type = "htmlwidget", cohortId = lifecycle::deprecated() )plotCohortAttrition( result, show = c("subjects", "records"), type = "htmlwidget", cohortId = lifecycle::deprecated() )
result |
A summarised_result object. |
show |
Which variables to show in the attrition plot, it can be 'subjects', 'records' or both. |
type |
type of the output, it can either be: 'htmlwidget', 'png', or 'DiagrammeR'. |
cohortId |
deprecated. |
A grViz visualisation.
library(CohortCharacteristics) library(omopgenerics) library(dplyr, warn.conflicts = FALSE) library(clock) cdm <- mockCohortCharacteristics(numberIndividuals = 1000) cdm[["cohort1"]] <- cdm[["cohort1"]] |> filter(get_year(cohort_start_date) >= 2000) |> recordCohortAttrition("Restrict to cohort_start_date >= 2000") |> filter(get_year(cohort_end_date) < 2020) |> recordCohortAttrition("Restrict to cohort_end_date < 2020") |> compute(temporary = FALSE, name = "cohort1") result <- summariseCohortAttrition(cdm$cohort1) result |> filter(group_level == "cohort_2") |> plotCohortAttrition()library(CohortCharacteristics) library(omopgenerics) library(dplyr, warn.conflicts = FALSE) library(clock) cdm <- mockCohortCharacteristics(numberIndividuals = 1000) cdm[["cohort1"]] <- cdm[["cohort1"]] |> filter(get_year(cohort_start_date) >= 2000) |> recordCohortAttrition("Restrict to cohort_start_date >= 2000") |> filter(get_year(cohort_end_date) < 2020) |> recordCohortAttrition("Restrict to cohort_end_date < 2020") |> compute(temporary = FALSE, name = "cohort1") result <- summariseCohortAttrition(cdm$cohort1) result |> filter(group_level == "cohort_2") |> plotCohortAttrition()
plotCohortCount( result, x = NULL, facet = c("cdm_name"), colour = NULL, style = NULL )plotCohortCount( result, x = NULL, facet = c("cdm_name"), colour = NULL, style = NULL )
result |
A summarised_result object. |
x |
Variables to use in x axis. |
facet |
Columns to facet by. See options with
|
colour |
Columns to color by. See options with
|
style |
Visual theme to apply. Character, or |
A ggplot.
library(CohortCharacteristics) library(PatientProfiles) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics(numberIndividuals = 100) counts <- cdm$cohort2 |> addSex() |> addAge(ageGroup = list(c(0, 29), c(30, 59), c(60, Inf))) |> summariseCohortCount(strata = list("age_group", "sex", c("age_group", "sex"))) |> filter(variable_name == "Number subjects") counts |> plotCohortCount( x = "sex", facet = cohort_name ~ age_group, colour = "sex" )library(CohortCharacteristics) library(PatientProfiles) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics(numberIndividuals = 100) counts <- cdm$cohort2 |> addSex() |> addAge(ageGroup = list(c(0, 29), c(30, 59), c(60, Inf))) |> summariseCohortCount(strata = list("age_group", "sex", c("age_group", "sex"))) |> filter(variable_name == "Number subjects") counts |> plotCohortCount( x = "sex", facet = cohort_name ~ age_group, colour = "sex" )
plotCohortOverlap( result, uniqueCombinations = TRUE, facet = c("cdm_name", "cohort_name_reference"), colour = "variable_name", style = NULL, .options = lifecycle::deprecated() )plotCohortOverlap( result, uniqueCombinations = TRUE, facet = c("cdm_name", "cohort_name_reference"), colour = "variable_name", style = NULL, .options = lifecycle::deprecated() )
result |
A summarised_result object. |
uniqueCombinations |
Whether to restrict to unique reference and comparator comparisons. |
facet |
Columns to facet by. See options with
|
colour |
Columns to color by. See options with
|
style |
Visual theme to apply. Character, or |
.options |
deprecated. |
A ggplot.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics() overlap <- summariseCohortOverlap(cdm$cohort2) plotCohortOverlap(overlap, uniqueCombinations = FALSE)library(CohortCharacteristics) cdm <- mockCohortCharacteristics() overlap <- summariseCohortOverlap(cdm$cohort2) plotCohortOverlap(overlap, uniqueCombinations = FALSE)
plotCohortTiming( result, plotType = "boxplot", timeScale = "days", uniqueCombinations = TRUE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator"), style = NULL )plotCohortTiming( result, plotType = "boxplot", timeScale = "days", uniqueCombinations = TRUE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator"), style = NULL )
result |
A summarised_result object. |
plotType |
Type of desired formatted table, possibilities are "boxplot" and "densityplot". |
timeScale |
Time scale to show, it can be "days" or "years". |
uniqueCombinations |
Whether to restrict to unique reference and comparator comparisons. |
facet |
Columns to facet by. See options with
|
colour |
Columns to color by. See options with
|
style |
Visual theme to apply. Character, or |
A ggplot.
## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = c("acetaminophen", "morphine", "warfarin") ) timings <- summariseCohortTiming(cdm$my_cohort) plotCohortTiming( timings, timeScale = "years", uniqueCombinations = FALSE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator") ) plotCohortTiming( timings, plotType = "densityplot", timeScale = "years", uniqueCombinations = FALSE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator") ) cdmDisconnect(cdm = cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = c("acetaminophen", "morphine", "warfarin") ) timings <- summariseCohortTiming(cdm$my_cohort) plotCohortTiming( timings, timeScale = "years", uniqueCombinations = FALSE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator") ) plotCohortTiming( timings, plotType = "densityplot", timeScale = "years", uniqueCombinations = FALSE, facet = c("cdm_name", "cohort_name_reference"), colour = c("cohort_name_comparator") ) cdmDisconnect(cdm = cdm) ## End(Not run)
plotComparedLargeScaleCharacteristics( result, colour, reference = NULL, facet = NULL, missings = 0, style = NULL )plotComparedLargeScaleCharacteristics( result, colour, reference = NULL, facet = NULL, missings = 0, style = NULL )
result |
A summarised_result object. |
colour |
Columns to color by. See options with
|
reference |
A named character to set up the reference. It must be one of the levels of reference. |
facet |
Columns to facet by. See options with
|
missings |
Value to replace the missing value with. If NULL missing values will be eliminated. |
style |
Visual theme to apply. Character, or |
A ggplot.
## Not run: library(CohortCharacteristics) library(DrugUtilisation) library(plotly, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) resultsLsc <- cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) resultsLsc |> plotComparedLargeScaleCharacteristics( colour = "variable_level", reference = "-365 to -1", missings = NULL ) |> ggplotly() cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(DrugUtilisation) library(plotly, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) resultsLsc <- cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) resultsLsc |> plotComparedLargeScaleCharacteristics( colour = "variable_level", reference = "-365 to -1", missings = NULL ) |> ggplotly() cdmDisconnect(cdm) ## End(Not run)
plotLargeScaleCharacteristics( result, facet = c("cdm_name", "cohort_name"), colour = "variable_level", style = NULL )plotLargeScaleCharacteristics( result, facet = c("cdm_name", "cohort_name"), colour = "variable_level", style = NULL )
result |
A summarised_result object. |
facet |
Columns to facet by. See options with
|
colour |
Columns to color by. See options with
|
style |
Visual theme to apply. Character, or |
A ggplot2 object.
## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) resultsLsc <- cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) resultsLsc |> plotLargeScaleCharacteristics( facet = c("cdm_name", "cohort_name"), colour = "variable_level" ) cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) resultsLsc <- cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) resultsLsc |> plotLargeScaleCharacteristics( facet = c("cdm_name", "cohort_name"), colour = "variable_level" ) cdmDisconnect(cdm) ## End(Not run)
Summarise characteristics of cohorts in a cohort table
summariseCharacteristics( cohort, cohortId = NULL, strata = list(), counts = TRUE, demographics = TRUE, ageGroup = NULL, tableIntersectFlag = list(), tableIntersectCount = list(), tableIntersectDate = list(), tableIntersectDays = list(), cohortIntersectFlag = list(), cohortIntersectCount = list(), cohortIntersectDate = list(), cohortIntersectDays = list(), conceptIntersectFlag = list(), conceptIntersectCount = list(), conceptIntersectDate = list(), conceptIntersectDays = list(), otherVariables = character(), estimates = list(), weights = NULL )summariseCharacteristics( cohort, cohortId = NULL, strata = list(), counts = TRUE, demographics = TRUE, ageGroup = NULL, tableIntersectFlag = list(), tableIntersectCount = list(), tableIntersectDate = list(), tableIntersectDays = list(), cohortIntersectFlag = list(), cohortIntersectCount = list(), cohortIntersectDate = list(), cohortIntersectDays = list(), conceptIntersectFlag = list(), conceptIntersectCount = list(), conceptIntersectDate = list(), conceptIntersectDays = list(), otherVariables = character(), estimates = list(), weights = NULL )
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
strata |
A list of variables to stratify results. These variables must have been added as additional columns in the cohort table. |
counts |
TRUE or FALSE. If TRUE, record and person counts will be produced. |
demographics |
TRUE or FALSE. If TRUE, patient demographics (cohort start date, cohort end date, age, sex, prior observation, and future observation will be summarised). |
ageGroup |
A list of age groups to stratify results by. |
tableIntersectFlag |
A list of arguments that uses PatientProfiles::addTableIntersectFlag() to add variables to summarise. |
tableIntersectCount |
A list of arguments that uses PatientProfiles::addTableIntersectCount() to add variables to summarise. |
tableIntersectDate |
A list of arguments that uses PatientProfiles::addTableIntersectDate() to add variables to summarise. |
tableIntersectDays |
A list of arguments that uses PatientProfiles::addTableIntersectDays() to add variables to summarise. |
cohortIntersectFlag |
A list of arguments that uses PatientProfiles::addCohortIntersectFlag() to add variables to summarise. |
cohortIntersectCount |
A list of arguments that uses PatientProfiles::addCohortIntersectCount() to add variables to summarise. |
cohortIntersectDate |
A list of arguments that uses PatientProfiles::addCohortIntersectDate() to add variables to summarise. |
cohortIntersectDays |
A list of arguments that uses PatientProfiles::addCohortIntersectDays() to add variables to summarise. |
conceptIntersectFlag |
A list of arguments that uses PatientProfiles::addConceptIntersectFlag() to add variables to summarise. |
conceptIntersectCount |
A list of arguments that uses PatientProfiles::addConceptIntersectCount() to add variables to summarise. |
conceptIntersectDate |
A list of arguments that uses PatientProfiles::addConceptIntersectDate() to add variables to summarise. |
conceptIntersectDays |
A list of arguments that uses PatientProfiles::addConceptIntersectDays() to add variables to summarise. |
otherVariables |
Other variables contained in cohort that you want to be summarised. |
estimates |
To modify the default estimates for a variable.
By default: 'min', 'q25', 'median', 'q75', 'max' for "date", for "numeric" and
"integer" variables ("numeric" and "integer" also use 'mean' and 'sd'
estimates). 'count' and 'percentage' for "categorical" and "binary".
You have to provide them as a list: |
weights |
Column in cohort that points to weights of each individual. |
A summary of the characteristics of the cohorts in the cohort table.
library(dplyr, warn.conflicts = FALSE) library(CohortCharacteristics) library(PatientProfiles) cdm <- mockCohortCharacteristics() cdm$cohort1 |> addSex() |> addAge( ageGroup = list(c(0, 40), c(41, 150)) ) |> summariseCharacteristics( strata = list("sex", "age_group"), cohortIntersectFlag = list( "Cohort 2 Flag" = list( targetCohortTable = "cohort2", window = c(-365, 0) ) ), cohortIntersectCount = list( "Cohort 2 Count" = list( targetCohortTable = "cohort2", window = c(-365, 0) ) ) ) |> glimpse()library(dplyr, warn.conflicts = FALSE) library(CohortCharacteristics) library(PatientProfiles) cdm <- mockCohortCharacteristics() cdm$cohort1 |> addSex() |> addAge( ageGroup = list(c(0, 40), c(41, 150)) ) |> summariseCharacteristics( strata = list("sex", "age_group"), cohortIntersectFlag = list( "Cohort 2 Flag" = list( targetCohortTable = "cohort2", window = c(-365, 0) ) ), cohortIntersectCount = list( "Cohort 2 Count" = list( targetCohortTable = "cohort2", window = c(-365, 0) ) ) ) |> glimpse()
Summarise attrition associated with cohorts in a cohort table
summariseCohortAttrition(cohort, cohortId = NULL)summariseCohortAttrition(cohort, cohortId = NULL)
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
A summary of the attrition for the cohorts in the cohort table.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortAttrition(cohort = cdm$cohort1) |> glimpse()library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortAttrition(cohort = cdm$cohort1) |> glimpse()
summariseCohortCodelist(cohort, cohortId = NULL)summariseCohortCodelist(cohort, cohortId = NULL)
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
A summarised_result object with the exported cohort codelist information.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) library(omock) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet(cdm = cdm, conceptSet = list(pharyngitis = 4112343L), name = "my_cohort") result <- summariseCohortCodelist(cdm$my_cohort) glimpse(result) tidy(result)library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) library(omock) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet(cdm = cdm, conceptSet = list(pharyngitis = 4112343L), name = "my_cohort") result <- summariseCohortCodelist(cdm$my_cohort) glimpse(result) tidy(result)
Summarise counts for cohorts in a cohort table
summariseCohortCount(cohort, cohortId = NULL, strata = list())summariseCohortCount(cohort, cohortId = NULL, strata = list())
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
strata |
A list of variables to stratify results. These variables must have been added as additional columns in the cohort table. |
A summary of counts of the cohorts in the cohort table.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortCount(cohort = cdm$cohort1) |> glimpse()library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortCount(cohort = cdm$cohort1) |> glimpse()
Summarise overlap between cohorts in a cohort table
summariseCohortOverlap( cohort, cohortId = NULL, strata = list(), overlapBy = "subject_id" )summariseCohortOverlap( cohort, cohortId = NULL, strata = list(), overlapBy = "subject_id" )
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
strata |
A list of variables to stratify results. These variables must have been added as additional columns in the cohort table. |
overlapBy |
Columns in cohort to use as record identifiers. |
A summary of overlap between cohorts in the cohort table.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortOverlap(cdm$cohort2) |> glimpse()library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics() summariseCohortOverlap(cdm$cohort2) |> glimpse()
Summarise timing between entries into cohorts in a cohort table
summariseCohortTiming( cohort, cohortId = NULL, strata = list(), restrictToFirstEntry = TRUE, estimates = c("min", "q25", "median", "q75", "max", "density"), density = lifecycle::deprecated() )summariseCohortTiming( cohort, cohortId = NULL, strata = list(), restrictToFirstEntry = TRUE, estimates = c("min", "q25", "median", "q75", "max", "density"), density = lifecycle::deprecated() )
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
strata |
A list of variables to stratify results. These variables must have been added as additional columns in the cohort table. |
restrictToFirstEntry |
If TRUE only an individual's first entry per cohort will be considered. If FALSE all entries per individual will be considered. |
estimates |
Summary statistics to use when summarising timing. |
density |
deprecated. |
A summary of timing between entries into cohorts in the cohort table.
library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics(numberIndividuals = 100) summariseCohortTiming(cdm$cohort2) |> glimpse()library(CohortCharacteristics) library(dplyr, warn.conflicts = FALSE) cdm <- mockCohortCharacteristics(numberIndividuals = 100) summariseCohortTiming(cdm$cohort2) |> glimpse()
This function is used to summarise the large scale characteristics of a cohort table
summariseLargeScaleCharacteristics( cohort, cohortId = NULL, strata = list(), window = list(c(-Inf, -366), c(-365, -31), c(-30, -1), c(0, 0), c(1, 30), c(31, 365), c(366, Inf)), eventInWindow = NULL, episodeInWindow = NULL, indexDate = "cohort_start_date", censorDate = NULL, includeSource = FALSE, minimumFrequency = 0.005, excludedCodes = c(0) )summariseLargeScaleCharacteristics( cohort, cohortId = NULL, strata = list(), window = list(c(-Inf, -366), c(-365, -31), c(-30, -1), c(0, 0), c(1, 30), c(31, 365), c(366, Inf)), eventInWindow = NULL, episodeInWindow = NULL, indexDate = "cohort_start_date", censorDate = NULL, includeSource = FALSE, minimumFrequency = 0.005, excludedCodes = c(0) )
cohort |
A cohort_table object. |
cohortId |
A cohort definition id to restrict by. If NULL, all cohorts will be included. |
strata |
A list of variables to stratify results. These variables must have been added as additional columns in the cohort table. |
window |
Temporal windows that we want to characterize. |
eventInWindow |
Tables to characterise the events in the window. eventInWindow must be provided if episodeInWindow is not specified. |
episodeInWindow |
Tables to characterise the episodes in the window. episodeInWindow must be provided if eventInWindow is not specified. |
indexDate |
Variable in x that contains the date to compute the intersection. |
censorDate |
whether to censor overlap events at a specific date or a column date of x |
includeSource |
Whether to include source concepts. |
minimumFrequency |
Minimum frequency of codes to be reported. If a
concept_id has a frequency smaller than |
excludedCodes |
Codes excluded. |
The output of this function is a ResultSummary containing the
relevant information.
## Not run: library(CohortCharacteristics) library(DrugUtilisation) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) |> glimpse() cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(DrugUtilisation) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = "acetaminophen" ) cdm$my_cohort |> summariseLargeScaleCharacteristics( window = list(c(-365, -1), c(1, 365)), eventInWindow = "condition_occurrence" ) |> glimpse() cdmDisconnect(cdm) ## End(Not run)
tableCharacteristics( result, type = NULL, header = c("cdm_name", "cohort_name"), groupColumn = character(), hide = c(additionalColumns(result), settingsColumns(result)), style = NULL, .options = list() )tableCharacteristics( result, type = NULL, header = c("cdm_name", "cohort_name"), groupColumn = character(), hide = c(additionalColumns(result), settingsColumns(result)), style = NULL, .options = list() )
result |
A summarised_result object. |
type |
Character string specifying the desired output table format. See
|
header |
Columns to use as header. See options with
|
groupColumn |
Columns to group by. See options with
|
hide |
Columns to hide from the visualisation. See options with
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
.options |
A named list with additional formatting options.
|
A formatted table.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) tableCharacteristics(result)library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCharacteristics(cdm$cohort1) tableCharacteristics(result)
tableCohortAttrition( result, type = NULL, header = "variable_name", groupColumn = c("cdm_name", "cohort_name"), hide = c("variable_level", "reason_id", "estimate_name", settingsColumns(result)), style = NULL, .options = list() )tableCohortAttrition( result, type = NULL, header = "variable_name", groupColumn = c("cdm_name", "cohort_name"), hide = c("variable_level", "reason_id", "estimate_name", settingsColumns(result)), style = NULL, .options = list() )
result |
A summarised_result object. |
type |
Character string specifying the desired output table format. See
|
header |
Columns to use as header. See options with
|
groupColumn |
Columns to group by. See options with
|
hide |
Columns to hide from the visualisation. See options with
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
.options |
A named list with additional formatting options.
|
A formatted table.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCohortAttrition(cdm$cohort2) tableCohortAttrition(result)library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCohortAttrition(cdm$cohort2) tableCohortAttrition(result)
<summarised_result> object from
summariseCohortCodelist()
tableCohortCodelist(result, type = "reactable")tableCohortCodelist(result, type = "reactable")
result |
A summarised_result object. |
type |
Type of table. Supported types: "gt", "flextable", "tibble", "datatable", "reactable". |
A visual table with the results.
library(CohortCharacteristics) library(omock) library(dplyr, warn.conflicts = FALSE) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet(cdm = cdm, conceptSet = list(pharyngitis = 4112343L), name = "my_cohort") result <- summariseCohortCodelist(cdm$my_cohort) tableCohortCodelist(result)library(CohortCharacteristics) library(omock) library(dplyr, warn.conflicts = FALSE) library(CDMConnector) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet(cdm = cdm, conceptSet = list(pharyngitis = 4112343L), name = "my_cohort") result <- summariseCohortCodelist(cdm$my_cohort) tableCohortCodelist(result)
tableCohortCount( result, type = NULL, header = "cohort_name", groupColumn = character(), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )tableCohortCount( result, type = NULL, header = "cohort_name", groupColumn = character(), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )
result |
A summarised_result object. |
type |
Character string specifying the desired output table format. See
|
header |
Columns to use as header. See options with
|
groupColumn |
Columns to group by. See options with
|
hide |
Columns to hide from the visualisation. See options with
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
.options |
A named list with additional formatting options.
|
A formatted table.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCohortCount(cdm$cohort1) tableCohortCount(result)library(CohortCharacteristics) cdm <- mockCohortCharacteristics() result <- summariseCohortCount(cdm$cohort1) tableCohortCount(result)
tableCohortOverlap( result, uniqueCombinations = TRUE, type = NULL, header = c("variable_name"), groupColumn = c("cdm_name"), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )tableCohortOverlap( result, uniqueCombinations = TRUE, type = NULL, header = c("variable_name"), groupColumn = c("cdm_name"), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )
result |
A summarised_result object. |
uniqueCombinations |
Whether to restrict to unique reference and comparator comparisons. |
type |
Character string specifying the desired output table format. See
|
header |
Columns to use as header. See options with
|
groupColumn |
Columns to group by. See options with
|
hide |
Columns to hide from the visualisation. See options with
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
.options |
A named list with additional formatting options.
|
A formatted table.
library(CohortCharacteristics) cdm <- mockCohortCharacteristics() overlap <- summariseCohortOverlap(cdm$cohort2) tableCohortOverlap(overlap)library(CohortCharacteristics) cdm <- mockCohortCharacteristics() overlap <- summariseCohortOverlap(cdm$cohort2) tableCohortOverlap(overlap)
tableCohortTiming( result, timeScale = "days", uniqueCombinations = TRUE, type = NULL, header = strataColumns(result), groupColumn = c("cdm_name"), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )tableCohortTiming( result, timeScale = "days", uniqueCombinations = TRUE, type = NULL, header = strataColumns(result), groupColumn = c("cdm_name"), hide = c("variable_level", settingsColumns(result)), style = NULL, .options = list() )
result |
A summarised_result object. |
timeScale |
Time scale to show, it can be "days" or "years". |
uniqueCombinations |
Whether to restrict to unique reference and comparator comparisons. |
type |
Character string specifying the desired output table format. See
|
header |
Columns to use as header. See options with
|
groupColumn |
Columns to group by. See options with
|
hide |
Columns to hide from the visualisation. See options with
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
.options |
A named list with additional formatting options.
|
A formatted table.
## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = c("acetaminophen", "morphine", "warfarin") ) timings <- summariseCohortTiming(cdm$my_cohort) tableCohortTiming(timings, timeScale = "years") cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) library(DrugUtilisation) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateIngredientCohortSet( cdm = cdm, name = "my_cohort", ingredient = c("acetaminophen", "morphine", "warfarin") ) timings <- summariseCohortTiming(cdm$my_cohort) tableCohortTiming(timings, timeScale = "years") cdmDisconnect(cdm) ## End(Not run)
Explore and compare the large scale characteristics of cohorts
tableLargeScaleCharacteristics( result, compareBy = NULL, hide = c("type"), smdReference = NULL, type = "reactable" )tableLargeScaleCharacteristics( result, compareBy = NULL, hide = c("type"), smdReference = NULL, type = "reactable" )
result |
A summarised_result object. |
compareBy |
A column to compare by it can be a choice between "cdm_name", "cohort_name", strata columns, "variable_level" (window) and "type". It can be left NULL for no comparison. |
hide |
Columns to hide. |
smdReference |
Level of reference for the Standardised Mean Differences
(SMD), it has to be one of the values of |
type |
Type of table to generate, it can be either |
A visual table.
## Not run: library(CohortCharacteristics) library(omock) library(CDMConnector) library(dplyr, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(viral_pharyngitis = 4112343), name = "my_cohort" ) result <- summariseLargeScaleCharacteristics( cohort = cdm$my_cohort, window = list(c(-Inf, -1), c(0, 0), c(1, Inf)), episodeInWindow = "drug_exposure" ) tableLargeScaleCharacteristics(result) tableLargeScaleCharacteristics(result, compareBy = "variable_level") tableLargeScaleCharacteristics(result, compareBy = "variable_level", smdReference = "-inf to -1") cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) library(CDMConnector) library(dplyr, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(viral_pharyngitis = 4112343), name = "my_cohort" ) result <- summariseLargeScaleCharacteristics( cohort = cdm$my_cohort, window = list(c(-Inf, -1), c(0, 0), c(1, Inf)), episodeInWindow = "drug_exposure" ) tableLargeScaleCharacteristics(result) tableLargeScaleCharacteristics(result, compareBy = "variable_level") tableLargeScaleCharacteristics(result, compareBy = "variable_level", smdReference = "-inf to -1") cdmDisconnect(cdm) ## End(Not run)
Visualise the top concepts per each cdm name, cohort, statification and window.
tableTopLargeScaleCharacteristics( result, topConcepts = 10, type = NULL, style = NULL )tableTopLargeScaleCharacteristics( result, topConcepts = 10, type = NULL, style = NULL )
result |
A summarised_result object. |
topConcepts |
Number of concepts to restrict the table. |
type |
Type of table, it can be any of the supported
|
style |
Defines the visual formatting of the table. This argument can be provided in one of the following ways:
If style = |
A formated table.
## Not run: library(CohortCharacteristics) library(omock) libarry(CDMConnector) library(dplyr, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(viral_pharyngitis = 4112343), name = "my_cohort" ) result <- summariseLargeScaleCharacteristics( cohort = cdm$my_cohort, window = list(c(-Inf, -1), c(0, 0), c(1, Inf)), episodeInWindow = "drug_exposure" ) tableTopLargeScaleCharacteristics(result) cdmDisconnect(cdm) ## End(Not run)## Not run: library(CohortCharacteristics) library(omock) libarry(CDMConnector) library(dplyr, warn.conflicts = FALSE) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm <- generateConceptCohortSet( cdm = cdm, conceptSet = list(viral_pharyngitis = 4112343), name = "my_cohort" ) result <- summariseLargeScaleCharacteristics( cohort = cdm$my_cohort, window = list(c(-Inf, -1), c(0, 0), c(1, Inf)), episodeInWindow = "drug_exposure" ) tableTopLargeScaleCharacteristics(result) cdmDisconnect(cdm) ## End(Not run)