Pings-2 BP Data Analysis

Load rerquired packages

Read in the data

Code
df_bp <-dget("df_pings2_bp_data")

Boxplot of BPs for sites

Code
df_bp %>% 
    select(
        Site, sbp_m0,  dbp_m0, sbp_m1, dbp_m1, sbp_m3, dbp_m3, sbp_m6, dbp_m6, 
        sbp_m9, dbp_m9, sbp_m12, dbp_m12) %>% 
    pivot_longer(
        cols = c(starts_with("sbp"), starts_with("dbp")), 
        names_to = "measure", values_to = "values") %>% 
     mutate(
        mth = str_extract(measure, "\\d+$") %>% as.numeric() %>% as.factor(),
        vital = str_extract(measure,  "^[a-z]+")) %>% 
    ggplot(aes(x=mth, y=values, color = vital)) + 
    geom_boxplot() + 
    theme_light() +
    labs(x = "Month", y = "Pressure (mmHg)")+
    facet_wrap(vars(Site), nrow = 4)
Figure 1: Boxplot of Blood Pressure for each Site

Measured blood pressure per site

Code
df_bp %>% 
    select(Site, sbp_m0, sbp_m1, sbp_m3, sbp_m6, sbp_m9, sbp_m12) %>% 
    pivot_longer(
        cols = c(starts_with("sbp")), 
        names_to = "measure", values_to = "values") %>% 
     mutate(
        mth = str_extract(measure, "\\d+$") %>% as.numeric() %>% as.factor(),
        vital = str_extract(measure,  "^[a-z]+"),
        mth = paste("Month", as.character(mth))) %>% 
    drop_na(values) %>% 
    group_by(Site, mth) %>% 
    summarise(count = n()) %>% 
    pivot_wider(id_cols = Site, names_from = mth, values_from = count) %>% 
    relocate(`Month 12`, .after = `Month 9`) %>% 
    ungroup() %>% 
    kableExtra::kable()
Table 1: Distribution of measured systolic blood pressure per visit, per Site
Site Month 0 Month 1 Month 3 Month 6 Month 9 Month 12
AGOGO SITE 28 28 27 27 27 27
ANKAASE SITE 23 23 21 21 21 20
CCTH SITE 51 51 46 44 42 37
KATH SITE 125 121 114 109 105 109
KNUST SITE 52 24 25 23 19 28
KORLE-BU SITE 57 52 48 45 40 45
KUMASI SOUTH HOSPITAL 38 33 33 33 30 29
KWADASO SITE 36 35 33 33 32 30
MANHYIA GOVT HOSPITAL 42 35 30 29 31 25
TAFO SITE 47 47 47 47 46 45
Code
df_bp_long <- 
    df_bp %>% 
    select(
        Site, sid=`RedCap ID`, sbp_m0, sbp_m1, sbp_m3, sbp_m6, sbp_m9, sbp_m12, 
        dbp_m0, dbp_m1, dbp_m3, dbp_m6, dbp_m9, dbp_m12) %>% 
    pivot_longer(
        cols = c(starts_with("sbp"),starts_with("dbp")), 
        names_to = "measure", 
        values_to = "values") %>% 
    filter(!is.na(values)) %>% 
    mutate(
        mth = str_extract(measure, "\\d+$") %>% as.numeric() %>% as.factor(),
        vital = str_extract(measure,  "^[a-z]+"),
        mth = paste("Month", as.character(mth))) %>% 
    select(sid, values, mth, vital, Site) %>% 
    pivot_wider(id_cols = c(sid, mth), values_from = values, names_from = vital) %>% 
    arrange(sid, mth) %>% 
    mutate(
        hpt_status = case_when(
            sbp >= 140 | dbp >= 90 ~ "Hypertensive",
            sbp >= 120 | dbp >= 80 ~ "Borderline",
            sbp < 120  | dbp <  80 ~ "Normal") %>% 
            factor(levels = c("Normal","Borderline", "Hypertensive")),
        mth = factor(
            mth, 
            levels = c(
                "Month 0", "Month 1", "Month 3", "Month 6", "Month 9", 
                "Month 12")
                )
            )

df_bp_long %>% 
    select(hpt_status, mth) %>% 
    gtsummary::tbl_summary(by=mth) %>% 
    gtsummary::bold_labels()
Table 2: Hypertension status at visits
Characteristic Month 0, N = 4991 Month 1, N = 4491 Month 3, N = 4241 Month 6, N = 4111 Month 9, N = 3931 Month 12, N = 3951
hpt_status





    Normal 3 (0.6%) 37 (8.2%) 24 (5.7%) 28 (6.8%) 30 (7.6%) 41 (10%)
    Borderline 26 (5.2%) 122 (27%) 145 (34%) 122 (30%) 127 (32%) 162 (41%)
    Hypertensive 470 (94%) 290 (65%) 255 (60%) 261 (64%) 236 (60%) 192 (49%)
1 n (%)
Code
df_bp_long %>%
    ggplot(aes(x = factor(mth), fill = hpt_status)) +
    geom_bar(position = "fill") +
    stat_count(
        geom = "text",
        aes(
            label = paste(after_stat(count))),
             position=position_fill(vjust=0.5), colour="white"
            ) +
    theme_light()+
    labs(
        fill = "Hypertension Status",
        x = "Months after recruitment",
        y = "Count",
        title = "Blood Pressure status over the study period"
        ) +
    scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9"))+
    theme(legend.position="top")
Figure 2: Hypertension status are review
Code
# df_bp_long %>% 
# #    filter(vital == "sbp") %>% 
#     ggplot(aes(x = as.numeric(as.character(mth)), y = values, group = sid)) +
#     geom_line(alpha =.4, col = "pink") +
#     stat_summary(
#         fun.data = mean_sdl, 
#         geom="line", 
#         colour = "black", 
#         linewidth = .8, 
#         group=1, linetype = 2) +
#         theme_light() +
#     labs(x = "Months")+
#     scale_x_continuous(breaks=c(0,1,3, 6, 9, 12))+
#     facet_wrap(vars(vital), nrow = 2, scales = "free",)
Code
# df_bp %>% 
#     arrange(dbp_m0_2) %>%
#     filter(!is.na(dbp_m0_2)) %>% 
#     arrange(sbp_m0_2) %>%
#     mutate(n = row_number()) %>% 
#     ggplot()+
#     geom_point(aes(y = sbp_m0_2, x = n), color = "red") +
#     geom_point(aes(y = sbp_m0_3, x = n), color = "blue")+
#     geom_segment(aes(y=sbp_m0_2 , yend = sbp_m0_3, x=n,  xend = n), show.legend = F)