knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
In this vignette, we will explore the OmopSketch functions designed to provide an overview of the clinical tables within a CDM object (observation_period, visit_occurrence, condition_occurrence, drug_exposure, procedure_occurrence, device_exposure, measurement, observation, and death). Specifically, there are four key functions that facilitate this:
summariseClinicalRecords()
and tableClinicalRecords()
: Use them to create a summary statistics with key basic information of the clinical table (e.g., number of records, number of concepts mapped, etc.)
summariseRecordCount()
, plotRecordCount()
and tableRecordCount()
: Use them to summarise the number of records within specific time intervals.
Let's see an example of its functionalities. To start with, we will load essential packages and create a mock cdm using the mockOmopSketch() database.
library(dplyr) library(OmopSketch) # Connect to mock database cdm <- mockOmopSketch()
Let's now use summariseClinicalTables()
from the OmopSketch package to help us have an overview of one of the clinical tables of the cdm (i.e., condition_occurrence).
summarisedResult <- summariseClinicalRecords(cdm, "condition_occurrence") summarisedResult |> print()
Notice that the output is in the summarised result format.
We can use the arguments to specify which statistics we want to perform. For example, use the argument recordsPerPerson
to indicate which estimates you are interested regarding the number of records per person.
summarisedResult <- summariseClinicalRecords(cdm, "condition_occurrence", recordsPerPerson = c("mean", "sd", "q05", "q95") ) summarisedResult |> filter(variable_name == "records_per_person") |> select(variable_name, estimate_name, estimate_value)
You can further specify if you want to include the number of records in observation (inObservation = TRUE
), the number of concepts mapped (standardConcept = TRUE
), which types of source vocabulary does the table contain (sourceVocabulary = TRUE
), which types of domain does the vocabulary have (domainId = TRUE
) or the concept's type (typeConcept = TRUE
).
summarisedResult <- summariseClinicalRecords(cdm, "condition_occurrence", recordsPerPerson = c("mean", "sd", "q05", "q95"), inObservation = TRUE, standardConcept = TRUE, sourceVocabulary = TRUE, domainId = TRUE, typeConcept = TRUE ) summarisedResult |> select(variable_name, estimate_name, estimate_value) |> glimpse()
Additionally, you can also stratify the previous results by sex and age groups:
summarisedResult <- summariseClinicalRecords(cdm, "condition_occurrence", recordsPerPerson = c("mean", "sd", "q05", "q95"), inObservation = TRUE, standardConcept = TRUE, sourceVocabulary = TRUE, domainId = TRUE, typeConcept = TRUE, sex = TRUE, ageGroup = list("<35" = c(0, 34), ">=35" = c(35, Inf)) ) summarisedResult |> select(variable_name, strata_level, estimate_name, estimate_value) |> glimpse()
Notice that, by default, the "overall" group will be also included, as well as crossed strata (that means, sex == "Female" and ageGroup == ">35").
Also, see that the analysis can be conducted for multiple OMOP tables at the same time:
summarisedResult <- summariseClinicalRecords(cdm, c("observation_period", "drug_exposure"), recordsPerPerson = c("mean", "sd"), inObservation = FALSE, standardConcept = FALSE, sourceVocabulary = FALSE, domainId = FALSE, typeConcept = FALSE ) summarisedResult |> select(group_level, variable_name, estimate_name, estimate_value) |> glimpse()
We can also filter the clinical table to a specific time window by setting the dateRange argument.
summarisedResult <- summariseClinicalRecords(cdm, "drug_exposure", dateRange = as.Date(c("1990-01-01", "2010-01-01"))) summarisedResult |> omopgenerics::settings()|> glimpse()
tableClinicalRecords()
will help you to tidy the previous results and create a gt table.
summarisedResult <- summariseClinicalRecords(cdm, "condition_occurrence", recordsPerPerson = c("mean", "sd", "q05", "q95"), inObservation = TRUE, standardConcept = TRUE, sourceVocabulary = TRUE, domainId = TRUE, typeConcept = TRUE, sex = TRUE ) summarisedResult |> tableClinicalRecords()
OmopSketch can also help you to summarise the trend of the records of an OMOP table. See the example below, where we use summariseRecordCount()
to count the number of records within each year, and then, we use plotRecordCount()
to create a ggplot with the trend.
We can also use tableRecordCount()
to display results in a table of type gt, reactable or datatable. By default it creates a gt table.
summarisedResult <- summariseRecordCount(cdm, "drug_exposure", interval = "years") summarisedResult |> tableRecordCount(type = "gt")
Note that you can adjust the time interval period using the interval
argument, which can be set to either "years", "months" or "quarters". See the example below, where it shows the number of records every 18 months:
summariseRecordCount(cdm, "drug_exposure", interval = "quarters") |> plotRecordCount()
We can further stratify our counts by sex (setting argument sex = TRUE
) or by age (providing an age group). Notice that in both cases, the function will automatically create a group called overall with all the sex groups and all the age groups.
summariseRecordCount(cdm, "drug_exposure", interval = "months", sex = TRUE, ageGroup = list( "<30" = c(0, 29), ">=30" = c(30, Inf) ) ) |> plotRecordCount()
By default, plotRecordCount()
does not apply faceting or colour to any variables. This can result confusing when stratifying by different variables, as seen in the previous picture. We can use VisOmopResults package to help us know by which columns we can colour or face by:
summariseRecordCount(cdm, "drug_exposure", interval = "months", sex = TRUE, ageGroup = list( "0-29" = c(0, 29), "30-Inf" = c(30, Inf) ) ) |> visOmopResults::tidyColumns()
Then, we can simply specify this by using the facet
and colour
arguments from plotRecordCount()
summariseRecordCount(cdm, "drug_exposure", interval = "months", sex = TRUE, ageGroup = list( "0-29" = c(0, 29), "30-Inf" = c(30, Inf) ) ) |> plotRecordCount(facet = omop_table ~ age_group, colour = "sex")
We can also filter the clinical table to a specific time window by setting the dateRange argument.
summariseRecordCount(cdm, "drug_exposure", interval = "years", sex = TRUE, dateRange = as.Date(c("1990-01-01", "2010-01-01"))) |> tableRecordCount(type = "gt")
Finally, disconnect from the cdm
PatientProfiles::mockDisconnect(cdm = cdm)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.