MyNixOS website logo
Description

Connect to an OMOP Common Data Model.

Provides tools for working with observational health data in the Observational Medical Outcomes Partnership (OMOP) Common Data Model format with a pipe friendly syntax. Common data model database table references are stored in a single compound object along with metadata.

CDMConnector

CRANstatus codecov.io BuildStatus duckdbstatus Postgresstatus SQL Server odbcstatus Redshiftstatus Snowflakestatus

Are you using the tidyverse with an OMOP Common Data Model?

Interact with your CDM in a pipe-friendly way with CDMConnector.

  • Quickly connect to your CDM and start exploring.
  • Build data analysis pipelines using familiar dplyr verbs.
  • Easily extract subsets of CDM data from a database.

Overview

CDMConnector introduces a single R object that represents an OMOP CDM relational database inspired by the dm, DatabaseConnector, and Andromeda packages. The cdm objects encapsulate references to OMOP CDM tables in a remote RDBMS as well as metadata necessary for interacting with a CDM, allowing for dplyr style data analysis pipelines and interactive data exploration.

OMOP CDMv5.4

Features

CDMConnector is meant to be the entry point for composable tidyverse style data analysis operations on an OMOP CDM. A cdm_reference object behaves like a named list of tables.

  • Quickly create a list of references to a subset of CDM tables
  • Store connection information for later use inside functions
  • Use any DBI driver back-end with the OMOP CDM

See Getting started for more details.

Installation

CDMConnector can be installed from CRAN:

install.packages("CDMConnector")

The development version can be installed from GitHub:

# install.packages("devtools")
devtools::install_github("darwin-eu/CDMConnector")

Usage

Create a cdm reference from any DBI connection to a database containing OMOP CDM tables. Use the cdm_schema argument to point to a particular schema in your database that contains your OMOP CDM tables and the write_schema to specify the schema where results tables can be created, and use cdm_name to provide a name for the database.

library(CDMConnector)

con <- DBI::dbConnect(duckdb::duckdb(dbdir = eunomia_dir()))

cdm <- cdm_from_con(con = con, 
                    cdm_schema = "main", 
                    write_schema = "main", 
                    cdm_name = "my_duckdb_database")

A cdm_reference is a named list of table references:

library(dplyr)
names(cdm)
##  [1] "person"                "observation_period"    "visit_occurrence"     
##  [4] "visit_detail"          "condition_occurrence"  "drug_exposure"        
##  [7] "procedure_occurrence"  "device_exposure"       "measurement"          
## [10] "observation"           "death"                 "note"                 
## [13] "note_nlp"              "specimen"              "fact_relationship"    
## [16] "location"              "care_site"             "provider"             
## [19] "payer_plan_period"     "cost"                  "drug_era"             
## [22] "dose_era"              "condition_era"         "metadata"             
## [25] "cdm_source"            "concept"               "vocabulary"           
## [28] "domain"                "concept_class"         "concept_relationship" 
## [31] "relationship"          "concept_synonym"       "concept_ancestor"     
## [34] "source_to_concept_map" "drug_strength"

Use dplyr verbs with the table references.

cdm$person %>% 
  tally()
## # Source:   SQL [1 x 1]
## # Database: DuckDB v1.0.1-dev5 [root@Darwin 23.0.0:R 4.3.1//private/var/folders/xx/01v98b6546ldnm1rg1_bvk000000gn/T/Rtmp9UjDOa/file25a7230b0dc2.duckdb]
##       n
##   <dbl>
## 1  2694

Compose operations with the pipe.

cdm$condition_era %>%
  left_join(cdm$concept, by = c("condition_concept_id" = "concept_id")) %>% 
  count(top_conditions = concept_name, sort = TRUE)
## # Source:     SQL [?? x 2]
## # Database:   DuckDB v1.0.1-dev5 [root@Darwin 23.0.0:R 4.3.1//private/var/folders/xx/01v98b6546ldnm1rg1_bvk000000gn/T/Rtmp9UjDOa/file25a7230b0dc2.duckdb]
## # Ordered by: desc(n)
##    top_conditions                               n
##    <chr>                                    <dbl>
##  1 Viral sinusitis                          17268
##  2 Acute viral pharyngitis                  10217
##  3 Acute bronchitis                          8184
##  4 Otitis media                              3561
##  5 Osteoarthritis                            2694
##  6 Streptococcal sore throat                 2656
##  7 Sprain of ankle                           1915
##  8 Concussion with no loss of consciousness  1013
##  9 Sinusitis                                 1001
## 10 Acute bacterial sinusitis                  939
## # ℹ more rows

And much more besides. See vignettes for further explanations on how to create database connections, make a cdm reference, and start analysing your data.

Getting help

If you encounter a clear bug, please file an issue with a minimal reproducible example on GitHub.

Citation

## To cite package 'CDMConnector' in publications use:
## 
##   Black A, Gorbachev A, Burn E, Catala Sabate M (????). _CDMConnector:
##   Connect to an OMOP Common Data Model_.
##   https://darwin-eu.github.io/CDMConnector/,
##   https://github.com/darwin-eu/CDMConnector.
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {CDMConnector: Connect to an OMOP Common Data Model},
##     author = {Adam Black and Artem Gorbachev and Edward Burn and Marti {Catala Sabate}},
##     note = {https://darwin-eu.github.io/CDMConnector/, https://github.com/darwin-eu/CDMConnector},
##   }

License: Apache 2.0

Metadata

Version

1.5.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows