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_summary_figures.Rmd) and HTML (docs/manuscript_summary_figures.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

Summary statistics and figures

Load packages

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(reshape2)

Attaching package: 'reshape2'
The following object is masked from 'package:tidyr':

    smiths
library(wesanderson)
library(readxl)
library(agricolae)
library(waves)
library(ggpubr)

iwanthue <- c("#c84d4c","#c77c3f","#d19f32","#647e3a","#61b858","#4db5a4","#6585cc","#975fc7","#c575a1","#cf4391")

namekey <- read.csv("data/TrialNameKey.csv") %>% rename(Trial = Abbreviated.Trial.Name) 
plots.aggregated <- read.csv("output/full_filtered_plots.csv", stringsAsFactors = F) %>% 
  left_join(namekey) %>% 
  dplyr::select(-studyName) %>% 
  rename(studyName = Trial) %>% 
  distinct()
Joining, by = "studyName"

#Figures and tables ##DMC summary table

dmc.summary <- plots.aggregated %>% 
  drop_na(dry.matter.content.percentage.CO_334.0000092) %>% 
  mutate(plot.id = paste(studyName, plotNumber, sep = "_")) %>% 
  drop_na(dry.matter.content.percentage.CO_334.0000092, X740) %>% 
  group_by(programName, studyName, studyDesign) %>% 
  summarize(`# Accessions` = n_distinct(germplasmName), 
            `# Plots` = n_distinct(observationUnitName),             
            `Mean DMC` = mean(dry.matter.content.percentage.CO_334.0000092), 
            `Maximum DMC` = max(dry.matter.content.percentage.CO_334.0000092), 
            `Minimum DMC` = min(dry.matter.content.percentage.CO_334.0000092), 
            `DMC Standard Deviation` = sd(dry.matter.content.percentage.CO_334.0000092)) %>% 
  rename(`Program Name` = programName, 
         `Trial Name` = studyName,
         `Trial Design` = studyDesign)
`summarise()` has grouped output by 'programName', 'studyName'. You can override using the `.groups` argument.
plots.aggregated %>% 
  group_by(studyName) %>% 
  dplyr::select(studyName, germplasmName) %>% 
  distinct() %>% 
  summarize(n())
# A tibble: 10 x 2
   studyName `n()`
   <fct>     <int>
 1 A-17IB       48
 2 B-17IB       65
 3 C-18IB       51
 4 D-18IB       35
 5 E-18IB       36
 6 F-19IB       30
 7 G-19IB       35
 8 H-19IB       36
 9 I-19IK       50
10 J-19IK      180
write.csv(dmc.summary, "output/Table2_DMC_statistics.csv", row.names = F)

Genotype overlap between trials

germ.by.trial <- plots.aggregated %>%
  drop_na(dry.matter.content.percentage.CO_334.0000092, X740) %>%
  dplyr::select(studyName, germplasmName) %>%
  distinct() %>% 
  mutate(present = 1) %>% 
  pivot_wider(names_from = studyName, values_from = present) %>% 
  mutate_at(vars(unique(plots.aggregated$studyName)), ~ifelse(is.na(.), 0, 1)) %>% 
  rowwise() %>% 
  mutate(sum_representation = sum(c(`A-17IB`, `B-17IB`, `C-18IB`, `D-18IB`, `E-18IB`, 
                                    `F-19IB`, `G-19IB`, `H-19IB`, `I-19IK`, `J-19IK`))) %>% 
  dplyr::select(germplasmName, sum_representation, everything())

counts.v3  <- plots.aggregated %>%
  dplyr::select(studyName, germplasmName) %>%
  distinct() %>%
  dplyr::count(., studyName, germplasmName) %>%
  spread(studyName, n, fill = 0) %>%
  select(-germplasmName) %>%
  as.matrix() %>%
  crossprod()

#write.csv(germ.by.trial, "output/germplasm_by_trial_inclusion_nicknames.csv", row.names = F)
write.csv(counts.v3, "output/S1_overlapping_accession_counts.csv", row.names = T)
germplasm.order <- plots.aggregated %>% dplyr::select(studyName, germplasmName) %>% 
  arrange(studyName, germplasmName) %>% dplyr::select(-studyName) %>% distinct() %>% rownames_to_column()

cv.base.plot <- plots.aggregated %>% 
  full_join(germplasm.order) %>% 
  dplyr::select(studyName, germplasmName, rowname) %>% 
  distinct() %>% 
  arrange(studyName, rowname) %>% 
  mutate(germplasmName = factor(germplasmName, levels = germplasm.order$germplasmName)) %>% 
  ggplot(., aes(x = germplasmName, y = reorder(studyName, desc(studyName)))) + geom_tile() + 
  labs(x = "Clone", y = "Trial") +
  theme_bw() +
  theme(axis.text.x = element_blank(), axis.ticks.x = element_blank(),
        panel.grid.major.x = element_blank(),
        panel.grid.major.y = element_blank(),)
Joining, by = "germplasmName"
cv.base.plot

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
cv.base.multi <- ggarrange(cv.base.plot, cv.base.plot, cv.base.plot, cv.base.plot,
                          labels = c("A", "B", "C", "D"),
                          nrow = 2, ncol = 2,
                          widths = c(1, 1))
cv.base.multi

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
ggsave(plot = cv.base.multi, "output/cv_base.png", device = "png", units = "in", width = 10, height = 6)

DMC violin and boxplots figure

# tukey https://stackoverflow.com/questions/48625620/adding-tukeys-significance-letters-to-boxplot
dmc.lm <- lm(dry.matter.content.percentage.CO_334.0000092~studyName, data = plots.aggregated)
dmc.aov <- aov(dmc.lm)
dmc.tuk <- TukeyHSD(dmc.aov)
dmc.tuk.agricolae <- HSD.test(dmc.aov, trt="studyName", unbalanced = TRUE)
tuk.means <- dmc.tuk.agricolae$means %>% rownames_to_column("studyName")
tuk.groups <- dmc.tuk.agricolae$groups %>% rownames_to_column("studyName") %>%  
  left_join(tuk.means, by = "studyName") %>% 
  dplyr::select(studyName, groups, Max) 


dmc.violin.boxplot <- plots.aggregated %>% left_join(tuk.groups, by = "studyName") %>% 
  ggplot(aes(x = studyName, y = dry.matter.content.percentage.CO_334.0000092, 
             fill = studyName
             )) + geom_violin()+
  geom_boxplot(position = "identity", width = .2) + 
  theme_bw() + 
  geom_text(aes(label = groups, y = (.6 + Max)), vjust = 0) +
  labs(x = "Trial", #title = "Plot mean dry matter content by trial", 
       y = "Dry matter content (%)") +
  scale_fill_manual(values = iwanthue, name = "Trial") +
  theme(legend.position = "none")
dmc.violin.boxplot

Version Author Date
88fee14 Jenna Hershberger 2021-04-30
ggsave(dmc.violin.boxplot, filename = "output/Figure2_DMC_distributions.png",  
       bg = "transparent", height = 5, width = 7)

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] ggpubr_0.4.0      waves_0.1.0       agricolae_1.3-3   readxl_1.3.1     
 [5] wesanderson_0.3.6 reshape2_1.4.4    forcats_0.5.0     stringr_1.4.0    
 [9] dplyr_1.0.5       purrr_0.3.4       readr_1.4.0       tidyr_1.1.2      
[13] tibble_3.1.1      ggplot2_3.3.3     tidyverse_1.3.0   workflowr_1.6.2  

loaded via a namespace (and not attached):
  [1] colorspace_2.0-0     ggsignif_0.6.0       prospectr_0.2.0     
  [4] rio_0.5.16           ellipsis_0.3.1       class_7.3-18        
  [7] rprojroot_2.0.2      pls_2.7-3            fs_1.5.0            
 [10] rstudioapi_0.13      farver_2.1.0         prodlim_2019.11.13  
 [13] fansi_0.4.2          lubridate_1.7.9.2    xml2_1.3.2          
 [16] codetools_0.2-18     splines_3.5.2        knitr_1.29          
 [19] jsonlite_1.7.2       pROC_1.17.0.1        caret_6.0-86        
 [22] broom_0.7.3          cluster_2.1.0        dbplyr_2.0.0        
 [25] shiny_1.6.0          compiler_3.5.2       httr_1.4.2          
 [28] spectacles_0.5-3     backports_1.2.1      assertthat_0.2.1    
 [31] Matrix_1.2-18        fastmap_1.1.0        cli_2.4.0           
 [34] later_1.1.0.1        htmltools_0.5.1      tools_3.5.2         
 [37] gtable_0.3.0         glue_1.4.2           Rcpp_1.0.6          
 [40] carData_3.0-4        limSolve_1.5.6       cellranger_1.1.0    
 [43] vctrs_0.3.7          baseline_1.3-1       nlme_3.1-151        
 [46] iterators_1.0.13     timeDate_3043.102    xfun_0.20           
 [49] gower_0.2.2          openxlsx_4.2.3       rvest_0.3.6         
 [52] lpSolve_5.6.15       mime_0.9             miniUI_0.1.1.1      
 [55] lifecycle_1.0.0      rstatix_0.6.0        MASS_7.3-53         
 [58] scales_1.1.1         ipred_0.9-9          hms_1.0.0           
 [61] promises_1.1.1       SparseM_1.78         curl_4.3            
 [64] yaml_2.2.1           pander_0.6.3         labelled_2.7.0      
 [67] rpart_4.1-15         stringi_1.5.3        highr_0.8           
 [70] klaR_0.6-15          AlgDesign_1.2.0      foreach_1.5.1       
 [73] randomForest_4.6-14  zip_2.1.1            lava_1.6.8.1        
 [76] epiR_2.0.19          rlang_0.4.10         pkgconfig_2.0.3     
 [79] evaluate_0.14        lattice_0.20-41      labeling_0.4.2      
 [82] recipes_0.1.15       cowplot_1.1.1        tidyselect_1.1.0    
 [85] plyr_1.8.6           magrittr_2.0.1       R6_2.5.0            
 [88] generics_0.1.0       combinat_0.0-8       DBI_1.1.1           
 [91] foreign_0.8-72       pillar_1.6.0         haven_2.3.1         
 [94] whisker_0.4          withr_2.4.2          abind_1.4-5         
 [97] survival_3.2-7       nnet_7.3-15          car_3.0-10          
[100] modelr_0.1.8         crayon_1.4.1         questionr_0.7.4     
[103] utf8_1.2.1           rmarkdown_2.6        grid_3.5.2          
[106] data.table_1.13.6    git2r_0.28.0         ModelMetrics_1.2.2.2
[109] reprex_0.3.0         digest_0.6.27        xtable_1.8-4        
[112] httpuv_1.5.5         signal_0.7-6         stats4_3.5.2        
[115] munsell_0.5.0        BiasedUrn_1.07       quadprog_1.5-8