knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
In this vignette, we explore how OmopSketch functions can serve as a valuable tool for summarising missingness in databases containing electronic health records mapped to the OMOP Common Data Model.
To illustrate the package’s functionality, we begin by loading the required packages and connecting to a test CDM using the Eunomia GiBleed dataset.
library(dplyr) library(omock) library(OmopSketch) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") cdm
A common first step in data quality assessment is to identify missing values. In this contest, missing data are defined as either NA values or concept IDs equal to 0 (counts are separated by either of the cases).
You can use the summariseMissingData() function to summarise missingness across the clinical tables in the CDM:
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = "observation_period" ) result_missingData |> glimpse()
You can choose to summarise missing data for specific OMOP CDM tables using the argument omopTableName.
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ) )
You can choose to summarise missing data by sex by setting the argument sex to TRUE.
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ), sex = TRUE )
You can choose to summarise missing data by age group by creating a list defining the age groups you want to use.
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ), ageGroup = list(c(0, 17), c(18, 64), c(65, 150)) )
You can also summarise missing data within a specific date range or across defined time intervals using the dateRange and interval arguments. The interval argument supports "overall" (no time stratification), "years", "quarters", or "months".
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ), interval = "years", dateRange = as.Date(c("2012-01-01", "2019-01-01")) )
You can also choose to summarise missing data for specific columns in the OMOP CDM tables using the argument col.
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ), col = c("observation_period_start_date", "observation_period_end_date") )
Finally, you can summarise missing data on a subset of subjects via the sample argument: provide an integer to randomly select that many person_ids from the person table, or a character string naming a cohort table to limit counts to its subject_ids.
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c( "observation_period", "visit_occurrence", "condition_occurrence", "drug_exposure", "procedure_occurrence", "device_exposure", "measurement", "observation", "death" ), sample = 1000 )
You can present these results using the function tableMissingData().
result_missingData <- summariseMissingData( cdm = cdm, omopTableName = c("condition_occurrence", "drug_exposure", "procedure_occurrence"), sex = TRUE, ageGroup = list(c(0, 17), c(18, 64), c(65, 150)), interval = "years", dateRange = as.Date(c("2012-01-01", "2019-01-01")), sample = 1000 ) result_missingData |> tableMissingData()
This table can either be of type gt (default) or flextable.
tableMissingData(result = result_missingData, type = "gt")
Finally, disconnect from the mock CDM.
cdmDisconnect(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.