A summarised result

Introduction

A summarised result is a table that contains aggregated summary statistics (that is, a result set that contains no patient-level data).

Let’s look at an example result in this format. Here we have just one esitmate

library(omopgenerics)
library(dplyr)

x <- dplyr::tibble(
    "result_id" = as.integer(1),
    "cdm_name" = "my_cdm",
    "group_name" = "cohort_name",
    "group_level" = "cohort1",
    "strata_name" = "sex",
    "strata_level" = "male",
    "variable_name" = "Age group",
    "variable_level" = "10 to 50",
    "estimate_name" = "count",
    "estimate_type" = "numeric",
    "estimate_value" = "5",
    "additional_name" = "overall",
    "additional_level" = "overall"
  )

result <- newSummarisedResult(x)
result |> 
  dplyr::glimpse()
#> Rows: 1
#> Columns: 13
#> $ result_id        <int> 1
#> $ cdm_name         <chr> "my_cdm"
#> $ group_name       <chr> "cohort_name"
#> $ group_level      <chr> "cohort1"
#> $ strata_name      <chr> "sex"
#> $ strata_level     <chr> "male"
#> $ variable_name    <chr> "Age group"
#> $ variable_level   <chr> "10 to 50"
#> $ estimate_name    <chr> "count"
#> $ estimate_type    <chr> "numeric"
#> $ estimate_value   <chr> "5"
#> $ additional_name  <chr> "overall"
#> $ additional_level <chr> "overall"

We can also associate settings with our results. These will typically be used to explain how the result was created.

result <- newSummarisedResult(x, 
                    settings = dplyr::tibble(result_id = 1,
                                             package = "PatientProfiles",
                                             study = "my_characterisation_study"))

result |> glimpse()
#> Rows: 1
#> Columns: 13
#> $ result_id        <int> 1
#> $ cdm_name         <chr> "my_cdm"
#> $ group_name       <chr> "cohort_name"
#> $ group_level      <chr> "cohort1"
#> $ strata_name      <chr> "sex"
#> $ strata_level     <chr> "male"
#> $ variable_name    <chr> "Age group"
#> $ variable_level   <chr> "10 to 50"
#> $ estimate_name    <chr> "count"
#> $ estimate_type    <chr> "numeric"
#> $ estimate_value   <chr> "5"
#> $ additional_name  <chr> "overall"
#> $ additional_level <chr> "overall"
settings(result)
#> # A tibble: 1 × 6
#>   result_id package         study       result_type package_name package_version
#>       <int> <chr>           <chr>       <chr>       <chr>        <chr>          
#> 1         1 PatientProfiles my_charact… ""          ""           ""

Combining summarised results

result_1 <- dplyr::tibble(
    "result_id" = as.integer(1),
    "cdm_name" = "my_cdm",
    "group_name" = "cohort_name",
    "group_level" = "cohort1",
    "strata_name" = "sex",
    "strata_level" = "male",
    "variable_name" = "Age group",
    "variable_level" = "10 to 50",
    "estimate_name" = "count",
    "estimate_type" = "numeric",
    "estimate_value" = "5",
    "additional_name" = "overall",
    "additional_level" = "overall"
  )
result_1_settings <- dplyr::tibble(result_id = 1,
                                   package_name = "PatientProfiles",
                                   package_version = "1.0.0",
                                   study = "my_characterisation_study",
                                   result_type = "stratified_by_age_group")
result_1 <- newSummarisedResult(result_1, settings = result_1_settings)


result_2 <- dplyr::tibble(
    "result_id" = as.integer(1),
    "cdm_name" = "my_cdm",
    "group_name" = "overall",
    "group_level" = "overall",
    "strata_name" = "overall",
    "strata_level" = "overall",
    "variable_name" = "overall",
    "variable_level" = "overall",
    "estimate_name" = "count",
    "estimate_type" = "numeric",
    "estimate_value" = "55",
    "additional_name" = "overall",
    "additional_level" = "overall"
  )
result_2_settings <- dplyr::tibble(result_id = 1,
                                   package_name = "PatientProfiles",
                                   package_version = "1.0.0",
                                   study = "my_characterisation_study",
                                   result_type = "overall_analysis")
result_2 <- newSummarisedResult(result_2, settings = result_2_settings)

Now we have our results we can combine them using bind. Because the two sets of results contain the same result ID, when the results are combined this will be automatically updated.

result <- bind(list(result_1, result_2))
result |> 
  dplyr::glimpse()
#> Rows: 2
#> Columns: 13
#> $ result_id        <int> 1, 2
#> $ cdm_name         <chr> "my_cdm", "my_cdm"
#> $ group_name       <chr> "cohort_name", "overall"
#> $ group_level      <chr> "cohort1", "overall"
#> $ strata_name      <chr> "sex", "overall"
#> $ strata_level     <chr> "male", "overall"
#> $ variable_name    <chr> "Age group", "overall"
#> $ variable_level   <chr> "10 to 50", "overall"
#> $ estimate_name    <chr> "count", "count"
#> $ estimate_type    <chr> "numeric", "numeric"
#> $ estimate_value   <chr> "5", "55"
#> $ additional_name  <chr> "overall", "overall"
#> $ additional_level <chr> "overall", "overall"
settings(result)
#> # A tibble: 2 × 5
#>   result_id package_name    package_version study                    result_type
#>       <int> <chr>           <chr>           <chr>                    <chr>      
#> 1         1 PatientProfiles 1.0.0           my_characterisation_stu… stratified…
#> 2         2 PatientProfiles 1.0.0           my_characterisation_stu… overall_an…

Minimum cell count suppression

Once we have a summarised result, we can suppress the results based on some minimum cell count.

suppress(result, minCellCount = 7) |> 
  glimpse()
#> Rows: 2
#> Columns: 13
#> $ result_id        <int> 1, 2
#> $ cdm_name         <chr> "my_cdm", "my_cdm"
#> $ group_name       <chr> "cohort_name", "overall"
#> $ group_level      <chr> "cohort1", "overall"
#> $ strata_name      <chr> "sex", "overall"
#> $ strata_level     <chr> "male", "overall"
#> $ variable_name    <chr> "Age group", "overall"
#> $ variable_level   <chr> "10 to 50", "overall"
#> $ estimate_name    <chr> "count", "count"
#> $ estimate_type    <chr> "numeric", "numeric"
#> $ estimate_value   <chr> NA, "55"
#> $ additional_name  <chr> "overall", "overall"
#> $ additional_level <chr> "overall", "overall"