# Step 2. Obtain the sequence ratios

# Introduction

In this vignette we will explore the functionality and arguments of `summariseSequenceRatios()` function, which is used to generate the sequence ratios of the SSA. As this function uses the output of `generateSequenceCohortSet()` function (explained in detail in the vignette: Step 1. Generate a sequence cohort), we will pick up the explanation from where we left off in the previous vignette.

Recall that in the previous vignette: Step 1. Generate a sequence cohort, we’ve generated `cdm$aspirin` and `cdm$acetaminophen` before and using them we could generate `cdm$intersect` like so:

    # Generate a sequence cohort
    cdm <- generateSequenceCohortSet(
      cdm = cdm,
      indexTable = "aspirin",
      markerTable = "acetaminophen",
      name = "intersect",
      combinationWindow = c(0,Inf))

# Obtain sequence ratios

One can obtain the crude and adjusted sequence ratios (with its corresponding confidence intervals) using `summariseSequenceRatios()` function:

    summariseSequenceRatios(
      cohort = cdm$intersect
    ) |>
      dplyr::glimpse()
    #> Rows: 10
    #> Columns: 13
    #> $ result_id        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
    #> $ cdm_name         <chr> "Synthea synthetic health database", "Synthea synthet…
    #> $ group_name       <chr> "index_cohort_name &&& marker_cohort_name", "index_co…
    #> $ group_level      <chr> "1191_aspirin &&& 161_acetaminophen", "1191_aspirin &…
    #> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
    #> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
    #> $ variable_name    <chr> "crude", "adjusted", "crude", "crude", "adjusted", "a…
    #> $ variable_level   <chr> "sequence_ratio", "sequence_ratio", "sequence_ratio",…
    #> $ estimate_name    <chr> "point_estimate", "point_estimate", "lower_CI", "uppe…
    #> $ estimate_type    <chr> "numeric", "numeric", "numeric", "numeric", "numeric"…
    #> $ estimate_value   <chr> "1.8108504398827", "186.99811917665", "1.649709638170…
    #> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
    #> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

The obtained output has a summarised result format. In the later vignette (Step 3. Visualise results) we will explore how to visualise the results in a more intuitive way.

    CDMConnector::cdmDisconnect(cdm = cdm)