Last updated: 2020-06-17

Checks: 6 1

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.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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 a16e6ef. 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
    Ignored:    renv/library/
    Ignored:    renv/staging/

Untracked files:
    Untracked:  analysis/glme_microbiome_genus_subset.Rmd
    Untracked:  analysis/glme_microbiome_phylum.Rmd
    Untracked:  analysis/microbiome_genus_prevotella_bacteroides.Rmd
    Untracked:  analysis/microbiome_genus_relative_abundance.Rmd
    Untracked:  data/analysis-data/DataDictionary_TOTALS_2018Record.xls
    Untracked:  fig/figure1.pdf
    Untracked:  fig/figure5_glmm_genus.pdf
    Untracked:  fig/figure5_glmm_phylum.pdf
    Untracked:  fig/misc/
    Untracked:  tab/results_glmm_microbiome_genus.csv
    Untracked:  tab/results_glmm_microbiome_phylum.csv
    Untracked:  tab/tables_results_2020-06-08.zip
    Untracked:  tab/tables_results_2020-06-08/

Unstaged changes:
    Modified:   analysis/alpha_diversity.Rmd
    Modified:   analysis/data_processing.Rmd
    Deleted:    analysis/glme_microbiome.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/microbiome_diet_trends.Rmd
    Modified:   code/get_cleaned_data.R
    Modified:   code/microbiome_statistics_and_functions.R
    Deleted:    fig/figure2.pdf
    Modified:   fig/figure2_individual_beta_diversity_over_study.pdf
    Deleted:    fig/figure3.pdf
    Modified:   fig/figure3_PCoA_analysis_results_beta_diversity_between_groups.pdf
    Deleted:    fig/figure4.pdf
    Modified:   fig/figure4_final_microbiome_diet_variables_over_time.pdf
    Modified:   fig/figure4_legend.pdf
    Deleted:    fig/figure5_glmm.pdf
    Deleted:    fig/figures-2020-06-08.zip
    Deleted:    fig/glmm_res.pdf
    Deleted:    fig/glmm_res.png
    Deleted:    fig/microbiome_abundance_glmm_results.pdf
    Deleted:    fig/predicted_Actinobacteria.png
    Deleted:    fig/predicted_Actinobacteria_model0.png
    Deleted:    fig/predicted_Actinobacteria_model1.png
    Deleted:    fig/predicted_Actinobacteria_model2.png
    Deleted:    fig/predicted_Actinobacteria_model3.png
    Deleted:    fig/predicted_Actinobacteria_model4.png
    Deleted:    fig/predicted_Actinobacteria_model5.png
    Deleted:    fig/predicted_Actinobacteria_model6.png
    Deleted:    fig/predicted_Actinobacteria_model7.png
    Deleted:    fig/predicted_Bacteroidetes.png
    Deleted:    fig/predicted_Bacteroidetes_model0.png
    Deleted:    fig/predicted_Bacteroidetes_model1.png
    Deleted:    fig/predicted_Bacteroidetes_model2.png
    Deleted:    fig/predicted_Bacteroidetes_model3.png
    Deleted:    fig/predicted_Bacteroidetes_model4.png
    Deleted:    fig/predicted_Bacteroidetes_model5.png
    Deleted:    fig/predicted_Bacteroidetes_model6.png
    Deleted:    fig/predicted_Bacteroidetes_model7.png
    Deleted:    fig/predicted_Cyanobacteria.png
    Deleted:    fig/predicted_Cyanobacteria_model0.png
    Deleted:    fig/predicted_Cyanobacteria_model1.png
    Deleted:    fig/predicted_Cyanobacteria_model2.png
    Deleted:    fig/predicted_Cyanobacteria_model3.png
    Deleted:    fig/predicted_Cyanobacteria_model4.png
    Deleted:    fig/predicted_Cyanobacteria_model5.png
    Deleted:    fig/predicted_Cyanobacteria_model6.png
    Deleted:    fig/predicted_Cyanobacteria_model7.png
    Deleted:    fig/predicted_Euryarchaeota.png
    Deleted:    fig/predicted_Euryarchaeota_model0.png
    Deleted:    fig/predicted_Euryarchaeota_model1.png
    Deleted:    fig/predicted_Euryarchaeota_model2.png
    Deleted:    fig/predicted_Euryarchaeota_model3.png
    Deleted:    fig/predicted_Euryarchaeota_model4.png
    Deleted:    fig/predicted_Euryarchaeota_model5.png
    Deleted:    fig/predicted_Euryarchaeota_model6.png
    Deleted:    fig/predicted_Euryarchaeota_model7.png
    Deleted:    fig/predicted_Firmicutes.png
    Deleted:    fig/predicted_Firmicutes_model0.png
    Deleted:    fig/predicted_Firmicutes_model1.png
    Deleted:    fig/predicted_Firmicutes_model2.png
    Deleted:    fig/predicted_Firmicutes_model3.png
    Deleted:    fig/predicted_Firmicutes_model4.png
    Deleted:    fig/predicted_Firmicutes_model5.png
    Deleted:    fig/predicted_Firmicutes_model6.png
    Deleted:    fig/predicted_Firmicutes_model7.png
    Deleted:    fig/predicted_Fusobacteria.png
    Deleted:    fig/predicted_Fusobacteria_model0.png
    Deleted:    fig/predicted_Fusobacteria_model1.png
    Deleted:    fig/predicted_Fusobacteria_model2.png
    Deleted:    fig/predicted_Fusobacteria_model3.png
    Deleted:    fig/predicted_Fusobacteria_model4.png
    Deleted:    fig/predicted_Fusobacteria_model5.png
    Deleted:    fig/predicted_Fusobacteria_model6.png
    Deleted:    fig/predicted_Fusobacteria_model7.png
    Deleted:    fig/predicted_Lentisphaerae.png
    Deleted:    fig/predicted_Lentisphaerae_model0.png
    Deleted:    fig/predicted_Lentisphaerae_model1.png
    Deleted:    fig/predicted_Lentisphaerae_model2.png
    Deleted:    fig/predicted_Lentisphaerae_model3.png
    Deleted:    fig/predicted_Lentisphaerae_model4.png
    Deleted:    fig/predicted_Lentisphaerae_model5.png
    Deleted:    fig/predicted_Lentisphaerae_model6.png
    Deleted:    fig/predicted_Lentisphaerae_model7.png
    Deleted:    fig/predicted_Proteobacteria.png
    Deleted:    fig/predicted_Proteobacteria_model0.png
    Deleted:    fig/predicted_Proteobacteria_model1.png
    Deleted:    fig/predicted_Proteobacteria_model2.png
    Deleted:    fig/predicted_Proteobacteria_model3.png
    Deleted:    fig/predicted_Proteobacteria_model4.png
    Deleted:    fig/predicted_Proteobacteria_model5.png
    Deleted:    fig/predicted_Proteobacteria_model6.png
    Deleted:    fig/predicted_Proteobacteria_model7.png
    Deleted:    fig/predicted_Tenericutes.png
    Deleted:    fig/predicted_Tenericutes_model0.png
    Deleted:    fig/predicted_Tenericutes_model1.png
    Deleted:    fig/predicted_Tenericutes_model2.png
    Deleted:    fig/predicted_Tenericutes_model3.png
    Deleted:    fig/predicted_Tenericutes_model4.png
    Deleted:    fig/predicted_Tenericutes_model5.png
    Deleted:    fig/predicted_Tenericutes_model6.png
    Deleted:    fig/predicted_Tenericutes_model7.png
    Deleted:    fig/predicted_Verrucomicrobia.png
    Deleted:    fig/predicted_Verrucomicrobia_model0.png
    Deleted:    fig/predicted_Verrucomicrobia_model1.png
    Deleted:    fig/predicted_Verrucomicrobia_model2.png
    Deleted:    fig/predicted_Verrucomicrobia_model3.png
    Deleted:    fig/predicted_Verrucomicrobia_model4.png
    Deleted:    fig/predicted_Verrucomicrobia_model5.png
    Deleted:    fig/predicted_Verrucomicrobia_model6.png
    Deleted:    fig/predicted_Verrucomicrobia_model7.png

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.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


Calculate Prevotella/Bacteroides ratio for all samples Calculate the change in P/B ratio for all samples (line plot before v after by group) Determine if there is a significant change over time in the P/B ratio and if the intervention had an effect

Ratio of Prevotella to Bacteroides

# genera to keep:
keepGenus <- c("__Bacteroides", "__Prevotella", "__Prevotella_2", "__Prevotella_6")

mphyseq = psmelt(phylo_data)
mphyseq2 <- mphyseq %>%
  filter(Genus %in% keepGenus) %>%
  mutate(Genus = substring(Genus, 3))

# subset to smaller dataset for easier use
varKeep <- c("Genus", "Abundance", "SubjectID", "Week", "Ethnicity", "Age", "Gender","Intervention")

mphyseq2 <- mphyseq2[, varKeep]

# make wide format wrt genus abundance
mphyseq2 <- mphyseq2 %>%
  pivot_wider(names_from = "Genus",
              values_from = "Abundance")

# compute ratio
mphyseq2 <- mphyseq2 %>%
  mutate(Prev_Bact_ratio = Prevotella/Bacteroides,
         Prev2_Bact_ratio = Prevotella_2/Bacteroides,
         Prev6_Bact_ratio = Prevotella_6/Bacteroides)


mphyseq2 %>%
  dplyr::group_by(Week)%>%
  dplyr::summarise(Prev_Bact_ratio = mean(Prev_Bact_ratio),
                   Prev2_Bact_ratio = mean(Prev2_Bact_ratio),
                   Prev6_Bact_ratio = mean(Prev6_Bact_ratio))
# A tibble: 4 x 4
  Week  Prev_Bact_ratio Prev2_Bact_ratio Prev6_Bact_ratio
  <fct>           <dbl>            <dbl>            <dbl>
1 1            0.00148            0.0830        0.000494 
2 4            0.000441           0.0379        0.0000358
3 8            0.00191            0.0459        0.00171  
4 12           0.00231            0.0687        0.00222  
mphyseq2 %>%
  dplyr::group_by(Week, Intervention)%>%
  dplyr::summarise(Prev_Bact_ratio = mean(Prev_Bact_ratio),
                   Prev2_Bact_ratio = mean(Prev2_Bact_ratio),
                   Prev6_Bact_ratio = mean(Prev6_Bact_ratio))
# A tibble: 8 x 5
# Groups:   Week [4]
  Week  Intervention Prev_Bact_ratio Prev2_Bact_ratio Prev6_Bact_ratio
  <fct> <chr>                  <dbl>            <dbl>            <dbl>
1 1     A                   0                  0.152         0        
2 1     B                   0.00326            0             0.00109  
3 4     A                   0.000437           0.0632        0        
4 4     B                   0.000447           0             0.0000895
5 8     A                   0                  0.107         0        
6 8     B                   0.00333            0             0.00299  
7 12    A                   0                  0.124         0        
8 12    B                   0.00521            0             0.00500  
keepVar <- c("SubjectID", "Week", "Intervention", "Prevotella", "Prevotella_2", "Prevotella_6", "Bacteroides", "Prev_Bact_ratio", "Prev2_Bact_ratio", "Prev6_Bact_ratio")
kable(mphyseq2[,keepVar], format="html", digits=3,
      caption="Raw data of Prevotella* and Bacteroides") %>%
  kable_styling(full_width = T) %>%
  scroll_box(width="100%", height="5in")
Raw data of Prevotella* and Bacteroides
SubjectID Week Intervention Prevotella Prevotella_2 Prevotella_6 Bacteroides Prev_Bact_ratio Prev2_Bact_ratio Prev6_Bact_ratio
1013 1 A 0 0 0 5016 0.000 0.000 0.000
1002 8 B 0 0 0 4701 0.000 0.000 0.000
1015 8 B 0 0 0 3910 0.000 0.000 0.000
1013 4 A 0 0 0 3793 0.000 0.000 0.000
1002 12 B 0 0 0 3667 0.000 0.000 0.000
1001 4 A 3 0 0 3469 0.001 0.000 0.000
1009 12 A 0 0 0 2954 0.000 0.000 0.000
1015 12 B 1 0 4 2927 0.000 0.000 0.001
1009 1 A 0 0 0 2923 0.000 0.000 0.000
1009 8 A 0 0 0 2918 0.000 0.000 0.000
1015 1 B 0 0 0 2853 0.000 0.000 0.000
1013 12 A 0 0 0 2849 0.000 0.000 0.000
1015 4 B 5 0 1 2794 0.002 0.000 0.000
1008 4 A 0 0 0 2686 0.000 0.000 0.000
1007 1 B 0 0 0 2662 0.000 0.000 0.000
1005 4 A 0 954 0 2614 0.000 0.365 0.000
1005 1 A 0 2271 0 2486 0.000 0.914 0.000
1002 4 B 0 0 0 2470 0.000 0.000 0.000
1002 1 B 0 0 0 2464 0.000 0.000 0.000
1009 4 A 0 0 0 2458 0.000 0.000 0.000
1008 12 A 0 0 0 2453 0.000 0.000 0.000
1008 1 A 0 0 0 2330 0.000 0.000 0.000
1007 4 B 0 0 0 2314 0.000 0.000 0.000
1007 12 B 0 0 0 2310 0.000 0.000 0.000
1001 1 A 0 0 0 2249 0.000 0.000 0.000
1007 8 B 1 0 2 2243 0.000 0.000 0.001
1005 12 A 0 1237 0 2046 0.000 0.605 0.000
1008 8 A 0 0 0 1723 0.000 0.000 0.000
1003 8 A 0 509 0 1585 0.000 0.321 0.000
1012 1 B 0 0 0 1351 0.000 0.000 0.000
1003 1 A 0 0 0 1174 0.000 0.000 0.000
1003 4 A 2 16 0 1138 0.002 0.014 0.000
1003 12 A 0 12 0 859 0.000 0.014 0.000
1010 1 B 9 0 3 552 0.016 0.000 0.005
1010 8 B 7 0 6 543 0.013 0.000 0.011
1010 12 B 11 0 10 537 0.020 0.000 0.019
1010 4 B 0 0 0 381 0.000 0.000 0.000

Line Plot of Ratio

# recode
plot_data <- mphyseq2

so <- distinct(mphyseq2, SubjectID, .keep_all = T)

subjectorder <- so$SubjectID[order(so$Intervention, decreasing = F)]

plot_data$SubjectID10 <- factor(plot_data$SubjectID,
                             levels = subjectorder,
                             labels=c(1:11))

ids <- 1:6
plot_data$Intervention2 <- ifelse(plot_data$SubjectID10 %in% ids, "Group A", "Group B")



# plot
p <- ggplot(plot_data, aes(x=Week, y=Prev_Bact_ratio, group=SubjectID10, color=Intervention))+
  geom_line()+
  geom_point()+
  facet_wrap(.~SubjectID10, ncol=6)+
  labs(x="Week", y= "Ratio",
       title="Prevotella / Bacteroides Ratio across subjects")+
  guides(colour= guide_legend(title = "Intervention"))+
  scale_colour_manual(values = cols)+
  theme(panel.grid = element_blank(),
        axis.text.y = element_text(size = 10),
        axis.title = element_text(size = 10),
        legend.position = c(0.95, 0.1))
p
geom_path: Each group consists of only one observation. Do you need to adjust
the group aesthetic?

# plot
p <- ggplot(plot_data, aes(x=Week, y=Prev2_Bact_ratio, group=SubjectID10, color=Intervention))+
  geom_line()+
  geom_point()+
  facet_wrap(.~SubjectID10, ncol=6)+
  labs(x="Week", y= "Ratio",
       title="Prevotella_2 / Bacteroides Ratio across subjects")+
  guides(colour= guide_legend(title = "Intervention"))+
  scale_colour_manual(values = cols)+
  theme(panel.grid = element_blank(),
        axis.text.y = element_text(size = 10),
        axis.title = element_text(size = 10),
        legend.position = c(0.95, 0.1))
p
geom_path: Each group consists of only one observation. Do you need to adjust
the group aesthetic?

p <- ggplot(plot_data, aes(x=Week, y=Prev6_Bact_ratio, group=SubjectID10, color=Intervention))+
  geom_line()+
  geom_point()+
  facet_wrap(.~SubjectID10, ncol=6)+
  labs(x="Week", y= "Ratio",
       title="Prevotella_6 / Bacteroides Ratio across subjects")+
  guides(colour= guide_legend(title = "Intervention"))+
  scale_colour_manual(values = cols)+
  theme(panel.grid = element_blank(),
        axis.text.y = element_text(size = 10),
        axis.title = element_text(size = 10),
        legend.position = c(0.95, 0.1))
p
geom_path: Each group consists of only one observation. Do you need to adjust
the group aesthetic?


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] farver_2.0.3        fansi_0.4.1         lubridate_1.7.8    
[13] xml2_1.3.2          codetools_0.2-16    splines_3.6.3      
[16] knitr_1.28          ade4_1.7-15         jsonlite_1.6.1     
[19] workflowr_1.6.2     nloptr_1.2.2.1      broom_0.5.6        
[22] cluster_2.1.0       dbplyr_1.4.4        BiocManager_1.30.10
[25] compiler_3.6.3      httr_1.4.1          backports_1.1.7    
[28] assertthat_0.2.1    cli_2.0.2           later_1.0.0        
[31] htmltools_0.4.0     tools_3.6.3         igraph_1.2.5       
[34] gtable_0.3.0        glue_1.4.1          reshape2_1.4.4     
[37] Rcpp_1.0.4.6        Biobase_2.46.0      cellranger_1.1.0   
[40] vctrs_0.3.0         Biostrings_2.54.0   multtest_2.42.0    
[43] ape_5.3             nlme_3.1-144        iterators_1.0.12   
[46] xfun_0.14           openxlsx_4.1.5      rvest_0.3.5        
[49] lifecycle_0.2.0     statmod_1.4.34      zlibbioc_1.32.0    
[52] MASS_7.3-51.5       scales_1.1.1        hms_0.5.3          
[55] promises_1.1.0      parallel_3.6.3      biomformat_1.14.0  
[58] rhdf5_2.30.1        curl_4.3            yaml_2.2.1         
[61] stringi_1.4.6       highr_0.8           S4Vectors_0.24.4   
[64] foreach_1.5.0       BiocGenerics_0.32.0 zip_2.0.4          
[67] boot_1.3-24         rlang_0.4.6         pkgconfig_2.0.3    
[70] evaluate_0.14       Rhdf5lib_1.8.0      labeling_0.3       
[73] tidyselect_1.1.0    magrittr_1.5        R6_2.4.1           
[76] IRanges_2.20.2      generics_0.0.2      DBI_1.1.0          
[79] foreign_0.8-75      pillar_1.4.4        haven_2.3.0        
[82] withr_2.2.0         mgcv_1.8-31         abind_1.4-5        
[85] survival_3.1-8      modelr_0.1.8        crayon_1.3.4       
[88] utf8_1.1.4          rmarkdown_2.1       grid_3.6.3         
[91] blob_1.2.1          git2r_0.27.1        reprex_0.3.0       
[94] digest_0.6.25       webshot_0.5.2       httpuv_1.5.2       
[97] numDeriv_2016.8-1.1 stats4_3.6.3        munsell_0.5.0