Last updated: 2019-04-22

Checks: 6 0

Knit directory: dsc-log-fold-change/

This reproducible R Markdown analysis was created with workflowr (version 1.2.0). The Report 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(20181115) 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! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

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:    .sos/
    Ignored:    analysis/.sos/
    Ignored:    dsc/.sos/
    Ignored:    dsc/benchmark/
    Ignored:    dsc/dsc_test/.sos/
    Ignored:    output/

Untracked files:
    Untracked:  analysis/eval_initial_power.Rmd
    Untracked:  analysis/eval_initial_type1.Rmd
    Untracked:  analysis/sim_power_berge_pbmc_results.Rmd

Unstaged changes:
    Modified:   analysis/index.Rmd
    Modified:   dsc/benchmark.dsc
    Modified:   dsc/benchmark.sh

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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
html 94f122f Joyce Hsiao 2019-04-22 Build site.
Rmd a9cd8b5 Joyce Hsiao 2019-04-22 power, sample size and effect size
Rmd 1cd1ce9 John Blischak 2019-02-21 Try using conda install instead of conda env create.
html 1cd1ce9 John Blischak 2019-02-21 Try using conda install instead of conda env create.

Introduction/summary

Extract dsc results

knitr::opts_chunk$set(warning=F, message=F)

library(dscrutils)
library(tidyverse)
── Attaching packages ────────────────────────────────── tidyverse 1.2.1 ──
✔ ggplot2 3.1.0       ✔ purrr   0.3.2  
✔ tibble  2.1.1       ✔ dplyr   0.8.0.1
✔ tidyr   0.8.3       ✔ stringr 1.3.1  
✔ readr   1.3.1       ✔ forcats 0.3.0  
── Conflicts ───────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

extract dsc output and get p-values, q-values, true signals, etc.

dir_dsc <- "/scratch/midway2/joycehsiao/dsc-log-fold-change/pipe_power_choose_betasd"

dsc_res_edger <- dscquery(dir_dsc, 
                    targets=c("data_poisthin_choose_betasd",
                              "data_poisthin_choose_betasd.seed", 
                              "data_poisthin_choose_betasd.n1",
                              "data_poisthin_choose_betasd.betasd",
                              "edger", "pval_rank"), 
                    ignore.missing.file = T)

dsc_res_limma_voom <- dscquery(dir_dsc, 
                    targets=c("data_poisthin_choose_betasd",
                              "data_poisthin_choose_betasd.seed", 
                              "data_poisthin_choose_betasd.n1",
                              "data_poisthin_choose_betasd.betasd",
                              "limma_voom", "pval_rank"), 
                    ignore.missing.file = T)


dsc_res_edger$output.file <- dsc_res_edger$edger.output.file
dsc_res_limma_voom$output.file <- dsc_res_limma_voom$limma_voom.output.file

dsc_res_edger <- subset(dsc_res_edger, select = -c(edger.output.file))
dsc_res_limma_voom <- subset(dsc_res_limma_voom, select = -c(limma_voom.output.file))
  
dsc_res <- rbind(data.frame(dsc_res_edger, method = rep("edger", nrow(dsc_res_edger))),
                 data.frame(dsc_res_limma_voom, method = rep("limma_voom", nrow(dsc_res_limma_voom))) )


method_vec <- as.factor(dsc_res$method)
n_methods <- nlevels(method_vec)

res <- vector("list",n_methods)
for (i in 1:nrow(dsc_res)) {
#  if (verbose) {print(i)}
  fl_pval <- readRDS(file.path(dir_dsc,
                       paste0(as.character(dsc_res$output.file[i]), ".rds")))
  fl_beta <- readRDS(file.path(dir_dsc,
                   paste0(as.character(dsc_res$data_poisthin_choose_betasd.output.file[i]), ".rds")))
  seed <- dsc_res$data_poisthin_choose_betasd.seed[i]
  n1 <- dsc_res$data_poisthin_choose_betasd.n1[i]
  betasd <- dsc_res$data_poisthin_choose_betasd.betasd[i]
  fl_qval <- readRDS(file.path(dir_dsc,
                      paste0(as.character(dsc_res$pval_rank.output.file[i]), ".rds")))
  res[[i]] <- data.frame(method = as.character(dsc_res$method)[i],
                         seed = seed,
                         betasd=betasd,
                         n1=n1,
                         truth_vec = fl_beta$beta != 0,
                         pval = fl_pval$pval,
                         qval = fl_qval$qval,
                         stringsAsFactors = F)
}
res_merge <- do.call(rbind, res)

saveRDS(res_merge, file = "output/eval_initial.Rmd/res_merge.rds")

Analyze

res_merge <- readRDS(file = "output/eval_initial.Rmd/res_merge.rds")

fdr_thres <- .1

p1 <- res_merge %>%
  filter(method == "limma_voom") %>%
  group_by(seed, betasd, n1) %>%
  summarise(power = sum(truth_vec==TRUE & qval<fdr_thres)/sum(truth_vec==TRUE)) %>%
  ggplot(., aes(x=factor(n1), y=power, col=factor(betasd))) + ylim(0,1) +
    geom_boxplot() +
    ylab("Power") + xlab("n1") +
    ggtitle("limma_voom")

p2 <- res_merge %>%
  filter(method == "edger") %>%
  group_by(seed, betasd, n1) %>%
  summarise(power = sum(truth_vec==TRUE & qval<fdr_thres)/sum(truth_vec==TRUE)) %>%
  ggplot(., aes(x=factor(n1), y=power, col=factor(betasd))) + ylim(0,1) +
    geom_boxplot() +
    ylab("Power") + xlab("n1") +
    ggtitle("edger")

library(cowplot)
plot_grid(p1,p2)

Version Author Date
94f122f Joyce Hsiao 2019-04-22


sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] cowplot_0.9.4   forcats_0.3.0   stringr_1.3.1   dplyr_0.8.0.1  
 [5] purrr_0.3.2     readr_1.3.1     tidyr_0.8.3     tibble_2.1.1   
 [9] ggplot2_3.1.0   tidyverse_1.2.1 dscrutils_0.3.8

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0       cellranger_1.1.0 plyr_1.8.4       compiler_3.5.1  
 [5] pillar_1.3.1     git2r_0.23.0     workflowr_1.2.0  tools_3.5.1     
 [9] digest_0.6.18    lubridate_1.7.4  jsonlite_1.6     evaluate_0.12   
[13] nlme_3.1-137     gtable_0.2.0     lattice_0.20-38  pkgconfig_2.0.2 
[17] rlang_0.3.1      cli_1.0.1        rstudioapi_0.10  yaml_2.2.0      
[21] haven_1.1.2      withr_2.1.2      xml2_1.2.0       httr_1.3.1      
[25] knitr_1.20       hms_0.4.2        generics_0.0.2   fs_1.2.6        
[29] rprojroot_1.3-2  grid_3.5.1       tidyselect_0.2.5 glue_1.3.0      
[33] R6_2.3.0         readxl_1.1.0     rmarkdown_1.10   modelr_0.1.2    
[37] magrittr_1.5     whisker_0.3-2    backports_1.1.2  scales_1.0.0    
[41] htmltools_0.3.6  rvest_0.3.2      assertthat_0.2.0 colorspace_1.3-2
[45] labeling_0.3     stringi_1.2.4    lazyeval_0.2.1   munsell_0.5.0   
[49] broom_0.5.1      crayon_1.3.4