# poster size: print at 63" x 31.5"

knitr::opts_chunk$set(collapse = TRUE, echo = FALSE, message = FALSE, warning = FALSE)
library(tidyverse)
devtools::load_all()
load_data(update = TRUE)
set_options()
ds <- project_data

dsBase <- ds %>% 
  dplyr::filter(fVN == "Baseline")

dsComplete <- ds %>% 
  dplyr::group_by(SID) %>%
  dplyr::filter(n() == 3) %>%
  dplyr::ungroup()
## Include captions below using `captioner` package
figNums <- captioner::captioner(prefix = 'Figure')
supFigNums <- captioner::captioner(prefix = 'Supplementary Figure')
tabNums <- captioner::captioner(prefix = 'Table')
supTabNums <- captioner::captioner(prefix = 'Supplementary Table')

Subject Characterization

Subject characteristics across visit numbers

subCharTable <- tableone::CreateTableOne(
  vars = c("Age",
           "Sex",
           "Ethnicity",
           "BMI",
           "Waist",
           "eGFR",
           "ACR",
           "UrineCreatinine",
           "UrineMicroalbumin",
           "UrinaryCalcium",
           "UDBP",
           "Creatinine",
           "VitaminD",
           "PTH",
           "ALT",
           "Systolic",
           "Diastolic",
           "MeanArtPressure",
           "Glucose0",
           "Glucose120",
           "dmStatus",
           "SmokeCigs"),
  strata = c("UDBPStatus"),
  data = ds,
  factorVars = c("Sex", "SmokeCigs")
) %>% 
  print(nonnormal = c("Glucose0",
                      "Glucose120",
                      "ALT",
                      "UDBP",
                      "ACR")) %>% 
  knitr::kable()

Part 1 - Cross-Sectional

ACR

# Box plot of uVDBP in different albuminuria categories
ds %>% 
  filter(fVN == "Baseline") %>% 
  select(acrStatus, udbpCrRatio) %>%
  na.omit() %>%
  box_plot_poster("acrStatus", "log(udbpCr)", 
            "Albuminuria",
            "log uVDBP:Creatinine")

# ANOVA
anova <- aov(formula = log(udbpCrRatio)~acr_status, data = ds1)
summary(anova)
TukeyHSD(anova)
rm(anova)
# Scatterplot of ACR and uVDBP ----------------------------------

ds %>% 
  filter(fVN == "Baseline") %>% 
  scatter_plot_poster("log(ACR)", "log(udbpCr)",
               "log Albumin:Creatinine Ratio",
               "log UDBP:Creatinine")

# Spearman Correlation ------------------------------------------

ds %>% 
  filter(fVN == "Baseline") %>% 
  cor.test(formula = ~ ACR + udbpCr, data = ., method = "spearman")

eGFR

# Boxplot of uVDBP concentrations across eGFR categories --------------

ds %>% 
  filter(fVN == "Baseline") %>% 
  select(eGFRStatus, udbpCrRatio) %>% 
  na.omit() %>% 
  box_plot_poster("eGFRStatus", "log(udbpCrRatio)", 
            "Estimated GFR (ml/min/1.73m^2)",
            "log uVDBP:Creatinine")

# ANOVA

anova <- aov(formula = log(udbpCrRatio)~eGFR_status, data = ds1)
summary(anova)
TukeyHSD(anova)
rm(anova)
# Scatterplot of eGFR and uVDBP ----------------------------------

ds %>% 
  dplyr::filter(fVN == "Baseline") %>% 
  scatter_plot_poster("eGFR", "log(udbpCr)",
               "Estimated Glomerular Filtration Rate (ml/min/1.73m^2)",
               "log UDBP:Creatinine")

# Spearman Correlation ------------------------------------------

ds %>% 
  filter(!(acrStatus == "Macroalbuminuria")) %>% 
  cor.test(formula = ~ eGFR + udbpCr, data = ., method = "spearman")
ds %>% 
  dplyr::filter(eGFR < 45) %>% 
  dplyr::select(SID, VN, Age, eGFR, dm_status, acr_status)

ds %>% 
  scatter_plot("Age", "eGFR",
               "Age", "eGFR")

Part 2 - GEE

gee <- ds %>%
  dplyr::mutate(
    udbpBase = ifelse(fVN == "Baseline", UDBP, NA),
    ageBase = ifelse(fVN == "Baseline", Age, NA),
    DM = ifelse(DM == 1, "diabetes", "non_dia"),
    fDM = relevel(as.factor(DM), "non_dia"),
    Ethnicity = ifelse(Ethnicity == "European", Ethnicity, "Other"),
    Ethnicity = relevel(as.factor(Ethnicity), "Other")
  ) %>% 
  dplyr::filter(!(fVN == "Baseline" &
                    acrStatus == "Macroalbuminuria")) %>%
  dplyr::filter(!(fVN == "Baseline" & eGFRStatus == "Moderate")) %>%
  dplyr::arrange(SID, fVN) %>%
  dplyr::group_by(SID) %>%
  tidyr::fill(udbpBase, ageBase) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(UDBP = UDBP/1000) %>%
  dplyr::arrange(SID, VN) %>%
  mason::design("gee") %>% 
  mason::add_settings(
      family = stats::gaussian(),
      corstr = 'ar1',
      cluster.id = 'SID'
    ) %>%
  mason::add_variables("yvars", c("ACR", "eGFR")) %>% 
  mason::add_variables("xvars", "UDBP") %>% 
  mason::add_variables("covariates", c("VN", "ageBase", "Sex", "Ethnicity", "BMI", "fDM")) %>% 
  mason::construct() %>%
  mason::scrub() %>% 
  dplyr::select(Yterms, Xterms, term, estimate, conf.low, conf.high, p.value)
gee %>% 
  dplyr::mutate(Xterms = term) %>% 
  dplyr::filter(!term == "(Intercept)") %>% 
  dplyr::mutate(Yterms = factor(Yterms, 
                                levels = c("ACR", "eGFR"),
                                ordered = TRUE),
                Xterms = factor(Xterms,
                                levels = rev(c("<-Xterm",
                                           "VN",
                                           "ageBase",
                                           "SexMale",
                                           "EthnicityEuropean",
                                           "BMI",
                                           "fDMdiabetes")),
                                labels = rev(c("uVDBP (ug/mL)",
                                           "Follow-up Duration (Years)",
                                           "Baseline Age (Years)",
                                           "Sex (male)",
                                           "Ethnicity (European)",
                                           "BMI (kg/m^2)",
                                           "Diabetes")),
                                ordered = TRUE)) %>% 
  arrange(Xterms) %>% 
  gee_plot(xlab = "Unit difference with 95% CI in outcome for every unit increase in uVDBP and covariates")


windyzn/urinaryDBP documentation built on May 4, 2019, 6:32 a.m.