### Install OmopSketch Source: https://ohdsi.github.io/OmopSketch/index.html Installation instructions for the package from CRAN or GitHub. ```R install.packages("OmopSketch") ``` ```R # install.packages("remotes") remotes::install_github("OHDSI/OmopSketch") ``` -------------------------------- ### Example usage of summariseOmopSnapshot Source: https://ohdsi.github.io/OmopSketch/reference/summariseOmopSnapshot.html Full example demonstrating the creation of a mock CDM, summarising it, and displaying the result. ```R # \donttest{ library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseOmopSnapshot(cdm = cdm) tableOmopSnapshot(result = result) cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Summarise temporal trends example Source: https://ohdsi.github.io/OmopSketch/reference/summariseTrend.html Example demonstrating the setup of a mock CDM and the execution of a trend summary with stratification by age and sex. ```R # \donttest{ library(OmopSketch) library(omock) library(dplyr) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseTrend( cdm = cdm, event = c("condition_occurrence", "drug_exposure"), episode = "observation_period", output = "person", interval = "years", ageGroup = list("<=20" = c(0, 20), ">20" = c(21, Inf)), sex = TRUE, dateRange = as.Date(c("1950-01-01", "2010-12-31")) ) plotTrend(result = result, facet = sex ~ omop_table, colour = c("age_group")) #> Warning: `type` not included in facet or colour, but have multiple values. cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Summarise concept counts example Source: https://ohdsi.github.io/OmopSketch/reference/summariseConceptIdCounts.html Example demonstrating how to initialise a mock CDM, perform concept count summarisation, and display the results. ```R # \donttest{ library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseConceptIdCounts( cdm = cdm, omopTableName = "condition_occurrence", countBy = c("record", "person"), sex = TRUE ) tableConceptIdCounts(result = result) cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Example usage of tableTopConceptCounts Source: https://ohdsi.github.io/OmopSketch/reference/tableTopConceptCounts.html Demonstrates how to generate a table of the top 5 concepts from a mock CDM dataset. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseConceptIdCounts(cdm = cdm, omopTableName = "condition_occurrence") tableTopConceptCounts(result = result, top = 5) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Example of tableRecordCount Source: https://ohdsi.github.io/OmopSketch/reference/tableRecordCount.html Demonstrates creating a record count summary from a mock CDM and visualizing it with tableRecordCount. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. summarisedResult <- summariseRecordCount( cdm = cdm, omopTableName = c("condition_occurrence", "drug_exposure"), interval = "years", ageGroup = list("<=20" = c(0, 20), ">20" = c(21, Inf)), sex = TRUE ) tableRecordCount(result = summarisedResult) ``` -------------------------------- ### Generate a visual snapshot table Source: https://ohdsi.github.io/OmopSketch/reference/tableOmopSnapshot.html This example demonstrates how to create a mock CDM, generate a snapshot summary, and render it as a visual table. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseOmopSnapshot(cdm = cdm) tableOmopSnapshot(result = result) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Example usage of plotPerson Source: https://ohdsi.github.io/OmopSketch/reference/plotPerson.html Example workflow demonstrating the creation of a mock CDM, summarising person data, and preparing for visualisation. ```R # \donttest{ library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summarisePerson(cdm = cdm) tablePerson(result = result) #> ! The following column types were changed: #> • variable_name: from integer to character cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Generate and display a trend table Source: https://ohdsi.github.io/OmopSketch/reference/tableTrend.html This example demonstrates how to summarize trends in a CDM and display the result using tableTrend. ```R library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summariseTrend( cdm = cdm, episode = "observation_period", event = c("drug_exposure", "condition_occurrence"), interval = "years", ageGroup = list("<=20" = c(0, 20), ">20" = c(21, Inf)), sex = TRUE ) tableTrend(result = result) ``` -------------------------------- ### Example usage of plotRecordCount Source: https://ohdsi.github.io/OmopSketch/reference/plotRecordCount.html Demonstrates creating a mock CDM, summarizing record counts, and generating a plot. ```R # \donttest{ library(omock) library(OmopSketch) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. summarisedResult <- summariseRecordCount( cdm = cdm, omopTableName = "condition_occurrence", ageGroup = list("<=20" = c(0, 20), ">20" = c(21, Inf)), sex = TRUE ) #> Warning: `summariseRecordCount()` was deprecated in OmopSketch 1.0.0. #> ℹ Please use `summariseTrend()` instead. plotRecordCount( result = summarisedResult, colour = "age_group", facet = sex ~ . ) #> Warning: `plotRecordCount()` was deprecated in OmopSketch 1.0.0. #> ℹ Please use `plotTrend()` instead. cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Generate and visualize observation period summary Source: https://ohdsi.github.io/OmopSketch/reference/tableObservationPeriod.html Example demonstrating how to create a mock CDM, summarize observation periods, and generate a table and plot. ```R # \donttest{ library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseObservationPeriod(cdm = cdm) #> Warning: ! There are 2649 individuals not included in the person table. tableObservationPeriod(result = result) plotObservationPeriod( result = result, variableName = "Duration in days", plotType = "boxplot" ) cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Example usage of summariseObservationPeriod Source: https://ohdsi.github.io/OmopSketch/reference/summariseObservationPeriod.html A complete workflow demonstrating how to initialize a mock CDM, generate a summary, display the results in a table, and visualize the duration. ```R library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summariseObservationPeriod(cdm = cdm) tableObservationPeriod(result = result) plotObservationPeriod( result = result, variableName = "Duration in days", plotType = "boxplot" ) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Example usage of plotConceptSetCounts Source: https://ohdsi.github.io/OmopSketch/reference/plotConceptSetCounts.html Demonstrates creating a mock CDM, summarizing concept set counts, and plotting the results. ```R library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseConceptSetCounts( cdm = cdm, conceptSet = list( "asthma" = c(4051466, 317009), "rhinitis" = c(4280726, 4048171, 40486433) ) ) #> Warning: `summariseConceptSetCounts()` was deprecated in OmopSketch 0.5.0. #> Warning: ! `codelist` cast to integers. #> ℹ Searching concepts from domain condition in condition_occurrence. #> ℹ Counting concepts result |> filter(variable_name == "Number subjects") |> plotConceptSetCounts( facet = "codelist_name", colour = "standard_concept_name" ) #> Warning: `plotConceptSetCounts()` was deprecated in OmopSketch 0.5.0. cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Example usage of tableInObservation Source: https://ohdsi.github.io/OmopSketch/reference/tableInObservation.html Demonstrates creating a summary object and passing it to tableInObservation. Note that this function is deprecated. ```R library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseInObservation( observationPeriod = cdm$observation_period, interval = "years", output = c("person-days", "record"), ageGroup = list("<=60" = c(0, 60), ">60" = c(61, Inf)), sex = TRUE ) result |> tableInObservation() #> Warning: `tableInObservation()` was deprecated in OmopSketch 1.0.0. #> ℹ Please use `tableTrend()` instead. ``` -------------------------------- ### Visualize trends with plotTrend Source: https://ohdsi.github.io/OmopSketch/reference/plotTrend.html Example demonstrating the creation of a trend plot using a mock CDM dataset. ```R library(dplyr) library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseTrend(cdm, episode = "observation_period", output = c("person-days", "record"), interval = "years", ageGroup = list("<=40" = c(0, 40), ">40" = c(41, Inf)), sex = TRUE ) plotTrend( result = result, output = "record", colour = "sex", facet = "age_group" ) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Example: Visualizing Concept ID Counts Source: https://ohdsi.github.io/OmopSketch/reference/tableConceptIdCounts.html Demonstrates generating a summary of concept ID counts from a mock CDM and displaying the standard concepts in a table. ```R # \donttest{ library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseConceptIdCounts(cdm = cdm, omopTableName = "condition_occurrence") tableConceptIdCounts(result = result, display = "standard") Database OMOP table Standard concept name Standard concept id Standard vocabulary N records GiBleed condition_occurrence Acute allergic reaction 4084167 Snomed 161 GiBleed condition_occurrence Acute bacterial sinusitis 4294548 Snomed 939 GiBleed condition_occurrence Acute bronchitis 260139 Snomed 8184 GiBleed condition_occurrence Acute cholecystitis 198809 Snomed 35 GiBleed condition_occurrence Acute viral pharyngitis 4112343 Snomed 10217 GiBleed condition_occurrence Alzheimer's disease 378419 Snomed 117 GiBleed condition_occurrence Anemia 439777 Snomed 102 GiBleed condition_occurrence Angiodysplasia of stomach 4310024 Snomed 388 GiBleed condition_occurrence Appendicitis 440448 Snomed 157 GiBleed condition_occurrence Asthma 317009 Snomed 5 1–10 of 80 rows Show 102550100 Previous12345...8Next cdmDisconnect(cdm = cdm) # } ``` -------------------------------- ### Example usage of plotObservationPeriod Source: https://ohdsi.github.io/OmopSketch/reference/plotObservationPeriod.html Demonstrates creating a boxplot of observation period duration using a mock CDM reference. ```R library(OmopSketch) library(dplyr, warn.conflicts = FALSE) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. result <- summariseObservationPeriod(cdm = cdm) #> Warning: ! There are 2649 individuals not included in the person table. tableObservationPeriod(result = result) plotObservationPeriod( result = result, variableName = "Duration in days", plotType = "boxplot" ) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Generate a Shiny application for database characteristics Source: https://ohdsi.github.io/OmopSketch/reference/shinyCharacteristics.html Example usage of shinyCharacteristics to create an interactive app from a mock CDM dataset. ```R if (FALSE) { # \dontrun{ library(OmopSketch) library(omock) library(here) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") res <- databaseCharacteristics(cdm = cdm) shinyCharacteristics(result = res, directory = here()) cdmDisconnect(cdm = cdm) } # } ``` -------------------------------- ### Execute Database Characterisation Source: https://ohdsi.github.io/OmopSketch/reference/databaseCharacteristics.html Demonstrates how to initialize a mock CDM, run the characterisation, and export results to a Shiny application. ```R if (FALSE) { # \dontrun{ library(OmopSketch) library(omock) library(dplyr) library(here) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- databaseCharacteristics( cdm = cdm, sample = 100, omopTableName = c("drug_exposure", "condition_occurrence"), sex = TRUE, ageGroup = list(c(0, 50), c(51, 100)), interval = "years", conceptIdCounts = FALSE ) result |> glimpse() shinyCharacteristics(result = result, directory = here()) cdmDisconnect(cdm = cdm) } # } ``` -------------------------------- ### Create a mock CDM for OmopSketch Source: https://ohdsi.github.io/OmopSketch/articles/summarise_observation_period.html Load necessary libraries and initialize a mock CDM reference using the omock package. ```R library(dplyr) #> #> Attaching package: 'dplyr' #> #> The following objects are masked from 'package:stats': #> #> filter, lag #> #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(OmopSketch) library(omock) # Connect to mock database cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. ``` -------------------------------- ### Load OmopSketch and dplyr Source: https://ohdsi.github.io/OmopSketch/index.html Initialize the required libraries for data manipulation and CDM sketching. ```R library(OmopSketch) library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union ``` -------------------------------- ### Create a mock CDM for database characterisation Source: https://ohdsi.github.io/OmopSketch/articles/database_characteristics.html Initializes a mock CDM reference using the GiBleed dataset and the omock package for testing purposes. ```R library(dplyr) #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. cdm #> #> ── # OMOP CDM reference (duckdb) of GiBleed ──────────────────────────────────── #> • omop tables: care_site, cdm_source, concept, concept_ancestor, concept_class, #> concept_relationship, concept_synonym, condition_era, condition_occurrence, #> cost, death, device_exposure, domain, dose_era, drug_era, drug_exposure, #> drug_strength, fact_relationship, location, measurement, metadata, note, #> note_nlp, observation, observation_period, payer_plan_period, person, #> procedure_occurrence, provider, relationship, source_to_concept_map, specimen, #> visit_detail, visit_occurrence, vocabulary #> • cohort tables: - #> • achilles tables: - #> • other tables: - ``` -------------------------------- ### Restrict analysis by date range Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Use the dateRange argument to filter records based on start dates or overlap periods. ```R summarisedResult <- summariseTrend( cdm = cdm, event = "drug_exposure", dateRange = as.Date(c("1990-01-01", "2010-01-01")) ) ``` -------------------------------- ### Create and display a CDM snapshot Source: https://ohdsi.github.io/OmopSketch/index.html Capture metadata about the CDM version and data release, then display it as a flextable. ```R snapshot <- summariseOmopSnapshot(cdm = cdm) tableOmopSnapshot(result = snapshot, type = "flextable") ``` -------------------------------- ### Summarise missing data in CDM tables Source: https://ohdsi.github.io/OmopSketch/reference/summariseMissingData.html Initializes a mock CDM, calculates missing data statistics for specific tables, and displays the results. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summariseMissingData( cdm = cdm, omopTableName = c("condition_occurrence", "visit_occurrence"), sample = 10000 ) tableMissingData(result = result) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Summarise record trends for episode tables Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Splits record counts into start and end date measures when using episode tables like observation_period. ```R summarisedResult <- summariseTrend( cdm = cdm, episode = "observation_period", output = "record", interval = "years" ) summarisedResult |> filter(grepl("Number of records", variable_name)) |> select(variable_name, additional_level, estimate_name, estimate_value) #> # A tibble: 450 × 4 #> variable_name additional_level estimate_name estimate_value #> #> 1 Number of records: start_date 1908-01-01 to 190… count 2 #> 2 Number of records: end_date 1908-01-01 to 190… count 0 #> 3 Number of records: start_date 1908-01-01 to 190… percentage 0.04 #> 4 Number of records: end_date 1908-01-01 to 190… percentage 0.00 #> 5 Number of records: start_date 1909-01-01 to 190… count 22 #> 6 Number of records: end_date 1909-01-01 to 190… count 0 #> 7 Number of records: start_date 1909-01-01 to 190… percentage 0.41 #> 8 Number of records: end_date 1909-01-01 to 190… percentage 0.00 #> 9 Number of records: start_date 1910-01-01 to 191… count 28 #> 10 Number of records: end_date 1910-01-01 to 191… count 0 #> # ℹ 440 more rows ``` -------------------------------- ### Generate a Shiny application for characterisation results Source: https://ohdsi.github.io/OmopSketch/articles/database_characteristics.html Creates a Shiny application in the specified directory to browse and visualise characterisation results. ```R shinyCharacteristics(result = result, directory = "path/to/your/shiny") ``` ```R shinyCharacteristics( result = result, directory = "path/to/my/shiny", title = "Characterisation of my data", logo = "path/to/my/logo.svg", theme = "scarlet", background = "path/to/my/background.md" ) ``` -------------------------------- ### Apply Apache License Boilerplate Source: https://ohdsi.github.io/OmopSketch/LICENSE.html Use this boilerplate notice to apply the Apache License to your work, replacing bracketed fields with your specific information. ```text Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### mockOmopSketch() Source: https://ohdsi.github.io/OmopSketch/reference/mockOmopSketch.html Creates a mock cdm_reference object for testing the OmopSketch package. ```APIDOC ## mockOmopSketch() ### Description Creates a mock cdm_reference object to test the OmopSketch package. ### Usage ```R mockOmopSketch(numberIndividuals = 100) ``` ### Arguments - **numberIndividuals** (numeric) - Optional - Number of individuals to create in the cdm reference object. Defaults to 100. ### Value A mock cdm_reference object. ``` -------------------------------- ### tableOmopSnapshot(result, header = "cdm_name", hide = "variable_level", groupColumn = "variable_name", type = NULL, style = NULL) Source: https://ohdsi.github.io/OmopSketch/reference/tableOmopSnapshot.html Creates a visual table from a summarise_omop_snapshot result. ```APIDOC ## tableOmopSnapshot ### Description Creates a visual table from a summarised_result object (output of summariseOmopSnapshot()). ### Arguments - **result** (summarised_result) - Required - A summarised_result object. - **header** (vector) - Optional - A vector specifying the elements to include in the header. - **hide** (vector) - Optional - Columns to drop from the output table. - **groupColumn** (vector) - Optional - Columns to use as group labels. - **type** (character) - Optional - Character string specifying the desired output table format. - **style** (string/list) - Optional - Defines the visual formatting of the table (pre-defined style, YAML file path, or list of custom R code). ### Value A formatted table visualisation. ``` -------------------------------- ### Create a cdm_reference object Source: https://ohdsi.github.io/OmopSketch/index.html Initialize a cdm_reference object using the omock package for testing purposes. ```R library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") #> ℹ Loading bundled GiBleed tables from package data. #> ℹ Adding drug_strength table. #> ℹ Creating local object. #> ℹ Inserting into duckdb. cdm #> #> ── # OMOP CDM reference (duckdb) of GiBleed ──────────────────────────────────── #> • omop tables: care_site, cdm_source, concept, concept_ancestor, concept_class, #> concept_relationship, concept_synonym, condition_era, condition_occurrence, #> cost, death, device_exposure, domain, dose_era, drug_era, drug_exposure, #> drug_strength, fact_relationship, location, measurement, metadata, note, #> note_nlp, observation, observation_period, payer_plan_period, person, #> procedure_occurrence, provider, relationship, source_to_concept_map, specimen, #> visit_detail, visit_occurrence, vocabulary #> • cohort tables: - #> • achilles tables: - #> • other tables: - ``` -------------------------------- ### Summarise observation periods with default settings Source: https://ohdsi.github.io/OmopSketch/articles/summarise_observation_period.html Generates a summary of the observation_period table using the default configuration. ```R summarisedResult <- summariseObservationPeriod(cdm = cdm) summarisedResult ``` -------------------------------- ### tableTrend(result, header, hide, groupColumn, type, style) Source: https://ohdsi.github.io/OmopSketch/reference/tableTrend.html Creates a visual table from a summarised_result object generated by summariseTrend(). ```APIDOC ## tableTrend(result, header, hide, groupColumn, type, style) ### Description Creates a visual table from a summariseTrend() result. This function formats the summarized data into a presentable table using specified headers, grouping, and styling options. ### Arguments - **result** (summarised_result) - Required - A summarised_result object (output of summariseTrend()). - **header** (vector) - Optional - A vector specifying the elements to include in the header. The order of elements matters, with the first being the topmost header. - **hide** (vector) - Optional - Columns to drop from the output table. - **groupColumn** (vector) - Optional - Columns to use as group labels. - **type** (string) - Optional - Type of formatting output table between 'gt', 'datatable' and 'reactable'. Default is 'gt'. - **style** (string/list) - Optional - Defines the visual formatting of the table. Can be a pre-defined style name, a YAML file path, or a list of custom R code. ### Value A formatted table visualisation. ``` -------------------------------- ### tableTopConceptCounts(result, top = 10, countBy = NULL, type = NULL, style = NULL) Source: https://ohdsi.github.io/OmopSketch/reference/tableTopConceptCounts.html Generates a formatted table visualization of the most common concepts from a summarised_result object. ```APIDOC ## tableTopConceptCounts ### Description This function takes a `summarised_result` object and generates a formatted table highlighting the most frequent concepts. ### Arguments - **result** (summarised_result) - Required - The output object from `summariseConceptIdCounts()`. - **top** (Integer) - Optional - The number of top concepts to display. Defaults to 10. - **countBy** (Character) - Optional - Either 'person' or 'record'. If NULL, the value present in the data is used. - **type** (Character) - Optional - Specifies the desired output table format. If NULL, global options or a default 'gt' table is used. - **style** (Character/List) - Optional - Defines the visual formatting of the table. Can be a pre-defined style name, a YAML file path, or a list of custom R code. ### Value A formatted table visualisation. ### Example ```r library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summariseConceptIdCounts(cdm = cdm, omopTableName = "condition_occurrence") tableTopConceptCounts(result = result, top = 5) ``` ``` -------------------------------- ### Select specific tables for characterization Source: https://ohdsi.github.io/OmopSketch/articles/database_characteristics.html Customize the analysis by specifying a subset of OMOP tables using the omopTableName argument. ```R result <- databaseCharacteristics( cdm = cdm, omopTableName = c("drug_exposure", "condition_occurrence") ) ``` -------------------------------- ### summariseOmopSnapshot() Source: https://ohdsi.github.io/OmopSketch/reference/index.html Summarise a cdm_reference object creating a snapshot with the metadata of the cdm_reference object. ```APIDOC ## summariseOmopSnapshot() ### Description Summarise a cdm_reference object creating a snapshot with the metadata of the cdm_reference object. ``` -------------------------------- ### Summarise clinical records in R Source: https://ohdsi.github.io/OmopSketch/reference/summariseClinicalRecords.html Initializes a mock CDM, performs a summary of the condition_occurrence table, and displays the result using tableClinicalRecords. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summariseClinicalRecords( cdm = cdm, omopTableName = "condition_occurrence", recordsPerPerson = c("mean", "sd"), quality = TRUE, conceptSummary = TRUE, missingData = TRUE ) tableClinicalRecords(result = result) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Generate a person summary table Source: https://ohdsi.github.io/OmopSketch/reference/tablePerson.html Creates a summary of the person table from a CDM reference and displays it as a table. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summarisePerson(cdm = cdm) tablePerson(result = result) cdmDisconnect(cdm = cdm) ``` -------------------------------- ### Usage of mockOmopSketch Source: https://ohdsi.github.io/OmopSketch/reference/mockOmopSketch.html Generates a mock cdm_reference object for testing purposes. Note that con, writeSchema, and seed arguments are deprecated. ```R mockOmopSketch( numberIndividuals = 100, con = lifecycle::deprecated(), writeSchema = lifecycle::deprecated(), seed = lifecycle::deprecated() ) ``` -------------------------------- ### summariseInObservation(observationPeriod, interval = "overall", output = "record", ageGroup = NULL, sex = FALSE, dateRange = NULL) Source: https://ohdsi.github.io/OmopSketch/reference/summariseInObservation.html Calculates observation statistics for an OMOP observation_period table. ```APIDOC ## summariseInObservation ### Description Summarise the number of people in observation during a specific interval of time. ### Usage ```r summariseInObservation( observationPeriod, interval = "overall", output = "record", ageGroup = NULL, sex = FALSE, dateRange = NULL ) ``` ### Arguments - **observationPeriod** (omop table) - An observation_period omop table. It must be part of a cdm_reference object. - **interval** (string) - Time interval to stratify by. It can either be "years", "quarters", "months" or "overall". - **output** (string) - Output format. It can be either the number of records ("record"), the number of person-days ("person-days"), the number of subjects ("person"), the number of females ("sex") or the median age of population in observation ("age"). - **ageGroup** (list) - A list of age groups to stratify the results by. Each element represents a specific age range. - **sex** (logical) - Whether to stratify results by sex (TRUE) or not (FALSE). - **dateRange** (vector) - A vector of two dates defining the desired study period. ### Value A `summarised_result` object with the results. ``` -------------------------------- ### Summarise with age groups and plot with aesthetics Source: https://ohdsi.github.io/OmopSketch/articles/summarise_observation_period.html Aggregates data by sex and custom age groups, then visualises using colour and facet arguments. ```R summarisedResult <- summariseObservationPeriod( cdm = cdm, sex = TRUE, ageGroup = list("<35" = c(0, 34), ">=35" = c(35, Inf)) ) plotObservationPeriod( result = summarisedResult, colour = "sex", facet = "age_group" ) ``` -------------------------------- ### summariseTrend(cdm, event = NULL, episode = NULL, output = "record", interval = "overall", ageGroup = NULL, sex = FALSE, inObservation = FALSE, dateRange = NULL) Source: https://ohdsi.github.io/OmopSketch/reference/summariseTrend.html Summarises temporal trends from OMOP CDM tables, considering data within the observation period. It supports both event and episode tables and can report trends such as number of records, number of subjects, person-days, median age, and number of females. ```APIDOC ## summariseTrend ### Description Summarises temporal trends from OMOP CDM tables, considering only data within the observation period. It supports both event and episode tables and can report trends such as number of records, number of subjects, person-days, median age, and number of females. ### Parameters - **cdm** (cdm_reference) - Required - A cdm_reference object. - **event** (character vector) - Optional - OMOP table names to treat as event tables (uses only start date). - **episode** (character vector) - Optional - OMOP table names to treat as episode tables (uses start and end date). - **output** (character vector) - Optional - Metrics to summarise: "record" (default), "person", "person-days", "age", "sex". - **interval** (character) - Optional - Time interval to stratify by: "years", "quarters", "months", or "overall". - **ageGroup** (list) - Optional - Age groups to stratify by, e.g., list(children = c(0, 17)). - **sex** (logical) - Optional - Whether to stratify by sex. - **inObservation** (logical) - Optional - If TRUE, stratifies by whether records occur within an observation period. - **dateRange** (vector) - Optional - A vector of two dates defining the study period. ### Returns - **summarised_result** (object) - A summarised_result object containing the calculated trends. ``` -------------------------------- ### databaseCharacteristics() Source: https://ohdsi.github.io/OmopSketch/reference/index.html Summarise Database Characteristics for OMOP CDM. ```APIDOC ## databaseCharacteristics() ### Description Summarise Database Characteristics for OMOP CDM. ``` -------------------------------- ### BibTeX Citation for OmopSketch Source: https://ohdsi.github.io/OmopSketch/authors.html Use this BibTeX entry to cite the OmopSketch R package in academic publications. ```bibtex @Manual{, title = {OmopSketch: Characterise Tables of an OMOP Common Data Model Instance}, author = {Marta Alcalde-Herraiz and Kim Lopez-Guell and Elin Rowlands and Cecilia Campanile and Edward Burn and Martí Català}, year = {2026}, note = {R package version 1.1.0.900}, url = {https://OHDSI.github.io/OmopSketch/}, } ``` -------------------------------- ### Summarize and display person table Source: https://ohdsi.github.io/OmopSketch/reference/tablePerson.html Generates a summary of the person table from a CDM reference and renders it as a table. ```R library(OmopSketch) library(omock) cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb") result <- summarisePerson(cdm = cdm) tablePerson(result = result) ``` -------------------------------- ### Summarise trend by quarterly intervals Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Configures the temporal granularity to quarters to observe trends over shorter time periods. ```R summarisedResult <- summariseTrend( cdm = cdm, event = "condition_occurrence", interval = "quarters", output = "record" ) summarisedResult |> select(additional_level, estimate_value) #> # A tibble: 884 × 2 #> additional_level estimate_value #> #> 1 1908-10-01 to 1908-12-31 1 #> 2 1908-10-01 to 1908-12-31 0.00 #> 3 1909-04-01 to 1909-06-30 2 #> 4 1909-04-01 to 1909-06-30 0.00 #> 5 1909-07-01 to 1909-09-30 2 #> 6 1909-07-01 to 1909-09-30 0.00 #> 7 1910-01-01 to 1910-03-31 4 #> 8 1910-01-01 to 1910-03-31 0.01 #> 9 1910-04-01 to 1910-06-30 4 #> 10 1910-04-01 to 1910-06-30 0.01 #> # ℹ 874 more rows ``` -------------------------------- ### Inspect Summarised Result Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Use settings and glimpse to inspect the structure and metadata of a summarised result object. ```R summarisedResult |> settings() |> glimpse() ``` -------------------------------- ### Function signature for tableTopConceptCounts Source: https://ohdsi.github.io/OmopSketch/reference/tableTopConceptCounts.html The standard function signature defining parameters for generating concept count tables. ```R tableTopConceptCounts( result, top = 10, countBy = NULL, type = NULL, style = NULL ) ``` -------------------------------- ### Include concept counts Source: https://ohdsi.github.io/OmopSketch/articles/database_characteristics.html Enable concept-level summaries by setting conceptIdCounts to TRUE. ```R result <- databaseCharacteristics( cdm = cdm, conceptIdCounts = TRUE ) ``` -------------------------------- ### tableConceptIdCounts(result, display = "overall", type = "reactable") Source: https://ohdsi.github.io/OmopSketch/reference/tableConceptIdCounts.html Creates a visual table from a summarised_result object generated by summariseConceptIdCounts(). ```APIDOC ## tableConceptIdCounts(result, display = "overall", type = "reactable") ### Description Creates a visual table from a summariseConceptIdCounts() result. ### Arguments - **result** (summarised_result) - Required - A summarised_result object (output of summariseConceptIdCounts()). - **display** (character) - Optional - A character string indicating which subset of the data to display. Options are: "overall", "standard", "source", or "missing standard". - **type** (character) - Optional - Type of formatting output table, either "reactable" or "datatable". ### Value A formatted table visualisation. ``` -------------------------------- ### Summarise and Format Trends Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Generate a trend summary using summariseTrend and format the output into a table with tableTrend. ```R result <- summariseTrend( cdm = cdm, event = "condition_occurrence", episode = "observation_period", output = "age", interval = "years" ) tableTrend(result = result) ``` -------------------------------- ### Summarise clinical records with concept summary Source: https://ohdsi.github.io/OmopSketch/articles/summarise_clinical_tables_records.html Set conceptSummary = TRUE to include details on domains, standard/non-standard concept usage, and associated vocabularies. ```R summarisedResult <- summariseClinicalRecords( cdm = cdm, omopTableName = "drug_exposure", recordsPerPerson = NULL, conceptSummary = TRUE, missingData = FALSE, quality = FALSE ) #> ℹ Adding variables of interest to drug_exposure. #> ℹ Summarising records per person in drug_exposure. #> No analyses were selected. #> ℹ Summarising domains in drug_exposure. #> ℹ Summarising standard concepts in drug_exposure. #> ℹ Summarising source vocabularies in drug_exposure. #> ℹ Summarising concept types in drug_exposure. #> ℹ Summarising concept class in drug_exposure. summarisedResult |> select(variable_name, variable_level, estimate_name, estimate_value) #> # A tibble: 41 × 4 #> variable_name variable_level estimate_name estimate_value #> #> 1 Number subjects NA count 2694 #> 2 Number records NA count 67707 #> 3 Number subjects NA percentage 100 #> 4 Domain Drug count 67707 #> 5 Standard concept Standard count 67707 #> 6 Standard vocabulary CVX count 25710 #> 7 Standard vocabulary RxNorm count 41997 #> 8 Source vocabulary No matching concept count 35 #> 9 Source vocabulary CVX count 25710 #> 10 Source vocabulary NDC count 2694 #> # ℹ 31 more rows ``` -------------------------------- ### Select output measure for visualisation Source: https://ohdsi.github.io/OmopSketch/articles/summarise_trend.html Specify the output measure to visualise when the trend result contains multiple metrics. ```R result <- summariseTrend(cdm, event = "measurement", interval = "quarters", output = c("sex", "record"), dateRange = as.Date(c("2010-01-01", "2019-12-31")) ) #> → The observation period in the cdm ends in 2019-07-03 plotTrend( result = result, output = "sex" ) ``` -------------------------------- ### Display concept ID counts by source Source: https://ohdsi.github.io/OmopSketch/articles/summarise_concept_id_counts.html Displays source concept ID, name, and vocabulary when the display argument is set to source. ```R tableConceptIdCounts(result = result, display = "source") ``` -------------------------------- ### tableTrend function usage Source: https://ohdsi.github.io/OmopSketch/reference/tableTrend.html Defines the function signature for creating a visual table from a summariseTrend result. ```R tableTrend( result, header = "cdm_name", hide = "variable_level", groupColumn = c("type", "omop_table"), type = NULL, style = NULL ) ``` -------------------------------- ### Summarise person table usage Source: https://ohdsi.github.io/OmopSketch/reference/summarisePerson.html Basic syntax for calling the summarisePerson function. ```R summarisePerson(cdm) ``` -------------------------------- ### Usage of tableRecordCount Source: https://ohdsi.github.io/OmopSketch/reference/tableRecordCount.html Basic syntax for calling the function. ```R tableRecordCount(result, type = "gt") ```