Last updated: 2020-06-08
Checks: 7 0
Knit directory: Fiber_Intervention_Study/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20191210)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 94015da. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: code/.Rhistory
Ignored: reference-papers/Dietary_Variables.xlsx
Ignored: reference-papers/Johnson_2019.pdf
Untracked files:
Untracked: fig/fig/
Untracked: fig/figure-2020-06-01/
Untracked: fig/figure2.pdf
Untracked: fig/figure3.pdf
Untracked: fig/figure5_glmm.pdf
Untracked: fig/figure6.pdf
Untracked: fig/figures-2020-06-08.zip
Untracked: fig/figures-2020-06-08/
Untracked: renv/
Untracked: tab/figure6_data_change_BMI.csv
Untracked: tab/sample_size_summary.xlsx
Untracked: tab/table_1_results.csv
Unstaged changes:
Modified: fig/figure4.pdf
Modified: fig/figure4_legend.pdf
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/summary_stats.Rmd
) and HTML (docs/summary_stats.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 94015da | noah-padgett | 2020-06-08 | revised figures |
html | 94015da | noah-padgett | 2020-06-08 | revised figures |
html | c1bce73 | noah-padgett | 2019-12-11 | Build site. |
Rmd | f275c59 | noah-padgett | 2019-12-10 | Initial commit - Noah |
html | f275c59 | noah-padgett | 2019-12-10 | Initial commit - Noah |
This page contains the summary statistics of participants’ data across the study.
# load packages
source("code/load_packages.R")
Loading required package: permute
Loading required package: lattice
This is vegan 2.5-6
Loading required package: Matrix
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
-- Attaching packages -------------------------------------- tidyverse 1.3.0 --
v ggplot2 3.3.0 v purrr 0.3.4
v tibble 3.0.1 v dplyr 0.8.5
v tidyr 1.1.0 v stringr 1.4.0
v readr 1.3.1 v forcats 0.5.0
-- Conflicts ----------------------------------------- tidyverse_conflicts() --
x tidyr::expand() masks Matrix::expand()
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
x tidyr::pack() masks Matrix::pack()
x tidyr::unpack() masks Matrix::unpack()
Attaching package: 'data.table'
The following objects are masked from 'package:dplyr':
between, first, last
The following object is masked from 'package:purrr':
transpose
------------------------------------------------------------------------------
You have loaded plyr after dplyr - this is likely to cause problems.
If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
library(plyr); library(dplyr)
------------------------------------------------------------------------------
Attaching package: 'plyr'
The following objects are masked from 'package:dplyr':
arrange, count, desc, failwith, id, mutate, rename, summarise,
summarize
The following object is masked from 'package:purrr':
compact
Attaching package: 'kableExtra'
The following object is masked from 'package:dplyr':
group_rows
Attaching package: 'gridExtra'
The following object is masked from 'package:dplyr':
combine
Loading required package: viridisLite
Loading required package: carData
Registered S3 methods overwritten by 'car':
method from
influence.merMod lme4
cooks.distance.influence.merMod lme4
dfbeta.influence.merMod lme4
dfbetas.influence.merMod lme4
Attaching package: 'car'
The following object is masked from 'package:dplyr':
recode
The following object is masked from 'package:purrr':
some
microbiome R package (microbiome.github.com)
Copyright (C) 2011-2019 Leo Lahti,
Sudarshan Shetty et al. <microbiome.github.io>
Attaching package: 'microbiome'
The following object is masked from 'package:ggplot2':
alpha
The following object is masked from 'package:vegan':
diversity
The following object is masked from 'package:base':
transform
********************************************************
Note: As of version 1.0.0, cowplot does not change the
default ggplot2 theme anymore. To recover the previous
behavior, execute:
theme_set(theme_cowplot())
********************************************************
Attaching package: 'cowplot'
The following object is masked from 'package:patchwork':
align_plots
# get data
source("code/get_cleaned_data.R")
Joining, by = c("SubjectID", "Age", "Ethnicity", "Gender", "Intervention")
Warning: Column `Ethnicity` joining factor and character vector, coercing into
character vector
Warning: Column `Gender` joining factor and character vector, coercing into
character vector
Warning: Column `Intervention` joining factor and character vector, coercing
into character vector
Joining, by = "SubjectID"
Joining, by = c("SubjectID", "Week")
mydata <- microbiome_data$meta.dat %>%
mutate(female = ifelse(Gender == "F", 1, 0),
c.age = Age - mean(Age),
IntB = ifelse(Intervention == "B", 1, 0),
Stress = Stress.Scale,
hispanic = ifelse(Ethnicity %in% c("White", "Asian", "Native America"), 1, 0),
BMI = Weight_pre/((Height_cm/100)**2))
sumTab <- mydata %>%
dplyr::group_by(Week) %>%
dplyr::summarise(N = n(),
Age_Mean = mean(Age),
Age_SD = sd(Age),
Weight_kg_M = mean(Weight_kg),
Weight_kg_SD = sd(Weight_kg),
Height_cm_M = mean(Height_cm),
Height_cm_SD = sd(Height_cm))
kable(sumTab, format="html", digits=1) %>%
kable_styling(full_width = T)
Week | N | Age_Mean | Age_SD | Weight_kg_M | Weight_kg_SD | Height_cm_M | Height_cm_SD |
---|---|---|---|---|---|---|---|
1 | 11 | 27.8 | 2.0 | 71.2 | 10.7 | 164.0 | 8.2 |
4 | 10 | 28.0 | 2.1 | 71.5 | 11.3 | 164.1 | 8.6 |
8 | 7 | 27.9 | 2.3 | 73.3 | 8.8 | 162.6 | 5.7 |
12 | 9 | 28.0 | 2.2 | 69.8 | 10.5 | 161.9 | 5.2 |
sumTab <- mydata %>%
dplyr::filter(Week==1) %>%
dplyr::group_by(Intervention) %>%
dplyr::summarise(N = n(),
PercentMale = (1 - mean(female))*100,
Age_Mean = mean(Age),
Age_SD = sd(Age),
Weight_kg_M = mean(Weight_kg),
Weight_kg_SD = sd(Weight_kg),
Height_cm_M = mean(Height_cm),
Height_cm_SD = sd(Height_cm),
BMI_M = mean(BMI),
BMI_SD = sd(BMI),
VFL_M = mean(Visceral_Fat_Level_pre),
VFL_SD = sd(Visceral_Fat_Level_pre),
PercBF_M = mean(Perc_Body_Fat_pre),
PercBF_SD = sd(Perc_Body_Fat_pre),
PercLF_M = mean(LBM_pre),
PercLF_SD = sd(LBM_pre),
HEI_Total_M = mean(HEI_Total, na.rm=T),
HEI_Total_SD = sd(HEI_Total, na.rm=T))
sumTab <- t(sumTab)
M <- sumTab[rownames(sumTab) %like% "_M",]
SD <- sumTab[rownames(sumTab) %like% "_SD",]
tab <- cbind(M, SD)
tab <- tab[, c(1,3,2,4)]
Ng <- c(sumTab[2,1], NA, sumTab[2,2], NA)
PercentMale <- c(sumTab[3,1], NA, sumTab[3,2], NA)
tab <- rbind(Ng, PercentMale, tab)
colnames(tab) <- c("GroupA_Mean","GroupA_SD", "GroupB_Mean", "GroupB_SD")
tab <- apply(tab, 1:2, as.numeric)
#tab
Next, we conducted Mann-Whitney-U test to compare distributions across intervention vs. placebo groups.
dat <- filter(mydata, Week == 1)
VAR <- c("Age", "Weight_kg", "Height_cm", "BMI", "Visceral_Fat_Level_pre", "Perc_Body_Fat_pre", "LBM_pre", "HEI_Total")
out <- numeric(length(VAR))
i <- 1
for(i in 1:length(VAR)){
fit <- wilcox.test(dat[,VAR[i]] ~ dat$IntB)
out[i] <- fit$p.value
}
Warning in wilcox.test.default(x = c(27, 28, 30, 26, 26, 27), y = c(32, : cannot
compute exact p-value with ties
Warning in wilcox.test.default(x = c(157.5, 184.2, 161.3, 163.8, 161.3, : cannot
compute exact p-value with ties
Warning in wilcox.test.default(x = c(17, 7, 6, 9, 9, 5), y = c(12, 13, 7, :
cannot compute exact p-value with ties
Warning in wilcox.test.default(x = c(44.3, 20.1, 24.6, 30.8, 33.4, 25.3), :
cannot compute exact p-value with ties
Warning in wilcox.test.default(x = c(22.2, 39.4, 26.1, 29.8, 22.2, 21.5), :
cannot compute exact p-value with ties
Warning in wilcox.test.default(x = c(88.8, 89.4, 89.13, 89.49, 90), y = c(90, :
cannot compute exact p-value with ties
out <- c(NA, NA, out)
out <- matrix(out, ncol=1)
colnames(out) <- "P_Value"
tab <- cbind(tab, out)
kable(tab, format="html", digits=3) %>%
kable_styling(full_width = T)
GroupA_Mean | GroupA_SD | GroupB_Mean | GroupB_SD | P_Value | |
---|---|---|---|---|---|
Ng | 6.000 | NA | 5.000 | NA | NA |
PercentMale | 33.333 | NA | 40.000 | NA | NA |
Age_Mean | 27.333 | 1.506 | 28.400 | 2.608 | 0.638 |
Weight_kg_M | 68.967 | 12.199 | 73.880 | 9.238 | 0.537 |
Height_cm_M | 164.267 | 10.067 | 163.584 | 6.309 | 0.927 |
BMI_M | 25.460 | 3.127 | 27.516 | 1.724 | 0.247 |
VFL_M | 8.833 | 4.309 | 10.200 | 2.950 | 0.405 |
PercBF_M | 29.750 | 8.551 | 32.340 | 4.999 | 0.464 |
PercLF_M | 26.867 | 6.908 | 27.860 | 3.996 | 0.407 |
HEI_Total_M | 89.364 | 0.446 | 89.817 | 0.365 | 0.201 |
tab <- as.data.frame(tab)
#write.csv(tab,paste0(w.d, "/tab/table_1_results.csv"))
asa24 <- microbiome_data$meta.dat
# If the recall number is missing, then they didn't response so we need to exclude them in the count.
asa24 %>%
dplyr::group_by(Week)%>%
filter(is.na(RecallNo)==F)%>%
dplyr::summarise(N=n())
# A tibble: 4 x 2
Week N
<fct> <int>
1 1 9
2 4 7
3 8 4
4 12 2
HEI scores were only gathered at onetime point. So, we need to subset to only 1 week then exclude the missing observations.
ffq <- microbiome_data$meta.dat
ffq %>%
dplyr::filter(Week == 1, is.na(HEI_Total)==F)%>%
dplyr::summarise(N = n())
N
1 9
Nvec <- matrix(ncol=1, nrow=5, dimnames = list(c("Total", "Week1", "Week4", "Week8", "Week12"), c("N")))
# total number of samples
Nvec[1,1] <- nsamples(phylo_data)
# week 1
subph <- subset_samples(phylo_data, Week == 1)
Nvec[2,1] <- nsamples(subph)
# week 4
subph <- subset_samples(phylo_data, Week == 4)
Nvec[3,1] <- nsamples(subph)
# week 8
subph <- subset_samples(phylo_data, Week == 8)
Nvec[4,1] <- nsamples(subph)
# week 12
subph <- subset_samples(phylo_data, Week == 12)
Nvec[5,1] <- nsamples(subph)
Nvec
N
Total 37
Week1 11
Week4 10
Week8 7
Week12 9
# Blood Samples
blood_data <- read_excel("data/Blood measures data/Copy of Fiber Study Blood Results.xlsx")
meta_data <- microbiome_data$meta.dat
keepVar <- c("SubjectID","Week", "Intervention", "Stress.Scale", "Ethnicity", "Gender", "Age")
meta_data <- meta_data [, keepVar] %>%
filter(Week == 1)
blood_data <- full_join(blood_data, meta_data)
Joining, by = "SubjectID"
blood_data <- distinct(blood_data, SubjectID, time,.keep_all = T)
blood_data %>%
dplyr::group_by(time) %>%
dplyr::summarise(N=n())
# A tibble: 2 x 2
time N
<chr> <int>
1 Post 11
2 Pre 11
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] cowplot_1.0.0 microbiome_1.8.0 car_3.0-8 carData_3.0-4
[5] gvlma_1.0.0.3 patchwork_1.0.0 viridis_0.5.1 viridisLite_0.3.0
[9] gridExtra_2.3 xtable_1.8-4 kableExtra_1.1.0 plyr_1.8.6
[13] data.table_1.12.8 readxl_1.3.1 forcats_0.5.0 stringr_1.4.0
[17] dplyr_0.8.5 purrr_0.3.4 readr_1.3.1 tidyr_1.1.0
[21] tibble_3.0.1 ggplot2_3.3.0 tidyverse_1.3.0 lmerTest_3.1-2
[25] lme4_1.1-23 Matrix_1.2-18 vegan_2.5-6 lattice_0.20-38
[29] permute_0.9-5 phyloseq_1.30.0
loaded via a namespace (and not attached):
[1] Rtsne_0.15 minqa_1.2.4 colorspace_1.4-1
[4] rio_0.5.16 ellipsis_0.3.1 rprojroot_1.3-2
[7] XVector_0.26.0 fs_1.4.1 rstudioapi_0.11
[10] fansi_0.4.1 lubridate_1.7.8 xml2_1.3.2
[13] codetools_0.2-16 splines_3.6.3 knitr_1.28
[16] ade4_1.7-15 jsonlite_1.6.1 workflowr_1.6.2
[19] nloptr_1.2.2.1 broom_0.5.6 cluster_2.1.0
[22] dbplyr_1.4.4 BiocManager_1.30.10 compiler_3.6.3
[25] httr_1.4.1 backports_1.1.7 assertthat_0.2.1
[28] cli_2.0.2 later_1.0.0 htmltools_0.4.0
[31] tools_3.6.3 igraph_1.2.5 gtable_0.3.0
[34] glue_1.4.1 reshape2_1.4.4 Rcpp_1.0.4.6
[37] Biobase_2.46.0 cellranger_1.1.0 vctrs_0.3.0
[40] Biostrings_2.54.0 multtest_2.42.0 ape_5.3
[43] nlme_3.1-144 iterators_1.0.12 xfun_0.14
[46] openxlsx_4.1.5 rvest_0.3.5 lifecycle_0.2.0
[49] statmod_1.4.34 zlibbioc_1.32.0 MASS_7.3-51.5
[52] scales_1.1.1 hms_0.5.3 promises_1.1.0
[55] parallel_3.6.3 biomformat_1.14.0 rhdf5_2.30.1
[58] curl_4.3 yaml_2.2.1 stringi_1.4.6
[61] highr_0.8 S4Vectors_0.24.4 foreach_1.5.0
[64] BiocGenerics_0.32.0 zip_2.0.4 boot_1.3-24
[67] rlang_0.4.6 pkgconfig_2.0.3 evaluate_0.14
[70] Rhdf5lib_1.8.0 tidyselect_1.1.0 magrittr_1.5
[73] R6_2.4.1 IRanges_2.20.2 generics_0.0.2
[76] DBI_1.1.0 foreign_0.8-75 pillar_1.4.4
[79] haven_2.3.0 whisker_0.4 withr_2.2.0
[82] mgcv_1.8-31 abind_1.4-5 survival_3.1-8
[85] modelr_0.1.8 crayon_1.3.4 utf8_1.1.4
[88] rmarkdown_2.1 grid_3.6.3 blob_1.2.1
[91] git2r_0.27.1 reprex_0.3.0 digest_0.6.25
[94] webshot_0.5.2 httpuv_1.5.2 numDeriv_2016.8-1.1
[97] stats4_3.6.3 munsell_0.5.0