Source: https://github.com/markziemann/background

library("parallel")
library("edgeR")
library("DESeq2")
library("limma")
library("stringi")
library("kableExtra")
library("fgsea")
library("clusterProfiler")
source("simpw_func.R")

Intro

TODO

xxx object slots

  1. expression counts

  2. ground truth up genes

  3. ground truth down genes

  4. ground truth up gene sets

  5. ground truth down gene sets

  6. DE result (DESeq2)

  7. DE genes up observed

  8. DE genes down observed

  9. clusterprofiler_default up gene sets

  10. clusterprofiler_default down gene sets

  11. clusterprofiler bg fix up gene sets

  12. clusterprofiler bg fix down gene sets

  13. clusterprofiler FDR fix up gene sets

  14. clusterprofiler FDR fix down gene sets

  15. clusterprofiler BG and FDR fix up gene sets

  16. clusterprofiler BG and FDR fix down gene sets

  17. fora up gene sets

  18. fora down gene sets

  19. fgsea up gene sets

  20. fgsea down gene sets

Get count data

a <- countData()

Generate gene sets

gsets <- randomGeneSets(a,setsize=30,nsets=200)

run simulations over a range of parameters

SIMS=1000
#run 500 sims
FRAC_DE=0.05
FC=0.5
N_REPS=3
DGE_FUNC="deseq2"
SUM_COUNT=2e7
VARIANCE=c(0,0.1,0.2,0.3,0.4,0.5,0.6)

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 0.5      3   deseq2     2e+07      0.0
## 2    0.05 0.5      3   deseq2     2e+07      0.1
## 3    0.05 0.5      3   deseq2     2e+07      0.2
## 4    0.05 0.5      3   deseq2     2e+07      0.3
## 5    0.05 0.5      3   deseq2     2e+07      0.4
## 6    0.05 0.5      3   deseq2     2e+07      0.5
## 7    0.05 0.5      3   deseq2     2e+07      0.6

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,cores=32)
  as.data.frame(do.call(rbind, x))
})

res <- do.call(rbind,res)

saveRDS(res,file="res.Rds")

Now show the results.

res %>% kbl(caption="simulation_results") %>% kable_paper("hover", full_width = F)
simulation_results
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.838 0.228 18379.09 0.162 0.9773495 0.9838 0.9805641 clusterProfiler default
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.876 0.423 18378.90 0.124 0.9589281 0.9876 0.9730529 clusterProfiler BG fix
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.576 0.019 18379.30 0.424 0.9980198 0.9576 0.9773922 clusterProfiler FDR fix
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.823 0.277 18379.04 0.177 0.9725743 0.9823 0.9774129 clusterProfiler BG and FDR fix
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.823 0.277 18379.04 0.177 0.9725743 0.9823 0.9774129 fora
3 2e+07 0.0 0.05 0.5 1000 deseq2 9.903 0.667 18378.65 0.097 0.9368969 0.9903 0.9628585 fgsea
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.634 0.280 18370.01 0.366 0.9717571 0.9634 0.9675605 clusterProfiler default
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.691 0.414 18369.88 0.309 0.9590302 0.9691 0.9640388 clusterProfiler BG fix
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.132 0.025 18370.26 0.868 0.9972698 0.9132 0.9533852 clusterProfiler FDR fix
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.567 0.270 18370.02 0.433 0.9725526 0.9567 0.9645612 clusterProfiler BG and FDR fix
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.567 0.270 18370.02 0.433 0.9725526 0.9567 0.9645612 fora
3 2e+07 0.1 0.05 0.5 1000 deseq2 9.932 0.557 18369.73 0.068 0.9468967 0.9932 0.9694958 fgsea
3 2e+07 0.2 0.05 0.5 1000 deseq2 8.342 0.364 18347.47 1.658 0.9581898 0.8342 0.8919063 clusterProfiler default
3 2e+07 0.2 0.05 0.5 1000 deseq2 8.486 0.463 18347.37 1.514 0.9482624 0.8486 0.8956673 clusterProfiler BG fix
3 2e+07 0.2 0.05 0.5 1000 deseq2 6.826 0.027 18347.81 3.174 0.9960601 0.6826 0.8100635 clusterProfiler FDR fix
3 2e+07 0.2 0.05 0.5 1000 deseq2 7.646 0.237 18347.60 2.354 0.9699353 0.7646 0.8551138 clusterProfiler BG and FDR fix
3 2e+07 0.2 0.05 0.5 1000 deseq2 7.646 0.237 18347.60 2.354 0.9699353 0.7646 0.8551138 fora
3 2e+07 0.2 0.05 0.5 1000 deseq2 9.731 0.548 18347.29 0.269 0.9466874 0.9731 0.9597120 fgsea
3 2e+07 0.3 0.05 0.5 1000 deseq2 4.934 0.373 18312.38 5.066 0.9297155 0.4934 0.6446724 clusterProfiler default
3 2e+07 0.3 0.05 0.5 1000 deseq2 5.279 0.467 18312.29 4.721 0.9187261 0.5279 0.6705195 clusterProfiler BG fix
3 2e+07 0.3 0.05 0.5 1000 deseq2 3.093 0.021 18312.73 6.907 0.9932563 0.3093 0.4717096 clusterProfiler FDR fix
3 2e+07 0.3 0.05 0.5 1000 deseq2 3.351 0.067 18312.69 6.649 0.9803979 0.3351 0.4994783 clusterProfiler BG and FDR fix
3 2e+07 0.3 0.05 0.5 1000 deseq2 3.351 0.067 18312.69 6.649 0.9803979 0.3351 0.4994783 fora
3 2e+07 0.3 0.05 0.5 1000 deseq2 8.883 0.523 18312.23 1.117 0.9443972 0.8883 0.9154901 fgsea
3 2e+07 0.4 0.05 0.5 1000 deseq2 1.995 0.285 18260.08 8.005 0.8750000 0.1995 0.3249186 clusterProfiler default
3 2e+07 0.4 0.05 0.5 1000 deseq2 2.351 0.393 18259.97 7.649 0.8567784 0.2351 0.3689579 clusterProfiler BG fix
3 2e+07 0.4 0.05 0.5 1000 deseq2 0.931 0.018 18260.35 9.069 0.9810327 0.0931 0.1700612 clusterProfiler FDR fix
3 2e+07 0.4 0.05 0.5 1000 deseq2 1.001 0.026 18260.34 8.999 0.9746835 0.1001 0.1815544 clusterProfiler BG and FDR fix
3 2e+07 0.4 0.05 0.5 1000 deseq2 1.001 0.026 18260.34 8.999 0.9746835 0.1001 0.1815544 fora
3 2e+07 0.4 0.05 0.5 1000 deseq2 6.893 0.439 18259.93 3.107 0.9401255 0.6893 0.7954073 fgsea
3 2e+07 0.5 0.05 0.5 1000 deseq2 0.601 0.249 18198.30 9.399 0.7070588 0.0601 0.1107834 clusterProfiler default
3 2e+07 0.5 0.05 0.5 1000 deseq2 0.686 0.320 18198.23 9.314 0.6819085 0.0686 0.1246593 clusterProfiler BG fix
3 2e+07 0.5 0.05 0.5 1000 deseq2 0.229 0.029 18198.52 9.771 0.8875969 0.0229 0.0446481 clusterProfiler FDR fix
3 2e+07 0.5 0.05 0.5 1000 deseq2 0.235 0.030 18198.52 9.765 0.8867925 0.0235 0.0457867 clusterProfiler BG and FDR fix
3 2e+07 0.5 0.05 0.5 1000 deseq2 0.235 0.030 18198.52 9.765 0.8867925 0.0235 0.0457867 fora
3 2e+07 0.5 0.05 0.5 1000 deseq2 4.055 0.288 18198.26 5.945 0.9336864 0.4055 0.5654326 fgsea
3 2e+07 0.6 0.05 0.5 1000 deseq2 0.321 0.223 18106.87 9.679 0.5900735 0.0321 0.0608877 clusterProfiler default
3 2e+07 0.6 0.05 0.5 1000 deseq2 0.384 0.290 18106.81 9.616 0.5697329 0.0384 0.0719505 clusterProfiler BG fix
3 2e+07 0.6 0.05 0.5 1000 deseq2 0.088 0.019 18107.08 9.912 0.8224299 0.0088 0.0174137 clusterProfiler FDR fix
3 2e+07 0.6 0.05 0.5 1000 deseq2 0.092 0.020 18107.08 9.908 0.8214286 0.0092 0.0181962 clusterProfiler BG and FDR fix
3 2e+07 0.6 0.05 0.5 1000 deseq2 0.092 0.020 18107.08 9.908 0.8214286 0.0092 0.0181962 fora
3 2e+07 0.6 0.05 0.5 1000 deseq2 1.935 0.197 18106.90 8.065 0.9075985 0.1935 0.3189911 fgsea

Plot

fig1_ORAjac.png

cp <- subset(res,PWAY_FUNC == "clusterProfiler default")
cpbg <- subset(res,PWAY_FUNC == "clusterProfiler BG fix")
cpfdr <- subset(res,PWAY_FUNC == "clusterProfiler FDR fix")
cpbgfdr <- subset(res,PWAY_FUNC == "clusterProfiler BG and FDR fix")
fo <- subset(res,PWAY_FUNC == "fora")
fg <- subset(res,PWAY_FUNC == "fgsea")

cp %>% kbl(caption="clusterProfiler") %>% kable_paper("hover", full_width = F)
clusterProfiler
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
1 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.838 0.228 18379.09 0.162 0.9773495 0.9838 0.9805641 clusterProfiler default
7 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.634 0.280 18370.01 0.366 0.9717571 0.9634 0.9675605 clusterProfiler default
13 3 2e+07 0.2 0.05 0.5 1000 deseq2 8.342 0.364 18347.47 1.658 0.9581898 0.8342 0.8919063 clusterProfiler default
19 3 2e+07 0.3 0.05 0.5 1000 deseq2 4.934 0.373 18312.38 5.066 0.9297155 0.4934 0.6446724 clusterProfiler default
25 3 2e+07 0.4 0.05 0.5 1000 deseq2 1.995 0.285 18260.08 8.005 0.8750000 0.1995 0.3249186 clusterProfiler default
31 3 2e+07 0.5 0.05 0.5 1000 deseq2 0.601 0.249 18198.30 9.399 0.7070588 0.0601 0.1107834 clusterProfiler default
37 3 2e+07 0.6 0.05 0.5 1000 deseq2 0.321 0.223 18106.87 9.679 0.5900735 0.0321 0.0608877 clusterProfiler default
cpbg %>% kbl(caption="clusterProfiler with background bug fix") %>% kable_paper("hover", full_width = F)
clusterProfiler with background bug fix
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
2 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.876 0.423 18378.90 0.124 0.9589281 0.9876 0.9730529 clusterProfiler BG fix
8 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.691 0.414 18369.88 0.309 0.9590302 0.9691 0.9640388 clusterProfiler BG fix
14 3 2e+07 0.2 0.05 0.5 1000 deseq2 8.486 0.463 18347.37 1.514 0.9482624 0.8486 0.8956673 clusterProfiler BG fix
20 3 2e+07 0.3 0.05 0.5 1000 deseq2 5.279 0.467 18312.29 4.721 0.9187261 0.5279 0.6705195 clusterProfiler BG fix
26 3 2e+07 0.4 0.05 0.5 1000 deseq2 2.351 0.393 18259.97 7.649 0.8567784 0.2351 0.3689579 clusterProfiler BG fix
32 3 2e+07 0.5 0.05 0.5 1000 deseq2 0.686 0.320 18198.23 9.314 0.6819085 0.0686 0.1246593 clusterProfiler BG fix
38 3 2e+07 0.6 0.05 0.5 1000 deseq2 0.384 0.290 18106.81 9.616 0.5697329 0.0384 0.0719505 clusterProfiler BG fix
cpfdr %>% kbl(caption="clusterProfiler with FDR bug fix") %>% kable_paper("hover", full_width = F)
clusterProfiler with FDR bug fix
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
3 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.576 0.019 18379.30 0.424 0.9980198 0.9576 0.9773922 clusterProfiler FDR fix
9 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.132 0.025 18370.26 0.868 0.9972698 0.9132 0.9533852 clusterProfiler FDR fix
15 3 2e+07 0.2 0.05 0.5 1000 deseq2 6.826 0.027 18347.81 3.174 0.9960601 0.6826 0.8100635 clusterProfiler FDR fix
21 3 2e+07 0.3 0.05 0.5 1000 deseq2 3.093 0.021 18312.73 6.907 0.9932563 0.3093 0.4717096 clusterProfiler FDR fix
27 3 2e+07 0.4 0.05 0.5 1000 deseq2 0.931 0.018 18260.35 9.069 0.9810327 0.0931 0.1700612 clusterProfiler FDR fix
33 3 2e+07 0.5 0.05 0.5 1000 deseq2 0.229 0.029 18198.52 9.771 0.8875969 0.0229 0.0446481 clusterProfiler FDR fix
39 3 2e+07 0.6 0.05 0.5 1000 deseq2 0.088 0.019 18107.08 9.912 0.8224299 0.0088 0.0174137 clusterProfiler FDR fix
cpbgfdr %>% kbl(caption="clusterProfiler with background and FDR fixes") %>% kable_paper("hover", full_width = F)
clusterProfiler with background and FDR fixes
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 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.823 0.277 18379.04 0.177 0.9725743 0.9823 0.9774129 clusterProfiler BG and FDR fix
10 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.567 0.270 18370.02 0.433 0.9725526 0.9567 0.9645612 clusterProfiler BG and FDR fix
16 3 2e+07 0.2 0.05 0.5 1000 deseq2 7.646 0.237 18347.60 2.354 0.9699353 0.7646 0.8551138 clusterProfiler BG and FDR fix
22 3 2e+07 0.3 0.05 0.5 1000 deseq2 3.351 0.067 18312.69 6.649 0.9803979 0.3351 0.4994783 clusterProfiler BG and FDR fix
28 3 2e+07 0.4 0.05 0.5 1000 deseq2 1.001 0.026 18260.34 8.999 0.9746835 0.1001 0.1815544 clusterProfiler BG and FDR fix
34 3 2e+07 0.5 0.05 0.5 1000 deseq2 0.235 0.030 18198.52 9.765 0.8867925 0.0235 0.0457867 clusterProfiler BG and FDR fix
40 3 2e+07 0.6 0.05 0.5 1000 deseq2 0.092 0.020 18107.08 9.908 0.8214286 0.0092 0.0181962 clusterProfiler BG and FDR fix
fo %>% kbl(caption="fora") %>% kable_paper("hover", full_width = F)
fora
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
5 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.823 0.277 18379.04 0.177 0.9725743 0.9823 0.9774129 fora
11 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.567 0.270 18370.02 0.433 0.9725526 0.9567 0.9645612 fora
17 3 2e+07 0.2 0.05 0.5 1000 deseq2 7.646 0.237 18347.60 2.354 0.9699353 0.7646 0.8551138 fora
23 3 2e+07 0.3 0.05 0.5 1000 deseq2 3.351 0.067 18312.69 6.649 0.9803979 0.3351 0.4994783 fora
29 3 2e+07 0.4 0.05 0.5 1000 deseq2 1.001 0.026 18260.34 8.999 0.9746835 0.1001 0.1815544 fora
35 3 2e+07 0.5 0.05 0.5 1000 deseq2 0.235 0.030 18198.52 9.765 0.8867925 0.0235 0.0457867 fora
41 3 2e+07 0.6 0.05 0.5 1000 deseq2 0.092 0.020 18107.08 9.908 0.8214286 0.0092 0.0181962 fora
fg %>% kbl(caption="fg") %>% kable_paper("hover", full_width = F)
fg
N_REPS SUM_COUNT VARIANCE FRAC_DE FC SIMS DGE_FUNC true_pos false_pos true_neg false_neg p r f PWAY_FUNC
6 3 2e+07 0.0 0.05 0.5 1000 deseq2 9.903 0.667 18378.65 0.097 0.9368969 0.9903 0.9628585 fgsea
12 3 2e+07 0.1 0.05 0.5 1000 deseq2 9.932 0.557 18369.73 0.068 0.9468967 0.9932 0.9694958 fgsea
18 3 2e+07 0.2 0.05 0.5 1000 deseq2 9.731 0.548 18347.29 0.269 0.9466874 0.9731 0.9597120 fgsea
24 3 2e+07 0.3 0.05 0.5 1000 deseq2 8.883 0.523 18312.23 1.117 0.9443972 0.8883 0.9154901 fgsea
30 3 2e+07 0.4 0.05 0.5 1000 deseq2 6.893 0.439 18259.93 3.107 0.9401255 0.6893 0.7954073 fgsea
36 3 2e+07 0.5 0.05 0.5 1000 deseq2 4.055 0.288 18198.26 5.945 0.9336864 0.4055 0.5654326 fgsea
42 3 2e+07 0.6 0.05 0.5 1000 deseq2 1.935 0.197 18106.90 8.065 0.9075985 0.1935 0.3189911 fgsea
par(mfrow=c(1,3))
par(mar=c(c(5.1, 5.1, 2.1, 2.1) ))

plot(cp$VARIANCE,cp$p,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="precision")
points(cpbg$VARIANCE,cpbg$p,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$p,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$p,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$p,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$p,type="b",pch=19,col="blue")

legend("bottomleft", inset=.02, title="tool",
   c("CP default","CP BG fix","CP FDR fix","CP BG and FDR fix","fora","fgsea"),
   col=c("black","orange","darkgreen","purple","red","blue"),horiz=FALSE, cex=1.2, pch=19,lwd=2)

plot(cp$VARIANCE,cp$r,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="recall")
points(cpbg$VARIANCE,cpbg$r,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$r,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$r,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$r,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$r,type="b",pch=19,col="blue")

plot(cp$VARIANCE,cp$f,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="f1")
points(cpbg$VARIANCE,cpbg$f,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$f,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$f,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$f,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$f,type="b",pch=19,col="blue")

png("fig3_sim.png", width=7,height=5,units="in",res=150,pointsize=12)
par(mar=c(c(5.1, 5.1, 2.1, 2.1) ))
par(mfrow=c(1,3))

plot(cp$VARIANCE,cp$p,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="precision")
points(cpbg$VARIANCE,cpbg$p,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$p,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$p,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$p,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$p,type="b",pch=19,col="blue")
grid()
legend("bottomleft", inset=.02, title="tool",
   c("CP default","CP BG fix","CP FDR fix","CP BG and FDR fix","fora","fgsea"),
   col=c("black","orange","darkgreen","purple","red","blue"),
   horiz=FALSE, cex=1.2, pch=19,lwd=2)

plot(cp$VARIANCE,cp$r,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="recall")
points(cpbg$VARIANCE,cpbg$r,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$r,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$r,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$r,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$r,type="b",pch=19,col="blue")
grid()

plot(cp$VARIANCE,cp$f,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="f1")
points(cpbg$VARIANCE,cpbg$f,type="b",pch=19,col="orange")
points(cpfdr$VARIANCE,cpfdr$f,type="b",pch=19,col="darkgreen")
points(cpbgfdr$VARIANCE,cpbgfdr$f,type="b",pch=19,col="purple")
points(fo$VARIANCE,fo$f,type="b",pch=19,col="red")
points(fg$VARIANCE,fg$f,type="b",pch=19,col="blue")
grid()
dev.off()
## png 
##   2

Barplot is simpler.

prec <- c("CP default"=mean(cp$p),"CP BG fix"=mean(cpbg$p),"CP FDR fix"=mean(cpfdr$p),"CP BG and FDR fix"=mean(cpbgfdr$p),"fora"=mean(fo$p),"fgsea"=mean(fg$p))
rec <- c("CP default"=mean(cp$r),"CP BG fix"=mean(cpbg$r),"CP FDR fix"=mean(cpfdr$r),"CP BG and FDR fix"=mean(cpbgfdr$r),"fora"=mean(fo$r),"fgsea"=mean(fg$r))
f1 <- sapply(1:length(prec), function(i) { 2/(1/rec[i]+1/prec[i]) })

par(mfrow=c(1,3))
par(mar=c(c(9.1, 3.5, 2.1, 1.1) ))
barplot(prec,ylim=c(0,1.1),las=2,main="precision",ylab="index")
text((1:6*1.18)-0.38,prec+0.02,labels=signif(prec,3))
barplot(rec,ylim=c(0,1.1),las=2,main="recall",ylab="index")
text((1:6*1.18)-0.38,rec+0.02,labels=signif(rec,3))

barplot(f1,ylim=c(0,1.1),las=2,main="F1",ylab="index")
text((1:6*1.18)-0.38,f1+0.02,labels=signif(f1,3))

Session information

sessionInfo()
## R version 4.4.0 (2024-04-24)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 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_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       
## 
## 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] mitch_1.16.0                clusterProfiler_4.12.0     
##  [3] fgsea_1.30.0                kableExtra_1.4.0           
##  [5] stringi_1.8.4               DESeq2_1.44.0              
##  [7] SummarizedExperiment_1.34.0 Biobase_2.64.0             
##  [9] MatrixGenerics_1.16.0       matrixStats_1.3.0          
## [11] GenomicRanges_1.56.0        GenomeInfoDb_1.40.0        
## [13] IRanges_2.38.0              S4Vectors_0.42.0           
## [15] BiocGenerics_0.50.0         edgeR_4.2.0                
## [17] limma_3.60.0               
## 
## loaded via a namespace (and not attached):
##   [1] RColorBrewer_1.1-3      rstudioapi_0.16.0       jsonlite_1.8.8         
##   [4] magrittr_2.0.3          farver_2.1.2            rmarkdown_2.27         
##   [7] fs_1.6.4                zlibbioc_1.50.0         vctrs_0.6.5            
##  [10] memoise_2.0.1.9000      ggtree_3.12.0           htmltools_0.5.8.1      
##  [13] S4Arrays_1.4.0          SparseArray_1.4.3       gridGraphics_0.5-1     
##  [16] sass_0.4.9              KernSmooth_2.23-24      bslib_0.7.0            
##  [19] htmlwidgets_1.6.4       echarts4r_0.4.5         plyr_1.8.9             
##  [22] cachem_1.1.0            igraph_2.0.3            mime_0.12              
##  [25] lifecycle_1.0.4         pkgconfig_2.0.3         gson_0.1.0             
##  [28] Matrix_1.7-0            R6_2.5.1                fastmap_1.2.0          
##  [31] shiny_1.8.1.1           GenomeInfoDbData_1.2.12 digest_0.6.35          
##  [34] aplot_0.2.2             enrichplot_1.24.0       GGally_2.2.1           
##  [37] colorspace_2.1-0        patchwork_1.2.0         AnnotationDbi_1.66.0   
##  [40] RSQLite_2.3.7           fansi_1.0.6             httr_1.4.7             
##  [43] polyclip_1.10-6         abind_1.4-5             compiler_4.4.0         
##  [46] bit64_4.0.5             withr_3.0.0             BiocParallel_1.38.0    
##  [49] viridis_0.6.5           DBI_1.2.3               ggstats_0.6.0          
##  [52] highr_0.11              gplots_3.1.3.1          ggforce_0.4.2          
##  [55] MASS_7.3-60.2           DelayedArray_0.30.1     HDO.db_0.99.1          
##  [58] caTools_1.18.2          gtools_3.9.5            tools_4.4.0            
##  [61] beeswarm_0.4.0          scatterpie_0.2.2        ape_5.8                
##  [64] httpuv_1.6.15           glue_1.7.0              promises_1.3.0         
##  [67] nlme_3.1-164            GOSemSim_2.30.0         shadowtext_0.1.3       
##  [70] grid_4.4.0              reshape2_1.4.4          generics_0.1.3         
##  [73] gtable_0.3.5            tidyr_1.3.1             data.table_1.15.4      
##  [76] tidygraph_1.3.1         xml2_1.3.6              utf8_1.2.4             
##  [79] XVector_0.44.0          ggrepel_0.9.5           pillar_1.9.0           
##  [82] stringr_1.5.1           yulab.utils_0.1.4       later_1.3.2            
##  [85] splines_4.4.0           dplyr_1.1.4             tweenr_2.0.3           
##  [88] treeio_1.28.0           lattice_0.22-6          bit_4.0.5              
##  [91] tidyselect_1.2.1        GO.db_3.19.1            locfit_1.5-9.9         
##  [94] Biostrings_2.72.0       knitr_1.47              gridExtra_2.3          
##  [97] svglite_2.1.3           xfun_0.44               graphlayouts_1.1.1     
## [100] statmod_1.5.0           UCSC.utils_1.0.0        lazyeval_0.2.2         
## [103] ggfun_0.1.5             yaml_2.3.8              evaluate_0.23          
## [106] codetools_0.2-20        ggraph_2.2.1            tibble_3.2.1           
## [109] qvalue_2.36.0           ggplotify_0.1.2         cli_3.6.2              
## [112] xtable_1.8-4            systemfonts_1.1.0       munsell_0.5.1          
## [115] jquerylib_0.1.4         Rcpp_1.0.12             png_0.1-8              
## [118] ggplot2_3.5.1           blob_1.2.4              DOSE_3.30.1            
## [121] bitops_1.0-7            viridisLite_0.4.2       tidytree_0.4.6         
## [124] scales_1.3.0            purrr_1.0.2             crayon_1.5.2           
## [127] rlang_1.1.4             cowplot_1.1.3           fastmatch_1.1-4        
## [130] KEGGREST_1.44.0