Last updated: 2020-12-02

Checks: 6 1

Knit directory: esoph-micro-cancer-workflow/

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(20200916) 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 9937a7e. 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:    analysis/figure/
    Ignored:    data/

Untracked files:
    Untracked:  analysis/test-of-replication.Rmd

Unstaged changes:
    Modified:   analysis/data_processing_nci_umd.Rmd
    Modified:   analysis/data_processing_tcga.Rmd
    Modified:   analysis/index.Rmd
    Modified:   code/get_cleaned_data.R

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.


  • Goal is to replicate Fisher’s exact test.

Data mung

First, we need to format the data for the analyses.

# transform to relative abundances
phylo.data.nci.umd <- transform_sample_counts(phylo.data.nci.umd, function(x){x / sum(x)})
phylo.data.tcga.RNAseq <- transform_sample_counts(phylo.data.tcga.RNAseq, function(x){x / sum(x)})
phylo.data.tcga.WGS <- transform_sample_counts(phylo.data.tcga.WGS, function(x){x / sum(x)})

# melt data down for use
dat.16s <- psmelt(phylo.data.nci.umd)
dat.rna <- psmelt(phylo.data.tcga.RNAseq)
dat.wgs <- psmelt(phylo.data.tcga.WGS)

# fix otu formatting
dat.rna$otu2 <- "a"
dat.wgs$otu2 <- "a"
i <- 1
for(i in 1:nrow(dat.rna)){
  dat.rna$otu2[i] <- str_split(dat.rna$OTU[i], ";")[[1]][7]
}
for(i in 1:nrow(dat.wgs)){
  dat.wgs$otu2[i] <- str_split(dat.wgs$OTU[i], ";")[[1]][7]
}


# subset to fuso. nuc. only
dat.16s <- filter(dat.16s, OTU == "Fusobacterium_nucleatum")
dat.rna <- filter(dat.rna, otu2 == "Fusobacterium nucleatum")
dat.wgs <- filter(dat.wgs, otu2 == "Fusobacterium nucleatum")

# make tumor vs normal variable
dat.16s$tumor <- factor(dat.16s$tissue, levels=c("BO", "N", "T"), labels = c("Non-Tumor", "Non-Tumor", "Tumor"))
dat.rna$tumor <- factor(dat.rna$SampleType_Level2, levels=c("Normal", "Tumor"), labels = c("Non-Tumor", "Tumor"))
dat.wgs$tumor <- factor(dat.wgs$SampleType_Level2, levels=c("Normal", "Tumor"), labels = c("Non-Tumor", "Tumor"))

# dataset id
dat.16s$source <- "16s"
dat.rna$source <- "rna"
dat.wgs$source <- "wgs"

# plotting ids
dat.16s$X <- paste0(dat.16s$source, "-", dat.16s$tumor)
dat.rna$X <- paste0(dat.rna$source, "-", dat.rna$tumor)
dat.wgs$X <- paste0(dat.wgs$source, "-", dat.wgs$tumor)

# merge data
cls <- c("OTU", "Sample", "Abundance", "tumor", "source", "X")
mydata <- full_join(dat.16s[,cls], dat.rna[,cls])
Joining, by = c("OTU", "Sample", "Abundance", "tumor", "source", "X")
mydata <- full_join(mydata, dat.wgs[,cls])
Joining, by = c("OTU", "Sample", "Abundance", "tumor", "source", "X")

Replicating the Analysis

Plot

p <- ggplot(mydata, aes(x=X, y=Abundance)) +
  geom_violin() +
  geom_jitter(alpha=0.5) +
  scale_y_continuous(
    trans = "sqrt",
    breaks=c(0.002, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.8)) +
  theme_classic()
p

Fisher Exact Test

Joining, by = c("OTU", "Sample", "Abundance", "tumor", "source", "X")
Joining, by = c("OTU", "Sample", "Abundance", "tumor", "source", "X")

Mann-Whitney U-Test

#
wilcox.test(dat.16s$Abundance ~ dat.16s$tumor)

    Wilcoxon rank sum test with continuity correction

data:  dat.16s$Abundance by dat.16s$tumor
W = 2330, p-value = 0.006126
alternative hypothesis: true location shift is not equal to 0
wilcox.test(dat.rna$Abundance ~ dat.rna$tumor)

    Wilcoxon rank sum test with continuity correction

data:  dat.rna$Abundance by dat.rna$tumor
W = 237, p-value = 0.5319
alternative hypothesis: true location shift is not equal to 0
wilcox.test(dat.wgs$Abundance ~ dat.wgs$tumor)

    Wilcoxon rank sum test with continuity correction

data:  dat.wgs$Abundance by dat.wgs$tumor
W = 1267.5, p-value = 0.0006748
alternative hypothesis: true location shift is not equal to 0

Fisher Exact Test.

a <- na.omit(dat.16s[, c("barrett", "tumor")])
fisher.test(a$barrett, a$tumor)

    Fisher's Exact Test for Count Data

data:  a$barrett and a$tumor
p-value = 1
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.5153007 2.0334489
sample estimates:
odds ratio 
  1.022175 
a <- na.omit(dat.rna[, c("barrett", "tumor")])
fisher.test(a$barrett, a$tumor)

    Fisher's Exact Test for Count Data

data:  a$barrett and a$tumor
p-value = 0.6188
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.07451302 7.42811003
sample estimates:
odds ratio 
 0.5913395 
a <- na.omit(dat.wgs[, c("barrett", "tumor")])
fisher.test(a$barrett, a$tumor)

    Fisher's Exact Test for Count Data

data:  a$barrett and a$tumor
p-value = 1
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.1595714 4.8896940
sample estimates:
odds ratio 
 0.9158179 

sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

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] car_3.0-8         carData_3.0-4     gvlma_1.0.0.3     patchwork_1.0.1  
 [5] viridis_0.5.1     viridisLite_0.3.0 gridExtra_2.3     xtable_1.8-4     
 [9] kableExtra_1.1.0  plyr_1.8.6        data.table_1.13.0 readxl_1.3.1     
[13] forcats_0.5.0     stringr_1.4.0     dplyr_1.0.1       purrr_0.3.4      
[17] readr_1.3.1       tidyr_1.1.1       tibble_3.0.3      ggplot2_3.3.2    
[21] tidyverse_1.3.0   lmerTest_3.1-2    lme4_1.1-23       Matrix_1.2-18    
[25] vegan_2.5-6       lattice_0.20-41   permute_0.9-5     phyloseq_1.32.0  
[29] workflowr_1.6.2  

loaded via a namespace (and not attached):
 [1] minqa_1.2.4         colorspace_1.4-1    rio_0.5.16         
 [4] ellipsis_0.3.1      rprojroot_1.3-2     XVector_0.28.0     
 [7] fs_1.5.0            rstudioapi_0.11     farver_2.0.3       
[10] fansi_0.4.1         lubridate_1.7.9     xml2_1.3.2         
[13] codetools_0.2-16    splines_4.0.2       knitr_1.29         
[16] ade4_1.7-15         jsonlite_1.7.0      nloptr_1.2.2.2     
[19] broom_0.7.0         cluster_2.1.0       dbplyr_1.4.4       
[22] BiocManager_1.30.10 compiler_4.0.2      httr_1.4.2         
[25] backports_1.1.7     assertthat_0.2.1    cli_2.0.2          
[28] later_1.1.0.1       htmltools_0.5.0     tools_4.0.2        
[31] igraph_1.2.5        gtable_0.3.0        glue_1.4.1         
[34] reshape2_1.4.4      Rcpp_1.0.5          Biobase_2.48.0     
[37] cellranger_1.1.0    vctrs_0.3.2         Biostrings_2.56.0  
[40] multtest_2.44.0     ape_5.4             nlme_3.1-148       
[43] iterators_1.0.12    xfun_0.19           openxlsx_4.1.5     
[46] rvest_0.3.6         lifecycle_0.2.0     statmod_1.4.34     
[49] zlibbioc_1.34.0     MASS_7.3-51.6       scales_1.1.1       
[52] hms_0.5.3           promises_1.1.1      parallel_4.0.2     
[55] biomformat_1.16.0   rhdf5_2.32.2        curl_4.3           
[58] yaml_2.2.1          stringi_1.4.6       S4Vectors_0.26.1   
[61] foreach_1.5.0       BiocGenerics_0.34.0 zip_2.0.4          
[64] boot_1.3-25         rlang_0.4.7         pkgconfig_2.0.3    
[67] evaluate_0.14       Rhdf5lib_1.10.1     tidyselect_1.1.0   
[70] magrittr_1.5        R6_2.4.1            IRanges_2.22.2     
[73] generics_0.0.2      DBI_1.1.0           foreign_0.8-80     
[76] pillar_1.4.6        haven_2.3.1         withr_2.2.0        
[79] mgcv_1.8-31         abind_1.4-5         survival_3.2-3     
[82] modelr_0.1.8        crayon_1.3.4        rmarkdown_2.5      
[85] grid_4.0.2          blob_1.2.1          git2r_0.27.1       
[88] reprex_0.3.0        digest_0.6.25       webshot_0.5.2      
[91] httpuv_1.5.4        numDeriv_2016.8-1.1 stats4_4.0.2       
[94] munsell_0.5.0