Last updated: 2021-04-30

Checks: 7 0

Knit directory: CassavaNIRS/

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(20210419) 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 88fee14. 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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    Hershberger_CassavaNIRS_2021.zip
    Ignored:    analysis/.DS_Store
    Ignored:    code/.DS_Store
    Ignored:    data/.DS_Store
    Ignored:    data/Cassavabase_phenotypes_20210419.csv
    Ignored:    data/Corrected_metadata/
    Ignored:    data/README.html
    Ignored:    data/README.txt
    Ignored:    data/Spectra/
    Ignored:    data/TrialNameKey.csv
    Ignored:    data/raw_pheno.csv
    Ignored:    data/raw_scans.csv
    Ignored:    output/.DS_Store
    Ignored:    output/Figure2_DMC_distributions.png
    Ignored:    output/Figure4_within_predictions.png
    Ignored:    output/Figure5_Subsamples.png
    Ignored:    output/Figure6_RF_Importance.png
    Ignored:    output/Figure7_CV_predictions.png
    Ignored:    output/FigureS2_within_trial_prediction_all.png
    Ignored:    output/S1_overlapping_accession_counts.csv
    Ignored:    output/S3_removed_scans.csv
    Ignored:    output/Table2_DMC_statistics.csv
    Ignored:    output/Table3_performance_summary.csv
    Ignored:    output/TableS2_within_trial_predictions.csv
    Ignored:    output/TableS4_cv_results.csv
    Ignored:    output/cv_base.png
    Ignored:    output/cv_results.csv
    Ignored:    output/full_filtered_plots.csv
    Ignored:    output/full_filtered_subsamples.csv
    Ignored:    output/full_filtered_unaggregated.csv
    Ignored:    output/subsampling_prediction_results_2021.csv
    Ignored:    output/within_trial_waves_PLSR.csv
    Ignored:    output/within_trial_waves_RF.csv
    Ignored:    output/within_trial_waves_RF_importance.csv
    Ignored:    output/within_trial_waves_SVM.csv

Unstaged changes:
    Modified:   analysis/index.Rmd

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/manuscript_subsampling.Rmd) and HTML (docs/manuscript_subsampling.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 88fee14 Jenna Hershberger 2021-04-30 Build workflowr site
html 88fee14 Jenna Hershberger 2021-04-30 Build workflowr site
Rmd 8f143af Jenna Hershberger 2021-04-21 Add content

Introduction

Prior to this script, run server_subsampling_generalized.R and server_subsample_plsr.R. Then convert the output Rds to a df.

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.3     ✓ purrr   0.3.4
✓ tibble  3.1.1     ✓ dplyr   1.0.5
✓ tidyr   1.1.2     ✓ stringr 1.4.0
✓ readr   1.4.0     ✓ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
library(ggpubr)
library(magrittr)

Attaching package: 'magrittr'
The following object is masked from 'package:purrr':

    set_names
The following object is masked from 'package:tidyr':

    extract
iwanthue <- c("#c84d4c","#c77c3f","#d19f32","#647e3a","#61b858","#4db5a4",
              "#6585cc","#975fc7","#c575a1","#cf4391")
namekey <- read.csv("data/TrialNameKey.csv") %>% 
  rename(Trial = Abbreviated.Trial.Name) 
subsamp_input <- read.csv("output/subsampling_prediction_results_2021.csv") %>%
  full_join(namekey) %>% 
    mutate(`Subsample type` = case_when(
        str_detect(studyName, "19.") ~ "Homogenized sample",
        !str_detect(studyName, "19.") & str_detect(studyName, "UYT") ~ "Homogenized sample",
        !str_detect(studyName, "19.") & !str_detect(studyName, "UYT") ~ "Roots"),
      num_samp_fct = as.factor(number_samples)) 
Joining, by = "studyName"
subsamp_input %>% 
  group_by(studyName) %>% 
  summarize(max(number_samples))
# A tibble: 10 x 2
   studyName                       `max(number_samples)`
   <fct>                                           <int>
 1 17.CASS.PYT.49.setA.IB                              6
 2 17.GS.C3.PYT.80.IB                                  6
 3 18.CASS.PYT.52.IB                                   6
 4 18.GS.C2.setA.UYT.36.IB                             2
 5 18.GS.C2.setB.UYT.36.IB                             2
 6 19.CASS.PYT.52.IK                                   6
 7 19.CMSSurveyVarieties.AYT.33.IB                     6
 8 19.GS.C2.UYT.36.setA.IB                            10
 9 19.GS.C2.UYT.36.setB.IB                            10
10 19.GS.C4B.PYT.500.IK                                6
subsample.df <- subsamp_input %>%
  filter(`Subsample type` == "Homogenized sample") %>%
  drop_na() %>%
  mutate(num_samp_fct = fct_reorder(num_samp_fct, number_samples)) 

subsample_plot <- subsample.df %>%
  ggplot(aes(x = num_samp_fct, y = R2p, fill = Trial)) +
  geom_boxplot() + facet_grid(cols = vars(Trial)) + theme_bw() +
  scale_fill_manual(values = iwanthue[c(4:10)], name = "Trial") +
  coord_cartesian(ylim = c(0, 1)) + 
  labs(fill = "Trial", x = "Number of samples", y = expression("R"["p"]^2)) + 
  theme(legend.position = "none") 
subsample_plot

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
root_plot <- subsamp_input %>%
  filter(`Subsample type` == "Roots") %>%
  drop_na() %>%
  mutate(num_samp_fct = fct_reorder(num_samp_fct, number_samples)) %>%
  ggplot(aes(x = num_samp_fct, y = R2p, fill = Trial)) +
  geom_boxplot() + facet_grid(cols = vars(Trial)) + theme_bw() +
  scale_fill_manual(values = iwanthue[c(1:3)], name = "Trial") +
  coord_cartesian(ylim = c(0, 1)) + 
  labs(fill = "Trial", x = "Number of roots", y = expression("R"["p"]^2))+
  theme(legend.position = "none")
root_plot

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
split.fig <- ggarrange(root_plot, subsample_plot,
                          labels = c("A", "B"),
                          nrow = 2,
                          widths = c(0.6, 1))
split.fig

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
ggsave(plot = split.fig, filename = "output/Figure5_Subsamples.png",
       units = "in", height = 9, width = 12)

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin18.2.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS/LAPACK: /usr/local/Cellar/openblas/0.3.6_1/lib/libopenblasp-r0.3.6.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] magrittr_2.0.1  ggpubr_0.4.0    forcats_0.5.0   stringr_1.4.0  
 [5] dplyr_1.0.5     purrr_0.3.4     readr_1.4.0     tidyr_1.1.2    
 [9] tibble_3.1.1    ggplot2_3.3.3   tidyverse_1.3.0 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] httr_1.4.2        jsonlite_1.7.2    carData_3.0-4     modelr_0.1.8     
 [5] assertthat_0.2.1  cellranger_1.1.0  yaml_2.2.1        pillar_1.6.0     
 [9] backports_1.2.1   glue_1.4.2        digest_0.6.27     promises_1.1.1   
[13] ggsignif_0.6.0    rvest_0.3.6       colorspace_2.0-0  cowplot_1.1.1    
[17] htmltools_0.5.1   httpuv_1.5.5      pkgconfig_2.0.3   broom_0.7.3      
[21] haven_2.3.1       scales_1.1.1      whisker_0.4       openxlsx_4.2.3   
[25] later_1.1.0.1     rio_0.5.16        git2r_0.28.0      generics_0.1.0   
[29] farver_2.1.0      car_3.0-10        ellipsis_0.3.1    withr_2.4.2      
[33] cli_2.4.0         crayon_1.4.1      readxl_1.3.1      evaluate_0.14    
[37] fs_1.5.0          fansi_0.4.2       rstatix_0.6.0     xml2_1.3.2       
[41] foreign_0.8-72    tools_3.5.2       data.table_1.13.6 hms_1.0.0        
[45] lifecycle_1.0.0   munsell_0.5.0     reprex_0.3.0      zip_2.1.1        
[49] compiler_3.5.2    rlang_0.4.10      grid_3.5.2        rstudioapi_0.13  
[53] labeling_0.4.2    rmarkdown_2.6     gtable_0.3.0      abind_1.4-5      
[57] DBI_1.1.1         curl_4.3          R6_2.5.0          lubridate_1.7.9.2
[61] knitr_1.29        utf8_1.2.1        rprojroot_2.0.2   stringi_1.5.3    
[65] Rcpp_1.0.6        vctrs_0.3.7       dbplyr_2.0.0      tidyselect_1.1.0 
[69] xfun_0.20