knitr::opts_chunk$set(collapse = TRUE, echo = FALSE, message = FALSE, warning = FALSE) library(dplyr) devtools::load_all() load_data(update = TRUE) set_options() extrafont::loadfonts(device="win")
ds <- project_data # # dsBase <- ds %>% # dplyr::filter(fVN == "Baseline") # dsComplete <- ds %>% dplyr::group_by(SID) %>% dplyr::filter(n() == 3) %>% dplyr::ungroup()
Subject characteristics across visit numbers
dsTableOne <- ds %>% dplyr::filter(Sex == "Female") subCharTable <- tableone::CreateTableOne( vars = c("Age", "Sex", "eGFR", "ACR", "UDBP", "VitaminD", "dmStatus", "BirthControl", "PeriodsStopped"), strata = c("fVN"), data = dsTableOne, factorVars = c("SmokeCigs", "BirthControl", "PeriodsStopped") ) %>% print(nonnormal = c("UDBP", "ACR")) %>% knitr::kable()
# Box plot of uVDBP in different albuminuria categories ds %>% filter(fVN == "Baseline") %>% select(acrStatus, udbpCrRatio) %>% na.omit() %>% box_plot_slides("acrStatus", "log(udbpCrRatio)", "Albuminuria", "log uVDBP:Creatinine (ug/mmol)") # 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") %>% select(ACR, udbpCrRatio) %>% na.omit() %>% scatter_plot("log(ACR)", "log(udbpCrRatio)", "log Albumin:Creatinine (mg/mmol)", "log uVDBP:Creatinine (ug/mmol)", line = TRUE) # Spearman Correlation ------------------------------------------ ds %>% filter(fVN == "Baseline") %>% cor.test(formula = ~ ACR + udbpCrRatio, data = ., method = "spearman")
# Boxplot of uVDBP concentrations across eGFR categories -------------- ds %>% filter(fVN == "Baseline") %>% select(eGFRStatus, udbpCrRatio) %>% na.omit() %>% box_plot_slides("eGFRStatus", "log(udbpCrRatio)", "Estimated GFR (ml/min/1.73m^2)", "log uVDBP:Creatinine (ug/mmol)") # ANOVA anova <- aov(formula = log(udbpCrRatio)~eGFR_status, data = ds1) summary(anova) TukeyHSD(anova) rm(anova)
# Scatterplot of eGFR and uVDBP ---------------------------------- ds %>% # dplyr::filter(eGFR < 150) %>% dplyr::filter(fVN == "Baseline") %>% dplyr::select(eGFR, udbpCrRatio) %>% na.omit() %>% scatter_plot("eGFR", "log(udbpCrRatio)", "Estimated Glomerular Filtration Rate (ml/min/1.73m^2)", "log uVDBP:Creatinine (ug/mmol)") # Spearman Correlation ------------------------------------------ ds %>% # filter(!(acrStatus == "Macroalbuminuria")) %>% dplyr::filter(fVN == "Baseline") %>% cor.test(formula = ~ eGFR + log(udbpCrRatio), data = ., method = "spearman")
# Multiple Regression ------------------------------------------- ds %>% dplyr::filter(fVN == "Baseline") %>% # dplyr::mutate(UDBP = UDBP/1000) %>% dplyr::arrange(SID, VN) %>% mason::design("glm") %>% mason::add_settings(family = stats::gaussian()) %>% mason::add_variables("yvars", "UDBP") %>% mason::add_variables("xvars", c("ACR", "eGFR")) %>% mason::construct() %>% # mason::add_variables("covariates", c("DM", "MedsBloodPressure")) %>% # mason::construct() %>% mason::add_variables("yvars", "VitaminD") %>% mason::add_variables("xvars", "UDBP") %>% mason::construct() %>% mason::scrub()
ds %>% dplyr::filter(fVN == "Baseline") %>% scatter_plot("log(CRP)", "VitaminD", "CRP", "25(OH)D") ds %>% dplyr::filter(fVN == "Baseline") %>% # dplyr::mutate(UDBP = UDBP/1000) %>% dplyr::arrange(SID, VN) %>% mason::design("glm") %>% mason::add_settings(family = stats::gaussian()) %>% mason::add_variables("yvars", "VitaminD") %>% mason::add_variables("xvars", "CRP") %>% mason::construct() %>% mason::scrub()
ds %>% dplyr::filter(eGFR < 45) %>% dplyr::select(SID, VN, Age, eGFR, dmStatus, acrStatus) ds %>% scatter_plot("Age", "eGFR", "Age", "eGFR") ds %>% dplyr::select(dmStatus, eGFR, fVN) %>% na.omit() %>% box_plot("dmStatus", "eGFR", "Diabetic Status", "eGFR", facet = TRUE)
ds %>% line_plot("")
dsGEE <- ds %>% dplyr::mutate(udbpBase = ifelse(fVN == "Baseline", UDBP, NA), ageBase = ifelse(fVN == "Baseline", Age, NA), bmiBase = ifelse(fVN == "Baseline", BMI, NA), waistBase = ifelse(fVN == "Baseline", Waist, NA), Sex = ifelse(Sex == "Male", 1, 0), Ethnicity = ifelse(Ethnicity == "European", Ethnicity, "Other"), Ethnicity = ifelse(Ethnicity == "European", 0, 1), fMedsBP = ifelse(fMedsBP == "Yes", 1, 0) # vitdBase = ifelse(fVN == "6Year", NA, VitaminD) ) %>% dplyr::arrange(SID, fVN) %>% dplyr::group_by(SID) %>% tidyr::fill(udbpBase, ageBase, bmiBase, waistBase) %>% dplyr::ungroup() %>% dplyr::arrange(SID, VN) %>% dplyr::select(udbpBase, ACR, eGFR, VN, ageBase, Sex, Ethnicity, BMI, Waist, DM, fMedsBP) round(cor(dsGEE[sapply(dsGEE, is.numeric)], use = "complete.obs"), 2) # Heatmap corrplot::corrplot(cor(dsGEE[sapply(dsGEE, is.numeric)], use = "complete.obs"), method = "color")
gee <- ds %>% dplyr::mutate( udbpBase = ifelse(fVN == "Baseline", UDBP, NA), ageBase = ifelse(fVN == "Baseline", Age, NA), fDM = relevel(as.factor(DM), "0") # Ethnicity = ifelse(Ethnicity == "European", 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", "fDM")) %>% mason::construct() %>% mason::scrub()
gee3 <- readRDS(file = "../data/ds.Rds") %>% dplyr::mutate( udbpBase = ifelse(fVN == "Baseline", UDBP, NA), ageBase = ifelse(fVN == "Baseline", Age, NA), VitaminD3 = ifelse(fVN == "6Year", NA, VitaminD) # Ethnicity = ifelse(Ethnicity == "European", Ethnicity, "Other"), ) %>% dplyr::arrange(SID, fVN) %>% dplyr::group_by(SID) %>% tidyr::fill(udbpBase, ageBase) %>% dplyr::ungroup() %>% # dplyr::group_by(VN) %>% # dplyr::mutate(udbpBase = as.numeric(scale(udbpBase))) %>% dplyr::mutate(UDBP = UDBP/1000) %>% # dplyr::ungroup() %>% dplyr::arrange(SID, VN) %>% mason_gee( yvars = c("VitaminD3"), xvars = "UDBP", covars = c("VN", "ageBase", "DM") )
Graph
gee %>% dplyr::mutate(p.value = ifelse(p.value > 0.05, 1, 0.04)) %>% seer::view_main_effect( graph.options = 'dot.size', groups = '~Yterms', legend.title = 'p-values', xlab = 'Percent difference with 95% CI in the outcomes\nfor each unit increase in baseline uVDBP', ylab = 'Kidney Measures' ) + graph_theme(ticks = FALSE, legend.pos = 'right') + ggplot2::theme(legend.margin = grid::unit(0, 'cm'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.