# Summarise large scale characteristics

## 1.1 Introduction

In the previous vignette we have seen how we can use the CohortCharacteristics package to summarise a set of pre-specified characteristics of a study cohort. These characteristics included patient demographics like age and sex, and also concept sets and cohorts that we defined. Another, often complimentary, way that we can approach characterising a study cohort is by simply summarising all clinical events we see for them in some window around their index date (cohort entry).

To show how large scale characterisation can work we’ll first create a first-ever ankle sprain study cohort using the Eunomia synthetic data.

    library(CDMConnector)
    library(dplyr)
    library(ggplot2)
    library(CohortCharacteristics)

    con <- DBI::dbConnect(duckdb::duckdb(),
      dbdir = CDMConnector::eunomia_dir()
    )
    cdm <- CDMConnector::cdm_from_con(con,
      cdm_schem = "main",
      write_schema = "main"
    )

    cdm <- generateConceptCohortSet(
      cdm = cdm,
      name = "ankle_sprain",
      conceptSet = list("ankle_sprain" = 81151),
      end = "event_end_date",
      limit = "first",
      overwrite = TRUE
    )

## 1.2 Large scale characteristics of study cohorts

To summarise our cohort of individuals with an ankle sprain we will look at their records in three tables of the OMOP CDM (condition_occurrence, procedure_occurrence, and drug_exposure) over two time windows (any time prior to their index date, and on index date). For conditions and procedures we will identify whether someone had a new record starting in the time window. Meanwhile, for drug exposures we will consider whether they had a new or ongoing record in the period.

Lastly, but important to note, we are only going to only return results for concepts for which at least 10% of the study cohort had a record.

    lsc <- cdm$ankle_sprain |>
      summariseLargeScaleCharacteristics(
        window = list(c(-Inf, -1), c(0, 0)),
        eventInWindow = c(
          "condition_occurrence",
          "procedure_occurrence"
        ),
        episodeInWindow = "drug_exposure",
        minimumFrequency = 0.1
      )

    tableLargeScaleCharacteristics(lsc)

| CDM name
--- | ---
| Synthea synthetic health database
| Cohort name
| ankle_sprain
Concept | Window
-inf to -1 | 0 to 0
Table: condition_occurrence (event in window)
Acute bacterial sinusitis (4294548) | 168 (12.4%) | -
Acute bronchitis (260139) | 767 (56.5%) | -
Acute viral pharyngitis (4112343) | 845 (62.3%) | -
Chronic sinusitis (257012) | 162 (11.9%) | -
Concussion with no loss of consciousness (378001) | 185 (13.6%) | -
Osteoarthritis (80180) | 283 (20.9%) | -
Otitis media (372328) | 909 (67.0%) | -
Sinusitis (4283893) | 166 (12.2%) | -
Sprain of ankle (81151) | - | 1,357 (100.0%)
Sprain of wrist (78272) | 148 (10.9%) | -
Streptococcal sore throat (28060) | 499 (36.8%) | -
Viral sinusitis (40481087) | 981 (72.3%) | -
Whiplash injury to neck (4218389) | 137 (10.1%) | -
Table: drug_exposure (episode in window)
Acetaminophen 160 MG Oral Tablet (1127078) | 559 (41.2%) | 199 (14.7%)
Acetaminophen 21.7 MG/ML / Dextromethorphan Hydrobromide 1 MG/ML / doxylamine succinate 0.417 MG/ML Oral Solution (40229134) | 296 (21.8%) | -
Acetaminophen 325 MG Oral Tablet (1127433) | 737 (54.3%) | 330 (24.3%)
Amoxicillin 250 MG / Clavulanate 125 MG Oral Tablet (1713671) | 499 (36.8%) | -
Ampicillin 100 MG/ML Injectable Solution (19129655) | 193 (14.2%) | -
Aspirin 81 MG Oral Tablet (19059056) | 842 (62.0%) | 470 (34.6%)
Doxycycline Monohydrate 50 MG Oral Tablet (46233988) | 172 (12.7%) | -
Haemophilus influenzae type b vaccine, PRP-OMP conjugate (40213314) | 210 (15.5%) | -
Ibuprofen 200 MG Oral Tablet (19078461) | - | 192 (14.2%)
Penicillin G 375 MG/ML Injectable Solution (19006318) | 384 (28.3%) | -
Penicillin V Potassium 250 MG Oral Tablet (19133873) | 491 (36.2%) | -
celecoxib (1118084) | 189 (13.9%) | -
hepatitis B vaccine, adult dosage (40213306) | 226 (16.6%) | -
poliovirus vaccine, inactivated (40213160) | 994 (73.2%) | -
tetanus and diphtheria toxoids, adsorbed, preservative free, for adult use (40213227) | 288 (21.2%) | -
Table: procedure_occurrence (event in window)
Bone immobilization (4170947) | 356 (26.2%) | -
Plain chest X-ray (4163872) | 137 (10.1%) | -
Sputum examination (4151422) | 282 (20.8%) | -
Suture open wound (4125906) | 363 (26.8%) | -

As we can see we have identified numerous concepts for which at least 10% of our study population had a record. Often with larger cohorts and real patient-level data we will obtain many times more results when running large scale characterisation. One option we have to help summarise our results is to pick out the most frequent concepts. Here, for example, we select the top 5 concepts.

    tableLargeScaleCharacteristics(lsc,
      topConcepts = 5
    )

| CDM name
--- | ---
| Synthea synthetic health database
| Cohort name
| ankle_sprain
Concept | Window
-inf to -1 | 0 to 0
Table: condition_occurrence (event in window)
Acute bronchitis (260139) | 767 (56.5%) | -
Acute viral pharyngitis (4112343) | 845 (62.3%) | -
Otitis media (372328) | 909 (67.0%) | -
Sprain of ankle (81151) | - | 1,357 (100.0%)
Viral sinusitis (40481087) | 981 (72.3%) | -
Table: drug_exposure (episode in window)
Acetaminophen 160 MG Oral Tablet (1127078) | 559 (41.2%) | 199 (14.7%)
Acetaminophen 325 MG Oral Tablet (1127433) | 737 (54.3%) | 330 (24.3%)
Amoxicillin 250 MG / Clavulanate 125 MG Oral Tablet (1713671) | 499 (36.8%) | -
Aspirin 81 MG Oral Tablet (19059056) | 842 (62.0%) | 470 (34.6%)
poliovirus vaccine, inactivated (40213160) | 994 (73.2%) | -
Table: procedure_occurrence (event in window)
Bone immobilization (4170947) | 356 (26.2%) | -
Plain chest X-ray (4163872) | 137 (10.1%) | -
Sputum examination (4151422) | 282 (20.8%) | -
Suture open wound (4125906) | 363 (26.8%) | -

## 1.3 Stratified large scale characteristics

Like when summarising pre-specified patient characteristics, we can also get stratified results when summarising large scale characteristics. Here, for example, large scale characteristics are stratified by sex (which we add as an additional column to our cohort table using the PatientProfiles package).

    lsc <- cdm$ankle_sprain |>
      PatientProfiles::addSex() |>
      summariseLargeScaleCharacteristics(
        window = list(c(-Inf, -1), c(0, 0)),
        strata = list("sex"),
        eventInWindow = "drug_exposure",
        minimumFrequency = 0.1
      )

    tableLargeScaleCharacteristics(lsc)

| CDM name
--- | ---
| Synthea synthetic health database
| Cohort name
| ankle_sprain
| sex
| Female | Male | overall
Concept | Window
-inf to -1 | 0 to 0 | -inf to -1 | 0 to 0 | -inf to -1 | 0 to 0
Table: drug_exposure (event in window)
Acetaminophen 160 MG Oral Tablet (1127078) | 292 (42.8%) | 97 (14.2%) | 267 (39.6%) | 102 (15.1%) | 559 (41.2%) | 199 (14.7%)
Acetaminophen 21.7 MG/ML / Dextromethorphan Hydrobromide 1 MG/ML / doxylamine succinate 0.417 MG/ML Oral Solution (40229134) | 132 (19.3%) | - | 164 (24.3%) | - | 296 (21.8%) | -
Acetaminophen 325 MG Oral Tablet (1127433) | 374 (54.8%) | 165 (24.2%) | 363 (53.9%) | 165 (24.5%) | 737 (54.3%) | 330 (24.3%)
Amoxicillin 250 MG / Clavulanate 125 MG Oral Tablet (1713671) | 244 (35.7%) | - | 255 (37.8%) | - | 499 (36.8%) | -
Ampicillin 100 MG/ML Injectable Solution (19129655) | 98 (14.3%) | - | 95 (14.1%) | - | 193 (14.2%) | -
Aspirin 81 MG Oral Tablet (19059056) | 427 (62.5%) | 245 (35.9%) | 415 (61.6%) | 225 (33.4%) | 842 (62.0%) | 470 (34.6%)
Doxycycline Monohydrate 50 MG Oral Tablet (46233988) | 94 (13.8%) | - | 78 (11.6%) | - | 172 (12.7%) | -
Haemophilus influenzae type b vaccine, PRP-OMP conjugate (40213314) | 112 (16.4%) | - | 98 (14.5%) | - | 210 (15.5%) | -
Ibuprofen 200 MG Oral Tablet (19078461) | - | 93 (13.6%) | - | 99 (14.7%) | - | 192 (14.2%)
Nitrofurantoin 5 MG/ML Oral Suspension (920300) | 84 (12.3%) | - | - | - | - | -
Penicillin G 375 MG/ML Injectable Solution (19006318) | 169 (24.7%) | - | 215 (31.9%) | - | 384 (28.3%) | -
Penicillin V Potassium 250 MG Oral Tablet (19133873) | 256 (37.5%) | - | 235 (34.9%) | - | 491 (36.2%) | -
Phenazopyridine hydrochloride 100 MG Oral Tablet (40236824) | 84 (12.3%) | - | - | - | - | -
celecoxib (1118084) | 92 (13.5%) | - | 97 (14.4%) | - | 189 (13.9%) | -
hepatitis B vaccine, adult dosage (40213306) | 128 (18.7%) | - | 98 (14.5%) | - | 226 (16.6%) | -
poliovirus vaccine, inactivated (40213160) | 501 (73.3%) | - | 493 (73.2%) | - | 994 (73.2%) | -
tetanus and diphtheria toxoids, adsorbed, preservative free, for adult use (40213227) | 151 (22.1%) | - | 137 (20.3%) | - | 288 (21.2%) | -
{7 (Inert Ingredients 1 MG Oral Tablet) / 21 (Mestranol 0.05 MG / Norethindrone 1 MG Oral Tablet) } Pack [Norinyl 1+50 28 Day] (19128065) | 135 (19.8%) | - | - | - | - | -