Source: https://github.com/markziemann/background
library("tidyverse")
library("parallel")
library("edgeR")
library("DESeq2")
library("limma")
library("stringi")
library("kableExtra")
source("simpw_func.R")
TODO
xxx object slots
expression counts
ground truth up genes
ground truth down genes
ground truth up gene sets
ground truth down gene sets
DE result (DESeq2)
DE genes up observed
DE genes down observed
fgsea up gene sets
fgsea down gene sets
phyper up gene sets
phyper down gene sets
clusterprofiler_default up gene sets
clusterprofiler_default down gene sets
clusterprofiler_fixed up gene sets
clusterprofiler_fixed down gene sets
clusterprofiler_nobg up gene sets
clusterprofiler_nobg down gene sets
fisher up gene sets
fisher down gene sets
DOSE up gene sets
DOSE down gene sets
a<-countData()
gsets<-randomGeneSets(a,setsize=50,nsets=500)
SIMS=8
FRAC_DE=0.05
FC=1
N_REPS=4
DGE_FUNC="deseq2"
SUM_COUNT=3e7
VARIANCE=c(0.25,0.3,0.35,0.4,0.45)
mygrid <- expand.grid(FRAC_DE,FC,N_REPS,DGE_FUNC,SUM_COUNT,VARIANCE)
colnames(mygrid) <- c("FRAC_DE","FC","N_REPS","DGE_FUNC","SUM_COUNT","VARIANCE")
mygrid
## FRAC_DE FC N_REPS DGE_FUNC SUM_COUNT VARIANCE
## 1 0.05 1 4 deseq2 3e+07 0.25
## 2 0.05 1 4 deseq2 3e+07 0.30
## 3 0.05 1 4 deseq2 3e+07 0.35
## 4 0.05 1 4 deseq2 3e+07 0.40
## 5 0.05 1 4 deseq2 3e+07 0.45
Now run the analysis.
res <- lapply(1:nrow(mygrid), function(i) {
FRAC_DE=mygrid[i,"FRAC_DE"]
FC=mygrid[i,"FC"]
N_REPS=mygrid[i,"N_REPS"]
DGE_FUNC=as.character(mygrid[i,"DGE_FUNC"])
SUM_COUNT=mygrid[i,"SUM_COUNT"]
VARIANCE=mygrid[i,"VARIANCE"]
x <- agg_dge(a,N_REPS,SUM_COUNT,VARIANCE,FRAC_DE,FC,SIMS,DGE_FUNC,gsets)
as.data.frame(do.call(rbind, x))
})
res <- do.call(rbind,res)
Now show the results.
res %>% kbl(caption="simulation_results") %>% kable_paper("hover", full_width = F)
N_REPS | SUM_COUNT | VARIANCE | FRAC_DE | FC | SIMS | DGE_FUNC | true_pos | false_pos | true_neg | false_neg | p | r | f | PWAY_FUNC |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19280.75 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | clusterprofiler_default |
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 2.250 | 19278.62 | 0.000 | 0.9142857 | 1.0000000 | 0.9552239 | clusterprofiler_fixed |
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19280.75 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | clusterprofiler_nobg |
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.000 | 19280.88 | 0.000 | 1.0000000 | 1.0000000 | 1.0000000 | phyper_res |
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 1.250 | 19279.62 | 0.000 | 0.9504950 | 1.0000000 | 0.9746193 | fgsea_res |
4 | 3e+07 | 0.25 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.250 | 19280.62 | 0.000 | 0.9896907 | 1.0000000 | 0.9948187 | fisher_res |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19260.12 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | clusterprofiler_default |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 3.250 | 19257.00 | 0.000 | 0.8807339 | 1.0000000 | 0.9365854 | clusterprofiler_fixed |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19260.12 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | clusterprofiler_nobg |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19260.12 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | phyper_res |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 2.375 | 19257.88 | 0.000 | 0.9099526 | 1.0000000 | 0.9528536 | fgsea_res |
4 | 3e+07 | 0.30 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.125 | 19260.12 | 0.000 | 0.9948187 | 1.0000000 | 0.9974026 | fisher_res |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.500 | 19242.25 | 0.000 | 0.9795918 | 1.0000000 | 0.9896907 | clusterprofiler_default |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 24.000 | 2.500 | 19240.25 | 0.000 | 0.9056604 | 1.0000000 | 0.9504950 | clusterprofiler_fixed |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 24.000 | 0.500 | 19242.25 | 0.000 | 0.9795918 | 1.0000000 | 0.9896907 | clusterprofiler_nobg |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 23.750 | 0.250 | 19242.50 | 0.250 | 0.9895833 | 0.9895833 | 0.9895833 | phyper_res |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 24.000 | 1.000 | 19241.75 | 0.000 | 0.9600000 | 1.0000000 | 0.9795918 | fgsea_res |
4 | 3e+07 | 0.35 | 0.05 | 1 | 8 | deseq2 | 23.875 | 0.375 | 19242.38 | 0.125 | 0.9845361 | 0.9947917 | 0.9896373 | fisher_res |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 14.125 | 9.875 | 19195.00 | 9.875 | 0.5885417 | 0.5885417 | 0.5885417 | clusterprofiler_default |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 16.750 | 27.750 | 19177.12 | 7.250 | 0.3764045 | 0.6979167 | 0.4890511 | clusterprofiler_fixed |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 14.125 | 9.875 | 19195.00 | 9.875 | 0.5885417 | 0.5885417 | 0.5885417 | clusterprofiler_nobg |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 4.625 | 0.000 | 19204.88 | 19.375 | 1.0000000 | 0.1927083 | 0.3231441 | phyper_res |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 24.000 | 1.250 | 19203.62 | 0.000 | 0.9504950 | 1.0000000 | 0.9746193 | fgsea_res |
4 | 3e+07 | 0.40 | 0.05 | 1 | 8 | deseq2 | 7.000 | 0.125 | 19204.75 | 17.000 | 0.9824561 | 0.2916667 | 0.4497992 | fisher_res |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 13.500 | 19.000 | 19156.50 | 10.500 | 0.4153846 | 0.5625000 | 0.4778761 | clusterprofiler_default |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 13.750 | 21.625 | 19153.88 | 10.250 | 0.3886926 | 0.5729167 | 0.4631579 | clusterprofiler_fixed |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 13.500 | 19.000 | 19156.50 | 10.500 | 0.4153846 | 0.5625000 | 0.4778761 | clusterprofiler_nobg |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 2.625 | 0.125 | 19175.38 | 21.375 | 0.9545455 | 0.1093750 | 0.1962617 | phyper_res |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 24.000 | 2.375 | 19173.12 | 0.000 | 0.9099526 | 1.0000000 | 0.9528536 | fgsea_res |
4 | 3e+07 | 0.45 | 0.05 | 1 | 8 | deseq2 | 4.500 | 0.125 | 19175.38 | 19.500 | 0.9729730 | 0.1875000 | 0.3144105 | fisher_res |
sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
##
## 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
##
## time zone: Australia/Melbourne
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 parallel stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] kableExtra_1.3.4 clusterProfiler_4.8.3
## [3] fgsea_1.26.0 mitch_1.12.0
## [5] stringi_1.7.12 DESeq2_1.40.2
## [7] SummarizedExperiment_1.30.2 Biobase_2.60.0
## [9] MatrixGenerics_1.12.3 matrixStats_1.0.0
## [11] GenomicRanges_1.52.0 GenomeInfoDb_1.36.2
## [13] IRanges_2.34.1 S4Vectors_0.38.1
## [15] BiocGenerics_0.46.0 edgeR_3.42.4
## [17] limma_3.56.2 lubridate_1.9.2
## [19] forcats_1.0.0 stringr_1.5.0
## [21] dplyr_1.1.3 purrr_1.0.2
## [23] readr_2.1.4 tidyr_1.3.0
## [25] tibble_3.2.1 ggplot2_3.4.3
## [27] tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] RColorBrewer_1.1-3 rstudioapi_0.15.0 jsonlite_1.8.7
## [4] magrittr_2.0.3 farver_2.1.1 rmarkdown_2.24
## [7] zlibbioc_1.46.0 vctrs_0.6.3 memoise_2.0.1
## [10] RCurl_1.98-1.12 ggtree_3.8.2 webshot_0.5.5
## [13] htmltools_0.5.6 S4Arrays_1.0.6 gridGraphics_0.5-1
## [16] sass_0.4.7 KernSmooth_2.23-22 bslib_0.5.1
## [19] htmlwidgets_1.6.2 plyr_1.8.8 echarts4r_0.4.5
## [22] cachem_1.0.8 igraph_1.5.1 mime_0.12
## [25] lifecycle_1.0.3 pkgconfig_2.0.3 gson_0.1.0
## [28] Matrix_1.6-1 R6_2.5.1 fastmap_1.1.1
## [31] GenomeInfoDbData_1.2.10 shiny_1.7.5 aplot_0.2.0
## [34] digest_0.6.33 enrichplot_1.20.1 colorspace_2.1-0
## [37] GGally_2.1.2 reshape_0.8.9 patchwork_1.1.3
## [40] AnnotationDbi_1.62.2 RSQLite_2.3.1 fansi_1.0.4
## [43] timechange_0.2.0 polyclip_1.10-4 httr_1.4.7
## [46] abind_1.4-5 compiler_4.3.1 bit64_4.0.5
## [49] withr_2.5.0 downloader_0.4 BiocParallel_1.34.2
## [52] viridis_0.6.4 DBI_1.1.3 highr_0.10
## [55] ggforce_0.4.1 gplots_3.1.3 MASS_7.3-60
## [58] DelayedArray_0.26.7 HDO.db_0.99.1 gtools_3.9.4
## [61] caTools_1.18.2 tools_4.3.1 scatterpie_0.2.1
## [64] ape_5.7-1 beeswarm_0.4.0 httpuv_1.6.11
## [67] glue_1.6.2 nlme_3.1-163 GOSemSim_2.26.1
## [70] promises_1.2.1 shadowtext_0.1.2 grid_4.3.1
## [73] reshape2_1.4.4 generics_0.1.3 gtable_0.3.4
## [76] tzdb_0.4.0 data.table_1.14.8 hms_1.1.3
## [79] tidygraph_1.2.3 xml2_1.3.5 utf8_1.2.3
## [82] XVector_0.40.0 ggrepel_0.9.3 pillar_1.9.0
## [85] yulab.utils_0.0.9 later_1.3.1 splines_4.3.1
## [88] tweenr_2.0.2 treeio_1.24.3 lattice_0.21-8
## [91] bit_4.0.5 tidyselect_1.2.0 GO.db_3.17.0
## [94] locfit_1.5-9.8 Biostrings_2.68.1 knitr_1.43
## [97] gridExtra_2.3 svglite_2.1.1 xfun_0.40
## [100] graphlayouts_1.0.0 lazyeval_0.2.2 ggfun_0.1.2
## [103] yaml_2.3.7 evaluate_0.21 codetools_0.2-19
## [106] ggraph_2.1.0 qvalue_2.32.0 ggplotify_0.1.2
## [109] cli_3.6.1 xtable_1.8-4 systemfonts_1.0.4
## [112] munsell_0.5.0 jquerylib_0.1.4 Rcpp_1.0.11
## [115] png_0.1-8 ellipsis_0.3.2 blob_1.2.4
## [118] DOSE_3.26.1 bitops_1.0-7 tidytree_0.4.5
## [121] viridisLite_0.4.2 scales_1.2.1 crayon_1.5.2
## [124] rlang_1.1.1 cowplot_1.1.1 fastmatch_1.1-4
## [127] KEGGREST_1.40.0 rvest_1.0.3