Last updated: 2020-05-19

Checks: 7 0

Knit directory: methyl-geneset-testing/

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(20200302) 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 63b0011. 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/.job/
    Ignored:    code/old/
    Ignored:    data/
    Ignored:    output/FDR-analysis/
    Ignored:    output/compare-methods/
    Ignored:    output/random-cpg-sims/

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/runTimeComparison.Rmd) and HTML (docs/runTimeComparison.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 63b0011 Jovana Maksimovic 2020-05-19 wflow_publish(c(“analysis/exploreArrayBias450.Rmd”, “analysis/exploreArrayBiasEPIC.Rmd”,
html f2da7f9 Jovana Maksimovic 2020-05-15 Build site.
Rmd 68a0f24 Jovana Maksimovic 2020-05-15 wflow_publish(c(“analysis/index.Rmd”, “analysis/runTimeComparison.Rmd”))
Rmd 1a34512 JovMaksimovic 2020-05-15 Code for comparing run-time of different gene set testing methods on the blood cell data.

library(here)
library(minfi)
library(limma)
library(reshape2)
library(missMethyl)
library(ggplot2)
library(glue)
library(tidyverse)
library(patchwork)
library(ChAMPdata)
library(tictoc)
library(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
library(EnsDb.Hsapiens.v75)
library(ChAMP)
library(methylGSA)

Compare run-time of different methods

Setup inputs

Create database for translating gene IDs.

edb <- EnsDb.Hsapiens.v75
transIDs <- genes(edb, columns = c("symbol", "gene_id", "entrezid"), 
                       return.type = "DataFrame")

Run-time comparison

Execute and record run-time for each method (on a single core) for the three different contrasts.

inFile <- here("data/run-time-results.rds")

if(!file.exists(inFile)){
    
    data("PathwayList")
    keep <- sapply(PathwayList, function(x) any(x %in% transIDs$symbol))
    symbol <- suppressMessages(lapply(PathwayList[keep], function(x){
        tmp <- unlist(transIDs$symbol[transIDs$symbol %in% x], use.names = FALSE)
        tmp[!is.na(tmp)]
    }))
    entrezid <- suppressMessages(lapply(symbol, function(x){
        tmp <- unlist(transIDs$entrezid[transIDs$symbol %in% x], use.names = FALSE)
        tmp[!is.na(tmp)]
    }))
    
    load(here("data/input.RData"))
    anno <- minfi::getAnnotation(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
    timing <- NULL
    
    for(i in 1:ncol(tfit$contrasts)){
        top <- topTreat(tfit, coef = i, number = 5000)
        
        tic("gometh")
        res <- gsameth(sig.cpg = rownames(top), 
                       all.cpg = rownames(tfit$coefficients), collection = entrezid, 
                       array.type = "EPIC", anno = anno)
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        timing <- bind_rows(timing, log)
        
        tic("mgsa.glm")
        res <- methylglm(cpg.pval = tfit$p.value[,i],
                         FullAnnot = anno, minsize = minsize, maxsize = maxsize,
                         GS.list = symbol, GS.idtype = "SYMBOL")
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        timing <- bind_rows(timing, log)
        
        tic("mgsa.ora")
        res <- methylRRA(cpg.pval = tfit$p.value[,i],
                         method = "ORA", FullAnnot = anno, minsize = minsize,
                         maxsize = maxsize, GS.list = symbol,
                         GS.idtype = "SYMBOL")
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        timing <- bind_rows(timing, log)
        
        tic("mgsa.gsea")
        res <- methylRRA(cpg.pval = tfit$p.value[,i],
                         method = "GSEA", FullAnnot = anno, minsize = minsize,
                         maxsize = maxsize, GS.list = symbol,
                         GS.idtype = "SYMBOL")
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        timing <- bind_rows(timing, log)
        
        cellType <- names(tfit$contrasts[,i])[tfit$contrasts[,i] != 0]
        tic("champ.ebgsea")
        ebgs <- champ.ebGSEA(beta = mVals[,targets$CellType %in% cellType],
                             pheno = targets$CellType[targets$CellType %in% cellType],
                             minN = 5, adjPval=1, arraytype = "EPIC")
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        timing <- bind_rows(timing, log)
        
    }
    saveRDS(timing, file = inFile)
    
} else {
    timing <- readRDS(inFile)
    colnames(timing)[3] <- "contrast"
    
}

Plot run-time results.

timing %>% mutate(time = as.integer(time)) %>%
    mutate(method = ifelse(method == "gometh", "mmethyl.gometh", 
                           method)) -> dat

p1 <- ggplot(dat, aes(x = method, y = time/60, fill = contrast)) + 
    geom_bar(position = "dodge", stat = "identity") +
    labs(x = "Method", y = "Run time (minutes)", fill = "Contrast")
p1

Version Author Date
f2da7f9 Jovana Maksimovic 2020-05-15
inFile <- here("data/run-time-mcores.rds")

if(!file.exists(inFile)){
    
    data("PathwayList")
    keep <- sapply(PathwayList, function(x) any(x %in% transIDs$symbol))
    symbol <- suppressMessages(lapply(PathwayList[keep], function(x){
        tmp <- unlist(transIDs$symbol[transIDs$symbol %in% x], use.names = FALSE)
        tmp[!is.na(tmp)]
    }))
    
    load(here("data/input.RData"))
    anno <- minfi::getAnnotation(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
    multi <- NULL
    
    for(i in 1:ncol(tfit$contrasts)){
        
        tic("mgsa.glm.3")
        res <- methylglm(cpg.pval = tfit$p.value[,i],
                         FullAnnot = anno, minsize = minsize, maxsize = maxsize,
                         GS.list = symbol, GS.idtype = "SYMBOL", parallel = TRUE,
                         BPPARAM = BiocParallel::MulticoreParam(workers = 3))
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        multi <- bind_rows(multi, log)
        
        tic("mgsa.glm.6")
        res <- methylglm(cpg.pval = tfit$p.value[,i],
                         FullAnnot = anno, minsize = minsize, maxsize = maxsize,
                         GS.list = symbol, GS.idtype = "SYMBOL", parallel = TRUE,
                         BPPARAM = BiocParallel::MulticoreParam(workers = 6))
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        multi <- bind_rows(multi, log)
        
        tic("mgsa.glm.9")
        res <- methylglm(cpg.pval = tfit$p.value[,i],
                         FullAnnot = anno, minsize = minsize, maxsize = maxsize,
                         GS.list = symbol, GS.idtype = "SYMBOL", parallel = TRUE,
                         BPPARAM = BiocParallel::MulticoreParam(workers = 9))
        toc(log = TRUE, quiet = TRUE)
        tmp <- strsplit2(tic.log(format = TRUE)[[1]], " ")
        log <- data.frame(method = gsub(":", "", tmp[1]), time = tmp[2], 
                          contrast = colnames(tfit$contrasts)[i])
        tic.clearlog()
        multi <- bind_rows(multi, log)
        
    }
    saveRDS(multi, file = inFile)
    
} else {
    multi <- readRDS(inFile)
}

Plot run-time results.

multi %>% mutate(time = as.integer(time)) %>%
    mutate(cores = limma::strsplit2(method, ".", fixed=TRUE)[,3])-> dat

p2 <- ggplot(dat, aes(x = cores, y = time/60, fill = contrast)) + 
    geom_bar(position = "dodge", stat = "identity") +
    labs(x = "No. cores", y = "Run time (minutes)", fill = "Contrast") +
    ggtitle("Using multiple cores for mgsa.glm") 
p2

Combining single core and multi-core plots.

layout <- c(area(t = 0, l = 1, b = 5, r = 4),
            area(t = 2, l = 3, b = 3, r = 4))
p1 + p2 + theme(text = element_text(size = 8), legend.position = "none") + 
    plot_layout(design = layout, guides = "collect")


sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /config/RStudio/R/3.6.1/lib64/R/lib/libRblas.so
LAPACK: /config/RStudio/R/3.6.1/lib64/R/lib/libRlapack.so

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

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

other attached packages:
 [1] methylGSA_1.4.9                                    
 [2] ChAMP_2.16.2                                       
 [3] DT_0.9                                             
 [4] IlluminaHumanMethylationEPICmanifest_0.3.0         
 [5] Illumina450ProbeVariants.db_1.22.0                 
 [6] DMRcate_2.0.7                                      
 [7] FEM_3.14.0                                         
 [8] graph_1.62.0                                       
 [9] org.Hs.eg.db_3.8.2                                 
[10] impute_1.58.0                                      
[11] igraph_1.2.5                                       
[12] corrplot_0.84                                      
[13] marray_1.62.0                                      
[14] Matrix_1.2-18                                      
[15] EnsDb.Hsapiens.v75_2.99.0                          
[16] ensembldb_2.8.0                                    
[17] AnnotationFilter_1.8.0                             
[18] GenomicFeatures_1.36.4                             
[19] AnnotationDbi_1.46.1                               
[20] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0
[21] tictoc_1.0                                         
[22] ChAMPdata_2.18.0                                   
[23] patchwork_1.0.0                                    
[24] forcats_0.4.0                                      
[25] stringr_1.4.0                                      
[26] dplyr_0.8.5                                        
[27] purrr_0.3.4                                        
[28] readr_1.3.1                                        
[29] tidyr_1.0.3                                        
[30] tibble_2.1.3                                       
[31] tidyverse_1.3.0                                    
[32] glue_1.4.1                                         
[33] ggplot2_3.3.0                                      
[34] missMethyl_1.20.4                                  
[35] reshape2_1.4.3                                     
[36] limma_3.42.2                                       
[37] minfi_1.32.0                                       
[38] bumphunter_1.26.0                                  
[39] locfit_1.5-9.1                                     
[40] iterators_1.0.12                                   
[41] foreach_1.5.0                                      
[42] Biostrings_2.54.0                                  
[43] XVector_0.24.0                                     
[44] SummarizedExperiment_1.16.1                        
[45] DelayedArray_0.12.3                                
[46] BiocParallel_1.20.1                                
[47] matrixStats_0.56.0                                 
[48] Biobase_2.46.0                                     
[49] GenomicRanges_1.38.0                               
[50] GenomeInfoDb_1.22.1                                
[51] IRanges_2.20.2                                     
[52] S4Vectors_0.24.4                                   
[53] BiocGenerics_0.32.0                                
[54] here_0.1                                           
[55] workflowr_1.6.2                                    

loaded via a namespace (and not attached):
  [1] Hmisc_4.2-0                                        
  [2] Rsamtools_2.0.1                                    
  [3] rprojroot_1.3-2                                    
  [4] crayon_1.3.4                                       
  [5] MASS_7.3-51.6                                      
  [6] nlme_3.1-147                                       
  [7] backports_1.1.7                                    
  [8] reprex_0.3.0                                       
  [9] sva_3.34.0                                         
 [10] GOSemSim_2.10.0                                    
 [11] rlang_0.4.6                                        
 [12] readxl_1.3.1                                       
 [13] DSS_2.34.0                                         
 [14] globaltest_5.40.0                                  
 [15] bit64_0.9-7                                        
 [16] isva_1.9                                           
 [17] rngtools_1.4                                       
 [18] methylumi_2.30.0                                   
 [19] UpSetR_1.4.0                                       
 [20] DOSE_3.10.2                                        
 [21] haven_2.2.0                                        
 [22] tidyselect_0.2.5                                   
 [23] XML_3.98-1.20                                      
 [24] nleqslv_3.3.2                                      
 [25] GenomicAlignments_1.20.1                           
 [26] xtable_1.8-4                                       
 [27] magrittr_1.5                                       
 [28] evaluate_0.14                                      
 [29] bibtex_0.4.2                                       
 [30] cli_2.0.2                                          
 [31] zlibbioc_1.30.0                                    
 [32] rstudioapi_0.11                                    
 [33] doRNG_1.7.1                                        
 [34] whisker_0.4                                        
 [35] rpart_4.1-15                                       
 [36] fastmatch_1.1-0                                    
 [37] shiny_1.3.2                                        
 [38] xfun_0.13                                          
 [39] askpass_1.1                                        
 [40] clue_0.3-57                                        
 [41] multtest_2.40.0                                    
 [42] cluster_2.1.0                                      
 [43] tidygraph_1.2.0                                    
 [44] interactiveDisplayBase_1.22.0                      
 [45] ggrepel_0.8.1                                      
 [46] base64_2.0                                         
 [47] biovizBase_1.32.0                                  
 [48] scrime_1.3.5                                       
 [49] dendextend_1.13.4                                  
 [50] permute_0.9-5                                      
 [51] reshape_0.8.8                                      
 [52] withr_2.1.2                                        
 [53] ggforce_0.3.1                                      
 [54] lumi_2.38.0                                        
 [55] bitops_1.0-6                                       
 [56] plyr_1.8.6                                         
 [57] cellranger_1.1.0                                   
 [58] JADE_2.0-3                                         
 [59] pillar_1.4.4                                       
 [60] fs_1.4.1                                           
 [61] europepmc_0.3                                      
 [62] clusterProfiler_3.12.0                             
 [63] DelayedMatrixStats_1.8.0                           
 [64] vctrs_0.3.0                                        
 [65] generics_0.0.2                                     
 [66] urltools_1.7.3                                     
 [67] tools_3.6.1                                        
 [68] foreign_0.8-72                                     
 [69] tweenr_1.0.1                                       
 [70] munsell_0.5.0                                      
 [71] fgsea_1.10.1                                       
 [72] compiler_3.6.1                                     
 [73] httpuv_1.5.2                                       
 [74] rtracklayer_1.44.4                                 
 [75] geneLenDataBase_1.20.0                             
 [76] ExperimentHub_1.12.0                               
 [77] beanplot_1.2                                       
 [78] Gviz_1.28.3                                        
 [79] pkgmaker_0.27                                      
 [80] plotly_4.9.0                                       
 [81] GenomeInfoDbData_1.2.1                             
 [82] gridExtra_2.3                                      
 [83] DNAcopy_1.58.0                                     
 [84] edgeR_3.26.8                                       
 [85] lattice_0.20-41                                    
 [86] later_1.0.0                                        
 [87] RobustRankAggreg_1.1                               
 [88] BiocFileCache_1.10.2                               
 [89] jsonlite_1.6.1                                     
 [90] affy_1.62.0                                        
 [91] scales_1.1.1                                       
 [92] genefilter_1.68.0                                  
 [93] lazyeval_0.2.2                                     
 [94] promises_1.1.0                                     
 [95] doParallel_1.0.15                                  
 [96] latticeExtra_0.6-28                                
 [97] R.utils_2.9.0                                      
 [98] goseq_1.36.0                                       
 [99] checkmate_1.9.4                                    
[100] cowplot_1.0.0                                      
[101] rmarkdown_2.1                                      
[102] nor1mix_1.3-0                                      
[103] statmod_1.4.32                                     
[104] siggenes_1.60.0                                    
[105] dichromat_2.0-0                                    
[106] BSgenome_1.52.0                                    
[107] HDF5Array_1.14.4                                   
[108] bsseq_1.22.0                                       
[109] survival_2.44-1.1                                  
[110] yaml_2.2.1                                         
[111] htmltools_0.4.0                                    
[112] memoise_1.1.0                                      
[113] VariantAnnotation_1.30.1                           
[114] graphlayouts_0.5.0                                 
[115] quadprog_1.5-8                                     
[116] viridisLite_0.3.0                                  
[117] digest_0.6.25                                      
[118] assertthat_0.2.1                                   
[119] mime_0.9                                           
[120] rappdirs_0.3.1                                     
[121] registry_0.5-1                                     
[122] BiasedUrn_1.07                                     
[123] RSQLite_2.1.2                                      
[124] data.table_1.12.8                                  
[125] blob_1.2.0                                         
[126] R.oo_1.22.0                                        
[127] preprocessCore_1.48.0                              
[128] labeling_0.3                                       
[129] fastICA_1.2-2                                      
[130] shinythemes_1.1.2                                  
[131] splines_3.6.1                                      
[132] Formula_1.2-3                                      
[133] Rhdf5lib_1.6.1                                     
[134] illuminaio_0.28.0                                  
[135] AnnotationHub_2.18.0                               
[136] ProtGenerics_1.16.0                                
[137] RCurl_1.95-4.12                                    
[138] broom_0.5.2                                        
[139] hms_0.5.3                                          
[140] modelr_0.1.7                                       
[141] rhdf5_2.30.1                                       
[142] colorspace_1.4-1                                   
[143] base64enc_0.1-3                                    
[144] BiocManager_1.30.10                                
[145] nnet_7.3-12                                        
[146] GEOquery_2.54.1                                    
[147] Rcpp_1.0.4.6                                       
[148] mclust_5.4.6                                       
[149] enrichplot_1.4.0                                   
[150] fansi_0.4.1                                        
[151] R6_2.4.1                                           
[152] grid_3.6.1                                         
[153] ggridges_0.5.1                                     
[154] lifecycle_0.2.0                                    
[155] acepack_1.4.1                                      
[156] curl_4.3                                           
[157] kpmt_0.1.0                                         
[158] affyio_1.54.0                                      
[159] RPMM_1.25                                          
[160] DO.db_2.9                                          
[161] qvalue_2.16.0                                      
[162] ROC_1.62.0                                         
[163] RColorBrewer_1.1-2                                 
[164] IlluminaHumanMethylationEPICanno.ilm10b2.hg19_0.6.0
[165] IlluminaHumanMethylation450kmanifest_0.4.0         
[166] htmlwidgets_1.3                                    
[167] triebeard_0.3.0                                    
[168] polyclip_1.10-0                                    
[169] biomaRt_2.42.1                                     
[170] gridGraphics_0.4-1                                 
[171] reactome.db_1.70.0                                 
[172] rvest_0.3.5                                        
[173] mgcv_1.8-29                                        
[174] openssl_1.4.1                                      
[175] htmlTable_1.13.2                                   
[176] codetools_0.2-16                                   
[177] IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.0 
[178] lubridate_1.7.4                                    
[179] GO.db_3.8.2                                        
[180] gtools_3.8.1                                       
[181] prettyunits_1.0.2                                  
[182] dbplyr_1.4.2                                       
[183] R.methodsS3_1.7.1                                  
[184] gtable_0.3.0                                       
[185] DBI_1.0.0                                          
[186] git2r_0.27.1                                       
[187] wateRmelon_1.30.0                                  
[188] httr_1.4.1                                         
[189] KernSmooth_2.23-15                                 
[190] stringi_1.4.6                                      
[191] progress_1.2.2                                     
[192] farver_2.0.3                                       
[193] annotate_1.62.0                                    
[194] viridis_0.5.1                                      
[195] xml2_1.3.2                                         
[196] combinat_0.0-8                                     
[197] rvcheck_0.1.5                                      
[198] ggplotify_0.0.4                                    
[199] BiocVersion_3.10.1                                 
[200] bit_1.1-14                                         
[201] ggraph_2.0.0                                       
[202] pkgconfig_2.0.3                                    
[203] ruv_0.9.7.1                                        
[204] knitr_1.28