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

RhpcBLASctl::blas_set_num_threads(1)

suppressPackageStartupMessages({
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. fora up gene sets 5% FDR

  10. fora down gene sets 5% FDR

  11. fora up gene sets 1% FDR

  12. fora down gene sets 1% FDR

  13. fgsea up gene sets 5% FDR

  14. fgsea down gene sets 5% FDR

  15. fgsea up gene sets 1% FDR

  16. fgsea down gene sets 1% FDR

Get count data

a <- countData()

Generate gene sets

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

run simulations over a range of parameters

SIMS=1000
FRAC_DE=0.05
FC=0.5
N_REPS=5
DGE_FUNC="deseq2"
SUM_COUNT=1e7
VARIANCE=c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0)

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      5   deseq2     1e+07      0.0
## 2     0.05 0.5      5   deseq2     1e+07      0.1
## 3     0.05 0.5      5   deseq2     1e+07      0.2
## 4     0.05 0.5      5   deseq2     1e+07      0.3
## 5     0.05 0.5      5   deseq2     1e+07      0.4
## 6     0.05 0.5      5   deseq2     1e+07      0.5
## 7     0.05 0.5      5   deseq2     1e+07      0.6
## 8     0.05 0.5      5   deseq2     1e+07      0.7
## 9     0.05 0.5      5   deseq2     1e+07      0.8
## 10    0.05 0.5      5   deseq2     1e+07      0.9
## 11    0.05 0.5      5   deseq2     1e+07      1.0

Now run the analysis.

if ( file.exists("simpw.Rds") ) {
  message("res.Rds found on disk, skipping")
} else {
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=16)
  as.data.frame(do.call(rbind, x))
})

res <- do.call(rbind,res)

saveRDS(res,file="simpw.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
5 1e+07 0.0 0.05 0.5 1000 deseq2 8.325 0.190 17119.72 1.675 0.9776864 0.8325 0.8992709 fora5
5 1e+07 0.0 0.05 0.5 1000 deseq2 7.382 0.013 17119.90 2.618 0.9982421 0.7382 0.8487496 fora1
5 1e+07 0.0 0.05 0.5 1000 deseq2 9.637 0.525 17119.39 0.363 0.9483369 0.9637 0.9559568 fgsea5
5 1e+07 0.0 0.05 0.5 1000 deseq2 9.079 0.094 17119.82 0.921 0.9897525 0.9079 0.9470610 fgsea1
5 1e+07 0.1 0.05 0.5 1000 deseq2 7.884 0.219 17111.13 2.116 0.9729730 0.7884 0.8710159 fora5
5 1e+07 0.1 0.05 0.5 1000 deseq2 6.901 0.027 17111.32 3.099 0.9961028 0.6901 0.8153355 fora1
5 1e+07 0.1 0.05 0.5 1000 deseq2 9.604 0.563 17110.79 0.396 0.9446248 0.9604 0.9524471 fgsea5
5 1e+07 0.1 0.05 0.5 1000 deseq2 8.923 0.072 17111.28 1.077 0.9919956 0.8923 0.9395104 fgsea1
5 1e+07 0.2 0.05 0.5 1000 deseq2 6.270 0.168 17091.87 3.730 0.9739049 0.6270 0.7628665 fora5
5 1e+07 0.2 0.05 0.5 1000 deseq2 5.307 0.019 17092.02 4.693 0.9964326 0.5307 0.6925486 fora1
5 1e+07 0.2 0.05 0.5 1000 deseq2 9.278 0.521 17091.52 0.722 0.9468313 0.9278 0.9372191 fgsea5
5 1e+07 0.2 0.05 0.5 1000 deseq2 8.245 0.091 17091.95 1.755 0.9890835 0.8245 0.8993237 fgsea1
5 1e+07 0.3 0.05 0.5 1000 deseq2 3.669 0.100 17054.17 6.331 0.9734678 0.3669 0.5329363 fora5
5 1e+07 0.3 0.05 0.5 1000 deseq2 2.930 0.019 17054.26 7.070 0.9935571 0.2930 0.4525446 fora1
5 1e+07 0.3 0.05 0.5 1000 deseq2 8.463 0.428 17053.85 1.537 0.9518614 0.8463 0.8959822 fgsea5
5 1e+07 0.3 0.05 0.5 1000 deseq2 6.760 0.071 17054.20 3.240 0.9896062 0.6760 0.8032797 fgsea1
5 1e+07 0.4 0.05 0.5 1000 deseq2 1.384 0.036 17002.61 8.616 0.9746479 0.1384 0.2423818 fora5
5 1e+07 0.4 0.05 0.5 1000 deseq2 0.967 0.009 17002.64 9.033 0.9907787 0.0967 0.1762026 fora1
5 1e+07 0.4 0.05 0.5 1000 deseq2 6.824 0.436 17002.21 3.176 0.9399449 0.6824 0.7907300 fgsea5
5 1e+07 0.4 0.05 0.5 1000 deseq2 4.358 0.053 17002.59 5.642 0.9879846 0.4358 0.6048158 fgsea1
5 1e+07 0.5 0.05 0.5 1000 deseq2 0.504 0.027 16942.13 9.496 0.9491525 0.0504 0.0957174 fora5
5 1e+07 0.5 0.05 0.5 1000 deseq2 0.251 0.010 16942.15 9.749 0.9616858 0.0251 0.0489231 fora1
5 1e+07 0.5 0.05 0.5 1000 deseq2 4.860 0.356 16941.81 5.140 0.9317485 0.4860 0.6388013 fgsea5
5 1e+07 0.5 0.05 0.5 1000 deseq2 2.313 0.038 16942.12 7.687 0.9838367 0.2313 0.3745446 fgsea1
5 1e+07 0.6 0.05 0.5 1000 deseq2 0.210 0.027 16826.51 9.790 0.8860759 0.0210 0.0410276 fora5
5 1e+07 0.6 0.05 0.5 1000 deseq2 0.106 0.012 16826.52 9.894 0.8983051 0.0106 0.0209528 fora1
5 1e+07 0.6 0.05 0.5 1000 deseq2 2.872 0.248 16826.29 7.128 0.9205128 0.2872 0.4378049 fgsea5
5 1e+07 0.6 0.05 0.5 1000 deseq2 1.091 0.029 16826.51 8.909 0.9741071 0.1091 0.1962230 fgsea1
5 1e+07 0.7 0.05 0.5 1000 deseq2 0.102 0.019 16510.26 9.898 0.8429752 0.0102 0.0201561 fora5
5 1e+07 0.7 0.05 0.5 1000 deseq2 0.037 0.003 16510.28 9.963 0.9250000 0.0037 0.0073705 fora1
5 1e+07 0.7 0.05 0.5 1000 deseq2 1.722 0.177 16510.10 8.278 0.9067930 0.1722 0.2894361 fgsea5
5 1e+07 0.7 0.05 0.5 1000 deseq2 0.529 0.018 16510.26 9.471 0.9670932 0.0529 0.1003129 fgsea1
5 1e+07 0.8 0.05 0.5 1000 deseq2 0.051 0.024 15836.75 9.949 0.6800000 0.0051 0.0101241 fora5
5 1e+07 0.8 0.05 0.5 1000 deseq2 0.021 0.007 15836.77 9.979 0.7500000 0.0021 0.0041883 fora1
5 1e+07 0.8 0.05 0.5 1000 deseq2 0.954 0.128 15836.65 9.046 0.8817006 0.0954 0.1721711 fgsea5
5 1e+07 0.8 0.05 0.5 1000 deseq2 0.301 0.014 15836.76 9.699 0.9555556 0.0301 0.0583616 fgsea1
5 1e+07 0.9 0.05 0.5 1000 deseq2 0.040 0.017 14776.20 9.960 0.7017544 0.0040 0.0079547 fora5
5 1e+07 0.9 0.05 0.5 1000 deseq2 0.008 0.005 14776.22 9.992 0.6153846 0.0008 0.0015979 fora1
5 1e+07 0.9 0.05 0.5 1000 deseq2 0.608 0.091 14776.13 9.392 0.8698140 0.0608 0.1136555 fgsea5
5 1e+07 0.9 0.05 0.5 1000 deseq2 0.178 0.010 14776.21 9.822 0.9468085 0.0178 0.0349431 fgsea1
5 1e+07 1.0 0.05 0.5 1000 deseq2 0.026 0.031 13415.90 9.974 0.4561404 0.0026 0.0051705 fora5
5 1e+07 1.0 0.05 0.5 1000 deseq2 0.010 0.009 13415.92 9.990 0.5263158 0.0010 0.0019962 fora1
5 1e+07 1.0 0.05 0.5 1000 deseq2 0.318 0.103 13415.83 9.682 0.7553444 0.0318 0.0610306 fgsea5
5 1e+07 1.0 0.05 0.5 1000 deseq2 0.067 0.019 13415.91 9.933 0.7790698 0.0067 0.0132857 fgsea1

Plot

fo5 <- subset(res,PWAY_FUNC == "fora5")
fo1 <- subset(res,PWAY_FUNC == "fora1")
fg5 <- subset(res,PWAY_FUNC == "fgsea5")
fg1 <- subset(res,PWAY_FUNC == "fgsea1")

fo5 %>% kbl(caption="fora 5% FDR") %>% kable_paper("hover", full_width = F)
fora 5% FDR
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 5 1e+07 0.0 0.05 0.5 1000 deseq2 8.325 0.190 17119.72 1.675 0.9776864 0.8325 0.8992709 fora5
5 5 1e+07 0.1 0.05 0.5 1000 deseq2 7.884 0.219 17111.13 2.116 0.9729730 0.7884 0.8710159 fora5
9 5 1e+07 0.2 0.05 0.5 1000 deseq2 6.270 0.168 17091.87 3.730 0.9739049 0.6270 0.7628665 fora5
13 5 1e+07 0.3 0.05 0.5 1000 deseq2 3.669 0.100 17054.17 6.331 0.9734678 0.3669 0.5329363 fora5
17 5 1e+07 0.4 0.05 0.5 1000 deseq2 1.384 0.036 17002.61 8.616 0.9746479 0.1384 0.2423818 fora5
21 5 1e+07 0.5 0.05 0.5 1000 deseq2 0.504 0.027 16942.13 9.496 0.9491525 0.0504 0.0957174 fora5
25 5 1e+07 0.6 0.05 0.5 1000 deseq2 0.210 0.027 16826.51 9.790 0.8860759 0.0210 0.0410276 fora5
29 5 1e+07 0.7 0.05 0.5 1000 deseq2 0.102 0.019 16510.26 9.898 0.8429752 0.0102 0.0201561 fora5
33 5 1e+07 0.8 0.05 0.5 1000 deseq2 0.051 0.024 15836.75 9.949 0.6800000 0.0051 0.0101241 fora5
37 5 1e+07 0.9 0.05 0.5 1000 deseq2 0.040 0.017 14776.20 9.960 0.7017544 0.0040 0.0079547 fora5
41 5 1e+07 1.0 0.05 0.5 1000 deseq2 0.026 0.031 13415.90 9.974 0.4561404 0.0026 0.0051705 fora5
fg5 %>% kbl(caption="fgsea 5% FDR") %>% kable_paper("hover", full_width = F)
fgsea 5% FDR
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 5 1e+07 0.0 0.05 0.5 1000 deseq2 9.637 0.525 17119.39 0.363 0.9483369 0.9637 0.9559568 fgsea5
7 5 1e+07 0.1 0.05 0.5 1000 deseq2 9.604 0.563 17110.79 0.396 0.9446248 0.9604 0.9524471 fgsea5
11 5 1e+07 0.2 0.05 0.5 1000 deseq2 9.278 0.521 17091.52 0.722 0.9468313 0.9278 0.9372191 fgsea5
15 5 1e+07 0.3 0.05 0.5 1000 deseq2 8.463 0.428 17053.85 1.537 0.9518614 0.8463 0.8959822 fgsea5
19 5 1e+07 0.4 0.05 0.5 1000 deseq2 6.824 0.436 17002.21 3.176 0.9399449 0.6824 0.7907300 fgsea5
23 5 1e+07 0.5 0.05 0.5 1000 deseq2 4.860 0.356 16941.81 5.140 0.9317485 0.4860 0.6388013 fgsea5
27 5 1e+07 0.6 0.05 0.5 1000 deseq2 2.872 0.248 16826.29 7.128 0.9205128 0.2872 0.4378049 fgsea5
31 5 1e+07 0.7 0.05 0.5 1000 deseq2 1.722 0.177 16510.10 8.278 0.9067930 0.1722 0.2894361 fgsea5
35 5 1e+07 0.8 0.05 0.5 1000 deseq2 0.954 0.128 15836.65 9.046 0.8817006 0.0954 0.1721711 fgsea5
39 5 1e+07 0.9 0.05 0.5 1000 deseq2 0.608 0.091 14776.13 9.392 0.8698140 0.0608 0.1136555 fgsea5
43 5 1e+07 1.0 0.05 0.5 1000 deseq2 0.318 0.103 13415.83 9.682 0.7553444 0.0318 0.0610306 fgsea5
fo1 %>% kbl(caption="fora 1% FDR") %>% kable_paper("hover", full_width = F)
fora 1% FDR
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 5 1e+07 0.0 0.05 0.5 1000 deseq2 7.382 0.013 17119.90 2.618 0.9982421 0.7382 0.8487496 fora1
6 5 1e+07 0.1 0.05 0.5 1000 deseq2 6.901 0.027 17111.32 3.099 0.9961028 0.6901 0.8153355 fora1
10 5 1e+07 0.2 0.05 0.5 1000 deseq2 5.307 0.019 17092.02 4.693 0.9964326 0.5307 0.6925486 fora1
14 5 1e+07 0.3 0.05 0.5 1000 deseq2 2.930 0.019 17054.26 7.070 0.9935571 0.2930 0.4525446 fora1
18 5 1e+07 0.4 0.05 0.5 1000 deseq2 0.967 0.009 17002.64 9.033 0.9907787 0.0967 0.1762026 fora1
22 5 1e+07 0.5 0.05 0.5 1000 deseq2 0.251 0.010 16942.15 9.749 0.9616858 0.0251 0.0489231 fora1
26 5 1e+07 0.6 0.05 0.5 1000 deseq2 0.106 0.012 16826.52 9.894 0.8983051 0.0106 0.0209528 fora1
30 5 1e+07 0.7 0.05 0.5 1000 deseq2 0.037 0.003 16510.28 9.963 0.9250000 0.0037 0.0073705 fora1
34 5 1e+07 0.8 0.05 0.5 1000 deseq2 0.021 0.007 15836.77 9.979 0.7500000 0.0021 0.0041883 fora1
38 5 1e+07 0.9 0.05 0.5 1000 deseq2 0.008 0.005 14776.22 9.992 0.6153846 0.0008 0.0015979 fora1
42 5 1e+07 1.0 0.05 0.5 1000 deseq2 0.010 0.009 13415.92 9.990 0.5263158 0.0010 0.0019962 fora1
fg1 %>% kbl(caption="fgsea 1% FDR") %>% kable_paper("hover", full_width = F)
fgsea 1% FDR
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 5 1e+07 0.0 0.05 0.5 1000 deseq2 9.079 0.094 17119.82 0.921 0.9897525 0.9079 0.9470610 fgsea1
8 5 1e+07 0.1 0.05 0.5 1000 deseq2 8.923 0.072 17111.28 1.077 0.9919956 0.8923 0.9395104 fgsea1
12 5 1e+07 0.2 0.05 0.5 1000 deseq2 8.245 0.091 17091.95 1.755 0.9890835 0.8245 0.8993237 fgsea1
16 5 1e+07 0.3 0.05 0.5 1000 deseq2 6.760 0.071 17054.20 3.240 0.9896062 0.6760 0.8032797 fgsea1
20 5 1e+07 0.4 0.05 0.5 1000 deseq2 4.358 0.053 17002.59 5.642 0.9879846 0.4358 0.6048158 fgsea1
24 5 1e+07 0.5 0.05 0.5 1000 deseq2 2.313 0.038 16942.12 7.687 0.9838367 0.2313 0.3745446 fgsea1
28 5 1e+07 0.6 0.05 0.5 1000 deseq2 1.091 0.029 16826.51 8.909 0.9741071 0.1091 0.1962230 fgsea1
32 5 1e+07 0.7 0.05 0.5 1000 deseq2 0.529 0.018 16510.26 9.471 0.9670932 0.0529 0.1003129 fgsea1
36 5 1e+07 0.8 0.05 0.5 1000 deseq2 0.301 0.014 15836.76 9.699 0.9555556 0.0301 0.0583616 fgsea1
40 5 1e+07 0.9 0.05 0.5 1000 deseq2 0.178 0.010 14776.21 9.822 0.9468085 0.0178 0.0349431 fgsea1
44 5 1e+07 1.0 0.05 0.5 1000 deseq2 0.067 0.019 13415.91 9.933 0.7790698 0.0067 0.0132857 fgsea1
par(mfrow=c(1,3))
par(mar=c(c(5.1, 5.1, 2.1, 2.1) ))

plot(fo5$VARIANCE,fo5$p,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="precision",col="red",lwd=3)
points(fg5$VARIANCE,fg5$p,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$p,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$p,type="b",pch=19,col="lightblue",lwd=3)
grid()

legend("bottomleft", inset=.02, title="tool",
   c("fora 5%","fgsea 5%", "fora 1%", "fgsea 1%"),
   col=c("red","blue","pink","lightblue"),horiz=FALSE, cex=1.0, pch=19,lwd=2)

plot(fo5$VARIANCE,fo5$r,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="recall",col="red",lwd=3)
points(fg5$VARIANCE,fg5$r,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$r,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$r,type="b",pch=19,col="lightblue",lwd=3)
grid()

plot(fo5$VARIANCE,fo5$f,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="F1",col="red",lwd=3)
points(fg5$VARIANCE,fg5$f,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$f,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$f,type="b",pch=19,col="lightblue",lwd=3)
grid()

##########################
png("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(fo5$VARIANCE,fo5$p,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="precision",col="red",lwd=3)
points(fg5$VARIANCE,fg5$p,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$p,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$p,type="b",pch=19,col="lightblue",lwd=3)
grid()

legend("bottomleft", inset=.02, title="tool",
   c("fora 5%","fgsea 5%", "fora 1%", "fgsea 1%"),
   col=c("red","blue","pink","lightblue"),horiz=FALSE, cex=1.0, pch=19,lwd=2)

plot(fo5$VARIANCE,fo5$r,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="recall",col="red",lwd=3)
points(fg5$VARIANCE,fg5$r,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$r,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$r,type="b",pch=19,col="lightblue",lwd=3)
grid()

plot(fo5$VARIANCE,fo5$f,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="F1",col="red",lwd=3)
points(fg5$VARIANCE,fg5$f,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$f,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$f,type="b",pch=19,col="lightblue",lwd=3)
grid()

dev.off()
## png 
##   2
#################################
pdf("sim.pdf", width=7,height=5,pointsize=12)
par(mar=c(c(5.1, 5.1, 2.1, 2.1) ))
par(mfrow=c(1,3))

plot(fo5$VARIANCE,fo5$p,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="precision",col="red",lwd=3)
points(fg5$VARIANCE,fg5$p,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$p,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$p,type="b",pch=19,col="lightblue",lwd=3)
grid()
legend("bottomleft", inset=.02, title="tool",
   c("fora 5%","fgsea 5%", "fora 1%", "fgsea 1%"),
   col=c("red","blue","pink","lightblue"),horiz=FALSE, cex=1.0, pch=19,lwd=2)

plot(fo5$VARIANCE,fo5$r,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="recall",col="red",lwd=3)
points(fg5$VARIANCE,fg5$r,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$r,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$r,type="b",pch=19,col="lightblue",lwd=3)
grid()

plot(fo5$VARIANCE,fo5$f,ylim=c(0,1),type="b",pch=19,xlab="variance added",ylab="index",main="F1",col="red",lwd=3)
points(fg5$VARIANCE,fg5$f,type="b",pch=19,col="blue",lwd=3)
points(fo1$VARIANCE,fo1$f,type="b",pch=19,col="pink",lwd=3)
points(fg1$VARIANCE,fg1$f,type="b",pch=19,col="lightblue",lwd=3)
grid()

dev.off()
## png 
##   2

Barplot is simpler.

prec <- c("fora 5%"=mean(fo5$p),"fgsea 5%"=mean(fg5$p),"fora 1%"=mean(fo1$p),"fgsea 1%"=mean(fg1$p))
rec <- c("fora 5%"=mean(fo5$r),"fgsea 5%"=mean(fg5$r),"fora 1%"=mean(fo1$r),"fgsea 1%"=mean(fg1$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="")
text((1:6*1.18)-0.45,prec+0.02,labels=signif(prec,3))
barplot(rec,ylim=c(0,1.1),las=2,main="recall",ylab="")
text((1:6*1.18)-0.45,rec+0.02,labels=signif(rec,3))
barplot(f1,ylim=c(0,1.1),las=2,main="F1",ylab="")
text((1:6*1.18)-0.45,f1+0.02,labels=signif(f1,3))

png("simbars.png", width=7,height=5,units="in",res=150,pointsize=12)
par(mar=c(c(9.1, 3.5, 2.1, 1.1) ))
par(mfrow=c(1,3))
barplot(prec,ylim=c(0,1.1),las=2,main="precision",ylab="")
text((1:6*1.18)-0.45,prec+0.02,labels=signif(prec,3))
barplot(rec,ylim=c(0,1.1),las=2,main="recall",ylab="")
text((1:6*1.18)-0.45,rec+0.02,labels=signif(rec,3))
barplot(f1,ylim=c(0,1.1),las=2,main="F1",ylab="")
text((1:6*1.18)-0.45,f1+0.02,labels=signif(f1,3))
dev.off()
## png 
##   2
#################################
pdf("simbars.pdf", width=7,height=5,pointsize=12)
par(mar=c(c(9.1, 3.5, 2.1, 1.1) ))
par(mfrow=c(1,3))
barplot(prec,ylim=c(0,1.1),las=2,main="precision",ylab="")
text((1:6*1.18)-0.45,prec+0.02,labels=signif(prec,3))
barplot(rec,ylim=c(0,1.1),las=2,main="recall",ylab="")
text((1:6*1.18)-0.45,rec+0.02,labels=signif(rec,3))
barplot(f1,ylim=c(0,1.1),las=2,main="F1",ylab="")
text((1:6*1.18)-0.45,f1+0.02,labels=signif(f1,3))
dev.off()
## png 
##   2

Session information

sessionInfo()
## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 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: Etc/UTC
## 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.1        GenomeInfoDb_1.40.1        
## [13] IRanges_2.38.1              S4Vectors_0.42.1           
## [15] BiocGenerics_0.50.0         edgeR_4.2.1                
## [17] limma_3.60.3               
## 
## 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           ggtree_3.12.0           htmltools_0.5.8.1      
##  [13] S4Arrays_1.4.1          SparseArray_1.4.8       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.36          
##  [34] aplot_0.2.3             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.1         
##  [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-61             DelayedArray_0.30.1     HDO.db_0.99.1          
##  [58] caTools_1.18.2          gtools_3.9.5            tools_4.4.1            
##  [61] beeswarm_0.4.0          scatterpie_0.2.3        ape_5.8                
##  [64] httpuv_1.6.15           glue_1.7.0              promises_1.3.0         
##  [67] nlme_3.1-165            GOSemSim_2.30.0         shadowtext_0.1.3       
##  [70] grid_4.4.1              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.1           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.10        
##  [94] Biostrings_2.72.1       knitr_1.47              gridExtra_2.3          
##  [97] svglite_2.1.3           RhpcBLASctl_0.23-42     xfun_0.45              
## [100] graphlayouts_1.1.1      statmod_1.5.0           UCSC.utils_1.0.0       
## [103] lazyeval_0.2.2          ggfun_0.1.5             yaml_2.3.8             
## [106] evaluate_0.24.0         codetools_0.2-20        ggraph_2.2.1           
## [109] tibble_3.2.1            qvalue_2.36.0           ggplotify_0.1.2        
## [112] cli_3.6.3               xtable_1.8-4            systemfonts_1.1.0      
## [115] munsell_0.5.1           jquerylib_0.1.4         Rcpp_1.0.12            
## [118] png_0.1-8               ggplot2_3.5.1           blob_1.2.4             
## [121] DOSE_3.30.1             bitops_1.0-7            viridisLite_0.4.2      
## [124] tidytree_0.4.6          scales_1.3.0            purrr_1.0.2            
## [127] crayon_1.5.3            rlang_1.1.4             cowplot_1.1.3          
## [130] fastmatch_1.1-4         KEGGREST_1.44.1