A5K CONSORT

Author

Chloe Mirzayi

Install ggconsort if needed

devtools::install_github("tgerke/ggconsort")

Load necessary packages

library(dplyr)
library(haven)
library(ggconsort)
library(ggplot2)

Import A5K baseline data

ds <- read_spss("data/A5K_Baseline_Dataset(IN PROGRESS)_2023_11_21.sav")
dim(ds)
[1] 32209   872

Build the CONSORT

study_cohorts <- ds %>%
  cohort_start("Completed screening survey") %>% 
  cohort_define(
    sentCASI = .full %>% filter(CASISent == 1),
    incCASI = .full %>% filter(CASISent == 1 & CASIComplete == 0),
    compCASI = .full %>% filter(CASIComplete == 1),
    sentKit = .full %>% filter(KitMailed == 1),
    compKit = .full %>% filter(HIVKitComplete == 1),
    compHIV = .full %>% filter(ValidKitResult == 1 & HIVKitComplete != 1),
    compRect = .full %>%  filter(RectalYN == 1 & HIVKitComplete != 1)
    ) %>% 
  cohort_label(
    sentCASI = "Sent CASI",
    incCASI = "Did not complete<br>CASI",
    compCASI = "Completed CASI",
    sentKit = "Mailed kit",
    compKit = "Both kits<br>returned",
    compHIV = "HIV kit<br>returned",
    compRect = "Rectal kit<br>returned"
    )

Define the CONSORT diagram

study_consort <- study_cohorts %>%
  consort_box_add(
    "full", 0, 50, cohort_count_adorn(study_cohorts, .full)
  ) %>%
  consort_box_add(
    "sentCASI", 0, 30, cohort_count_adorn(study_cohorts, sentCASI)
  ) %>% 
 consort_arrow_add("full", "bottom", "sentCASI", "top") %>% 
    consort_box_add(
    "incCASI", 20, 25, cohort_count_adorn(study_cohorts, incCASI)
  ) %>%
  consort_arrow_add(start_x=0, start_y=25, end="incCASI", end_side="left") %>% 
  consort_box_add("compCASI", 0, 20, 
                  cohort_count_adorn(study_cohorts, compCASI)) %>%
  consort_arrow_add("sentCASI", "bottom", "compCASI", "top") %>% 
  consort_box_add("compKit", 0, 10,
                  cohort_count_adorn(study_cohorts, compKit)) %>% 
  consort_box_add("compHIV", -20, 10, 
                  cohort_count_adorn(study_cohorts, compHIV)) %>% 
  consort_box_add("compRect", 20, 10, 
                  cohort_count_adorn(study_cohorts, compRect)) %>% 
  consort_arrow_add("compCASI", "bottom", "compKit", "top") %>% 
  consort_arrow_add("compCASI", "bottom", "compHIV", "top") %>% 
  consort_arrow_add("compCASI", "bottom", "compRect", "top")

Plot the CONSORT

study_consort %>%
  ggplot() + 
  geom_consort() +
  theme_consort(margin_h = 8, margin_v = 1)