Introduction

Here we are looking at applying LAM/mitch to a multi-EWAS dataset.

https://pubmed.ncbi.nlm.nih.gov/37410739/

https://zenodo.org/records/8021411

Requirements

suppressPackageStartupMessages({
  library("limma")
  library("eulerr")
  library("IlluminaHumanMethylation450kmanifest")
  library("IlluminaHumanMethylationEPICanno.ilm10b4.hg19")
  library("HGNChelper")
  library("tictoc")
  library("mitch")
  library("gplots")
  library("kableExtra")
  library("beeswarm")
  library("missMethyl")
  library("gridExtra")
  library("png")
})

CORES=8

Load data

Reactome pathways were downloaded on the 14th Sept 2023 from MsigDB.

We’ll also score the probes by the signed -log pvalue

if(!dir.exists("hillary")){
  dir.create("hillary")
}

if(!file.exists("hillary/compressed-disease-states-ewas.tar.gz")){
  setwd("hillary")
  download.file("https://zenodo.org/records/8021411/files/compressed-disease-states-ewas.tar.gz?download=1",destfile="compressed-disease-states-ewas.tar.gz")
  untar("compressed-disease-states-ewas.tar.gz")
  setwd("..")
}
myfiles1 <- list.files("hillary",pattern="prevalent_full",full.names=TRUE)
l1 <- lapply(myfiles1, read.csv)
l1 <- lapply(l1,function(x) { x[,c("CpG","Beta"),drop=FALSE] } )
names(l1) <- gsub("_gs.csv","",gsub("hillary/prevalent_full_","",myfiles))
str(l1)
## List of 14
##  $ alzheimers          :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.004897 -0.11068 -0.005802 0.014743 -0.000639 ...
##  $ breast_cancer       :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.008027 -0.001347 -0.015014 0.000159 0.008284 ...
##  $ chronic_pain        :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.05475 0.00926 0.01377 0.01013 -0.0095 ...
##  $ CKD                 :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00596 0.0054 0.00243 -0.00618 -0.00671 ...
##  $ colorectal_cancer   :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.010005 -0.000702 -0.006291 -0.00484 0.001418 ...
##  $ COPD                :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.025953 -0.015607 -0.001531 -0.010835 0.000989 ...
##  $ diabetes            :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.006468 -0.001714 -0.018136 0.003039 -0.000918 ...
##  $ heart_disease       :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00228 -0.02185 0.02049 -0.0039 0.00153 ...
##  $ lung_cancer         :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00586 -0.00214 -0.00204 -0.00697 0.00332 ...
##  $ osteoarthritis      :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.02473 -0.00845 0.00772 0.01197 0.01001 ...
##  $ parkinsons          :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.005442 -0.001892 -0.004781 -0.001103 -0.000104 ...
##  $ prostate_cancer     :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00579 0.02438 -0.01237 0.0074 -0.00241 ...
##  $ rheumatoid_arthritis:'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.01251 0.03812 0.00982 0.01406 0.00283 ...
##  $ stroke              :'data.frame':    752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.01456 -0.0153 -0.02123 0.00254 0.00112 ...
myfiles2 <- list.files("hillary",pattern="incident_full",full.names=TRUE)
l2 <- lapply(myfiles2, read.csv)
l2 <- lapply(l2,function(x) { x[,c("CpG","Beta"),drop=FALSE] } )
names(l2) <- gsub("_gs.csv","",gsub("hillary/incident_full_","",myfiles2))
str(l2)
## List of 19
##  $ alzheimers           :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.0095 0.00121 0.00108 0.00209 -0.00256 ...
##  $ breast_cancer        :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.002121 0.008666 0.000462 0.004987 -0.000953 ...
##  $ chronic_pain         :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.01489 -0.03197 0.00993 -0.0136 0.00384 ...
##  $ CKD                  :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.001575 -0.003478 -0.000156 0.000612 -0.000292 ...
##  $ colorectal_cancer    :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.001718 0.000956 0.002322 -0.003885 0.001745 ...
##  $ COPD                 :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.00799 0.00653 -0.00138 -0.00247 0.00342 ...
##  $ covid_hospitalisation:'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -4.23e-02 6.87e-03 7.28e-05 7.01e-03 5.08e-03 ...
##  $ diabetes             :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.005986 0.006475 -0.005368 0.000561 0.004567 ...
##  $ heart_disease        :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.01333 0.00943 -0.00269 -0.0017 -0.00511 ...
##  $ ibd                  :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.0084 0.0066 -0.0147 0.00183 -0.00311 ...
##  $ liver_cirrhosis      :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.000439 -0.003165 0.002227 0.0022 -0.000803 ...
##  $ long_covid           :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.2922 0.0673 0.6262 0.0668 -0.1499 ...
##  $ lung_cancer          :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00133 0.00213 -0.00791 0.00141 -0.00232 ...
##  $ osteoarthritis       :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.00269 -0.01725 0.02689 -0.00334 -0.00308 ...
##  $ ovarian_cancer       :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.000657 0.003344 -0.003583 -0.00115 0.001788 ...
##  $ parkinsons           :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.00016 0.000965 0.001041 -0.00135 -0.000752 ...
##  $ prostate_cancer      :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.007516 -0.011051 -0.007453 0.000616 0.001915 ...
##  $ rheumatoid_arthritis :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] 0.000515 -0.001186 0.000713 0.001359 0.001786 ...
##  $ stroke               :'data.frame':   752722 obs. of  2 variables:
##   ..$ CpG : chr [1:752722] "cg18478105" "cg14361672" "cg01763666" "cg02115394" ...
##   ..$ Beta: num [1:752722] -0.00412 0.002 0.00319 0.00383 -0.00119 ...
gs_symbols <- gmt_import("c2.cp.reactome.v2023.1.Hs.symbols.gmt")

Curate the annotation

Use all probes on the chip.

Update old gene symbols.

tic()
anno <- getAnnotation(IlluminaHumanMethylationEPICanno.ilm10b4.hg19)
myann <- data.frame(anno[,c("UCSC_RefGene_Name","UCSC_RefGene_Group","Islands_Name","Relation_to_Island")])
gp <- myann[,"UCSC_RefGene_Name",drop=FALSE]
gp2 <- strsplit(gp$UCSC_RefGene_Name,";")
names(gp2) <- rownames(gp)
gp2 <- lapply(gp2,unique)
gt <- stack(gp2)
colnames(gt) <- c("gene","probe")
gt$probe <- as.character(gt$probe)
dim(gt)
## [1] 684970      2
str(gt)
## 'data.frame':    684970 obs. of  2 variables:
##  $ gene : chr  "YTHDF1" "EIF2S3" "PKN3" "CCDC57" ...
##  $ probe: chr  "cg18478105" "cg09835024" "cg14361672" "cg01763666" ...
toc() #9.0s
## 12.409 sec elapsed
tic()
#new.hgnc.table <- getCurrentHumanMap()
new.hgnc.table <- readRDS("new.hgnc.table.rds")
fix <- checkGeneSymbols(gt$gene,map=new.hgnc.table)
## Warning in checkGeneSymbols(gt$gene, map = new.hgnc.table): Human gene symbols
## should be all upper-case except for the 'orf' in open reading frames. The case
## of some letters was corrected.
## Warning in checkGeneSymbols(gt$gene, map = new.hgnc.table): x contains
## non-approved gene symbols
fix2 <- fix[which(fix$x != fix$Suggested.Symbol),]
length(unique(fix2$x))
## [1] 3253
gt$gene <- fix$Suggested.Symbol
toc()
## 50.731 sec elapsed

Mitch import

As we don’t have the test statistic, we will use the delta beta value, which according to preliminary investigations works better than the directional p-value.

l1: prevalent

l2: incident

tic()
m1 <- mitch_import(x=l1,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = l1, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
toc() #117 sec
## 66.042 sec elapsed
head(m1)
##            alzheimers breast_cancer chronic_pain           CKD
## A1BG     -0.008221589  0.0053105947 -0.013071700  0.0033540211
## A1BG-AS1 -0.004233515  0.0024686615 -0.019011331 -0.0014040615
## A1CF     -0.009002804  0.0002532217 -0.013886839  0.0007266396
## A2M       0.006820743  0.0034871700 -0.006451970 -0.0046553807
## A2M-AS1   0.061286000  0.0099358000  0.024287000  0.0019842000
## A2ML1    -0.015142667  0.0062460789  0.001835431 -0.0002313603
##          colorectal_cancer          COPD     diabetes heart_disease
## A1BG           0.005786606 -0.0008826229 -0.006799651  -0.004042047
## A1BG-AS1       0.008133452 -0.0026733551 -0.009933892  -0.008125077
## A1CF          -0.001142371  0.0055164978  0.001369157   0.015620270
## A2M            0.005373974  0.0025985720 -0.001004644  -0.002524372
## A2M-AS1        0.013436000  0.0105620000 -0.008632800  -0.030906000
## A2ML1          0.002453735  0.0035715661  0.004802442  -0.000115850
##            lung_cancer osteoarthritis   parkinsons prostate_cancer
## A1BG      0.0021250121   -0.003627459 0.0022200363     0.002281968
## A1BG-AS1  0.0032586708   -0.002584733 0.0031032277     0.004377554
## A1CF     -0.0002496335    0.008616171 0.0029512548     0.008346012
## A2M       0.0023641197   -0.003620486 0.0011883607     0.001014237
## A2M-AS1   0.0040564000    0.016744000 0.0002487200     0.005403400
## A2ML1    -0.0009114175    0.008265458 0.0002088644     0.002255033
##          rheumatoid_arthritis        stroke
## A1BG             -0.006779316  0.0002895914
## A1BG-AS1         -0.010101462  0.0007705874
## A1CF             -0.001300365  0.0059818522
## A2M               0.006746609  0.0014745213
## A2M-AS1          -0.013946000 -0.0142040000
## A2ML1             0.003013324  0.0022876761
tic()
m2 <- mitch_import(x=l2,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = l2, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
toc() #158 sec
## 91.743 sec elapsed
head(m2)
##             alzheimers breast_cancer  chronic_pain           CKD
## A1BG      5.084368e-04 -6.318768e-04  0.0002301753  0.0005615255
## A1BG-AS1 -2.090631e-04  4.519615e-05 -0.0019561746  0.0011224565
## A1CF      1.244080e-03 -1.628947e-03 -0.0031212174  0.0008953483
## A2M      -7.458717e-05 -1.811270e-03  0.0034057620  0.0001440781
## A2M-AS1   4.677900e-03 -1.215700e-02 -0.0027084000 -0.0026319000
## A2ML1     1.669304e-03 -5.637453e-04 -0.0045962901 -0.0005658983
##          colorectal_cancer          COPD covid_hospitalisation     diabetes
## A1BG          0.0020387679  0.0017412103           0.007950112  0.006480400
## A1BG-AS1      0.0029418062  0.0022725962           0.009102761  0.009699762
## A1CF         -0.0015391277 -0.0002604017           0.004859927 -0.005793625
## A2M          -0.0004250785 -0.0015433390          -0.002574839 -0.000805537
## A2M-AS1       0.0057066000 -0.0101360000          -0.009949800  0.010303000
## A2ML1         0.0000405520  0.0017475522          -0.007598520  0.003072690
##          heart_disease           ibd liver_cirrhosis  long_covid   lung_cancer
## A1BG      0.0016748316 -0.0016281726    0.0011774437 -0.03270144 -1.829838e-04
## A1BG-AS1  0.0003791538 -0.0019914477    0.0013469785 -0.03182165 -2.571425e-04
## A1CF     -0.0001371752  0.0018986026   -0.0019445357  0.03079543 -1.924523e-04
## A2M       0.0005329207 -0.0008026473   -0.0008272411 -0.01638500 -4.189465e-04
## A2M-AS1   0.0057750000 -0.0051522000    0.0026419000 -0.31487000 -2.710530e-04
## A2ML1     0.0028732975  0.0006945010   -0.0010377521  0.10090850 -1.884505e-05
##          osteoarthritis ovarian_cancer    parkinsons prostate_cancer
## A1BG        0.008759511   0.0006228232 -5.963763e-04    -0.006757779
## A1BG-AS1    0.011684431   0.0006301492 -7.590546e-04    -0.008730646
## A1CF        0.003113947  -0.0013322063  8.361253e-04    -0.001651735
## A2M        -0.000602872  -0.0010100706  1.342940e-05     0.002817242
## A2M-AS1    -0.009950300  -0.0000064800 -1.579100e-03     0.010934000
## A2ML1       0.002953585  -0.0008099856  3.977747e-05     0.003276922
##          rheumatoid_arthritis        stroke
## A1BG             0.0002831442  0.0024092732
## A1BG-AS1         0.0005559785  0.0030393531
## A1CF             0.0017111817 -0.0003764426
## A2M              0.0016425058  0.0010126575
## A2M-AS1         -0.0020590000  0.0117930000
## A2ML1           -0.0006907633  0.0004472456

Mitch calc prevalence

Multi-comparison for prevalence.

tic()
mres1 <- mitch_calc(x=m1,genesets=gs_symbols,minsetsize=5,cores=8, priority="effect")
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
toc() #21.3s
## 68.186 sec elapsed
mtable1 <- mres1$enrichment_result
head(mtable1,20)
##                                                                                          set
## 1055                                  REACTOME_METAL_SEQUESTRATION_BY_ANTIMICROBIAL_PROTEINS
## 758                     REACTOME_SODIUM_COUPLED_SULPHATE_DI_AND_TRI_CARBOXYLATE_TRANSPORTERS
## 898                                                         REACTOME_ORGANIC_ANION_TRANSPORT
## 421   REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_ENDOCRINE_COMMITTED_NEUROG3_PROGENITOR_CELLS
## 1588                                              REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE
## 1614                                            REACTOME_FORMATION_OF_LATERAL_PLATE_MESODERM
## 213                                         REACTOME_LECTIN_PATHWAY_OF_COMPLEMENT_ACTIVATION
## 1393                                                         REACTOME_INTERLEUKIN_36_PATHWAY
## 521  REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE
## 422               REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_EARLY_PANCREATIC_PRECURSOR_CELLS
## 1532                                                        REACTOME_DEFECTIVE_F9_ACTIVATION
## 1007                                                   REACTOME_CD22_MEDIATED_BCR_REGULATION
## 256                                                         REACTOME_ACTIVATION_OF_C3_AND_C5
## 1534                     REACTOME_SIGNALING_BY_MEMBRANE_TETHERED_FUSIONS_OF_PDGFRA_OR_PDGFRB
## 634                                                      REACTOME_VASOPRESSIN_LIKE_RECEPTORS
## 1187                                                           REACTOME_FASL_CD95L_SIGNALING
## 775                                                                  REACTOME_RSK_ACTIVATION
## 216                                                REACTOME_CREATION_OF_C4_AND_C2_ACTIVATORS
## 774                                                       REACTOME_FREE_FATTY_ACID_RECEPTORS
## 1221                             REACTOME_PTK6_REGULATES_PROTEINS_INVOLVED_IN_RNA_PROCESSING
##      setSize      pMANOVA s.alzheimers s.breast_cancer s.chronic_pain
## 1055       6 8.016738e-04 -0.904913413     0.120797540     0.51735527
## 758        5 5.687922e-02 -0.047322971    -0.004145078    -0.65195891
## 898        5 4.249713e-02 -0.245323152     0.179983638    -0.54018726
## 421        5 8.504890e-02 -0.008344696     0.068466503     0.57414780
## 1588       6 8.522210e-03  0.328485069     0.344499492     0.01545384
## 1614       5 1.020562e-01 -0.062212526    -0.237505681     0.37903827
## 213        8 1.019821e-03 -0.290274558     0.301547798    -0.30354789
## 1393       7 2.045340e-03 -0.311610390     0.046038961    -0.36320779
## 521        5 1.716184e-02 -0.206435779     0.267775657    -0.07101173
## 422        8 4.040498e-03  0.091504159    -0.493874722     0.41630301
## 1532       5 3.297438e-04  0.172475230    -0.019216435     0.16436688
## 1007       5 1.069337e-01 -0.214416871     0.224543223     0.25872193
## 256        6 1.486393e-01 -0.149190188     0.348150842    -0.44740391
## 1534       5 1.226236e-01 -0.458394691     0.048941005     0.65586765
## 634        5 2.279373e-01 -0.104572312     0.318571039     0.44294155
## 1187       5 2.404745e-01 -0.137896555    -0.545659486     0.15611308
## 775        5 3.170955e-01  0.212144351    -0.325661304    -0.29730025
## 216       14 2.696386e-05 -0.270995317     0.383154380    -0.37591182
## 774        5 4.308581e-02  0.226252159    -0.026997546     0.48473775
## 1221       5 9.807675e-03  0.108971912    -0.321861649     0.17982002
##            s.CKD s.colorectal_can       s.COPD  s.diabetes s.heart_disease
## 1055  0.31663712      -0.24709483 -0.254912655  0.15840189       0.4699180
## 758  -0.69824561       0.18978275  0.612398873 -0.30031815      -0.4302700
## 898  -0.55885829       0.30531770  0.742277975  0.20599945      -0.5490774
## 421   0.40979911      -0.36576675 -0.277483865  0.29628216       0.5824561
## 1588 -0.70289229       0.39770920  0.203930124  0.22026272      -0.4092693
## 1614  0.22810654      -0.62085265 -0.258012908  0.15274975       0.3437687
## 213  -0.06496886       0.43357653  0.459770899 -0.09761807      -0.5660371
## 1393 -0.09242857       0.16329870  0.739818182  0.02364935      -0.4857403
## 521   0.17634760       0.46837560  0.392164349 -0.01701663      -0.5638578
## 422  -0.03661530      -0.52031911 -0.261148234  0.22670349       0.5447407
## 1532 -0.08379238      -0.70200891 -0.641505318 -0.42899736      -0.4364694
## 1007  0.24543223      -0.19938187 -0.216471230  0.28793746       0.2999182
## 256  -0.33854522       0.13984213  0.300259079 -0.14817508      -0.4767662
## 1534  0.04785020      -0.52764294 -0.601818017  0.09055540       0.2462503
## 634   0.01507136      -0.54884101 -0.570929915  0.09053722       0.4532497
## 1187  0.22523407      -0.83081538 -0.371329879 -0.01643487       0.2690119
## 775  -0.40289065       0.08995546 -0.113080629  0.07637488      -0.4232888
## 216  -0.02572897       0.15685510  0.553832063 -0.07016518      -0.4119428
## 774   0.22027088       0.69359149 -0.006799382  0.19483683       0.2549405
## 1221  0.38991001      -0.30773566  0.454395055 -0.28279247       0.1054995
##      s.lung_cancer s.osteoarthritis s.parkinsons s.prostate_cance
## 1055 -0.5431874309       0.50578004 -0.418677939       0.73154251
## 758  -0.6305063176       0.47715662 -0.341532588      -0.08853741
## 898  -0.1713844196       0.57669303  0.299809108       0.00219980
## 421   0.3288246523      -0.43494228 -0.167402963      -0.59989092
## 1588 -0.2490795873       0.30216808 -0.494689635      -0.09723800
## 1614  0.0581219889      -0.55631306 -0.454122353      -0.70542678
## 213  -0.6514841584       0.37590345 -0.006920769       0.30888904
## 1393 -0.5186103896       0.19079221  0.296571429      -0.06954545
## 521  -0.7477865649       0.36365785 -0.182510681       0.08004727
## 422   0.1773603346      -0.58117414 -0.167257603      -0.51153462
## 1532 -0.1095900373       0.09613671  0.184874102      -0.27126625
## 1007  0.3795836742       0.54435051 -0.125734024       0.26257613
## 256  -0.4030574368      -0.13300911 -0.128933533      -0.23147433
## 1534 -0.0640669030      -0.23939642 -0.298045632       0.35476775
## 634  -0.1568402872       0.06477593 -0.291009908      -0.62574311
## 1187 -0.2199800018      -0.15527679 -0.380383601      -0.35364058
## 775   0.0789928188      -0.06470321 -0.597872921      -0.21579856
## 216  -0.4277140129       0.42045846  0.156939546       0.26242766
## 774   0.4330333606       0.17952913  0.446286701       0.23032452
## 1221 -0.0005635851       0.51233524  0.436033088       0.28355604
##      s.rheumatoid_art    s.stroke p.alzheimers p.breast_cancer p.chronic_pain
## 1055       0.10554066 -0.08685969 0.0001234742      0.60836892     0.02818881
## 758       -0.17840196  0.02901554 0.8546019302      0.98719364     0.01157712
## 898       -0.43208799  0.05112263 0.3421222521      0.48582864     0.03644892
## 421        0.42787019  0.39181893 0.9742221537      0.79091344     0.02618811
## 1588       0.36034726 -0.60968441 0.1634971397      0.14392195     0.94773415
## 1614       0.02756113 -0.18011090 0.8096270581      0.35772556     0.14216000
## 213       -0.06650302  0.46478249 0.1551010173      0.13968619     0.13707888
## 1393       0.07972727  0.62762338 0.1533773511      0.83294065     0.09608839
## 521        0.14720480  0.45044996 0.4240632075      0.29977006     0.78333114
## 422        0.04874085 -0.01804627 0.6540297342      0.01556043     0.04144307
## 1532       0.14185983  0.51815290 0.5042081203      0.94068236     0.52446060
## 1007       0.80669030  0.30695391 0.4063703366      0.38456745     0.31640811
## 256       -0.66298502 -0.47678136 0.5268374771      0.13972114     0.05771122
## 1534       0.20070903  0.25119535 0.0758787305      0.84968883     0.01108785
## 634        0.12851559 -0.09264612 0.6855226719      0.21734028     0.08629569
## 1187      -0.10617217 -0.16562131 0.5933541369      0.03459416     0.54549609
## 775       -0.44603218 -0.66243069 0.4113627605      0.20727690     0.24962528
## 216       -0.11186676  0.51659294 0.0791476056      0.01305128     0.01487378
## 774        0.44099627  0.03972366 0.3809598182      0.91673826     0.06049939
## 1221       0.48968276 -0.30206345 0.6730430203      0.21262698     0.48622526
##            p.CKD p.colorectal_can       p.COPD p.diabetes p.heart_disease
## 1055 0.179224822      0.294571714 0.2795599942 0.50163719     0.046217846
## 758  0.006849845      0.462397548 0.0177132658 0.24485106     0.095674175
## 898  0.030449374      0.237083655 0.0040452655 0.42504328     0.033477098
## 421  0.112530747      0.156658594 0.2825890786 0.25125043     0.024096389
## 1588 0.002865173      0.091590681 0.3870154584 0.35013661     0.082544988
## 1614 0.377068747      0.016203464 0.3177362010 0.55418627     0.183119736
## 213  0.750329017      0.033696527 0.0243222339 0.63256758     0.005561305
## 1393 0.671952116      0.454356481 0.0006989680 0.91371682     0.026041905
## 521  0.494683575      0.069713206 0.1288564188 0.94746228     0.028994732
## 422  0.857674761      0.010815237 0.2008694482 0.26684120     0.007624693
## 1532 0.745581027      0.006555214 0.0129809963 0.09665951     0.090988633
## 1007 0.341907657      0.440069224 0.4018884590 0.26484926     0.245480075
## 256  0.150979016      0.553055546 0.2027808028 0.52965349     0.043129775
## 1534 0.853000402      0.041022649 0.0197756336 0.72584321     0.340300940
## 634  0.953460943      0.033553336 0.0270394348 0.72589604     0.079226666
## 1187 0.383106538      0.001292841 0.1504501840 0.94925598     0.297544321
## 775  0.118720654      0.727587030 0.6614691290 0.76742215     0.101179708
## 216  0.867621612      0.309549364 0.0003326864 0.64943090     0.007609800
## 774  0.393677523      0.007230644 0.9789946007 0.45056339     0.323533409
## 1221 0.131069772      0.233390187 0.0784711559 0.27348210     0.682885377
##      p.lung_cancer p.osteoarthritis p.parkinsons p.prostate_cance
## 1055   0.021209005      0.031909635   0.07572951      0.001913030
## 758    0.014618704      0.064634693   0.18598477      0.731714375
## 898    0.506908447      0.025531247   0.24565182      0.993203433
## 421    0.202897827      0.092125359   0.51682876      0.020173025
## 1588   0.290710385      0.199924412   0.03586188      0.679997135
## 1614   0.821926945      0.031213700   0.07865051      0.006297556
## 213    0.001416757      0.065595937   0.97295959      0.130300132
## 1393   0.017491466      0.382042775   0.17421119      0.750007945
## 521    0.003780159      0.159062229   0.47972534      0.756584342
## 422    0.385019557      0.004416900   0.41267099      0.012225128
## 1532   0.671296774      0.709689573   0.47405527      0.293514114
## 1007   0.141586992      0.035030328   0.62634046      0.309252565
## 256    0.087311295      0.572616052   0.58443722      0.326157248
## 1534   0.804066366      0.353911269   0.24844010      0.169502257
## 634    0.543626056      0.801942820   0.25978445      0.015382703
## 1187   0.394302498      0.547650560   0.14074979      0.170861822
## 775    0.759691396      0.802160553   0.02059661      0.403352701
## 216    0.005586621      0.006447888   0.30928897      0.089103882
## 774    0.093562276      0.486930799   0.08394788      0.372447033
## 1221   0.998258711      0.047254004   0.09131226      0.272188889
##      p.rheumatoid_art     p.stroke   s.dist        SD p.adjustMANOVA
## 1055      0.654380093 0.7125423081 1.689178 0.4671946   0.0071931607
## 758       0.489669966 0.9105398839 1.543890 0.3999646   0.2142476469
## 898       0.094280520 0.8430736797 1.525113 0.4228746   0.1753273690
## 421       0.097539000 0.1291936651 1.470356 0.3975515   0.2826929032
## 1588      0.126371261 0.0096993065 1.430294 0.3956374   0.0518276618
## 1614      0.915006653 0.4855202809 1.378200 0.3557849   0.3191930236
## 213       0.744636504 0.0228130686 1.372042 0.3798981   0.0089718343
## 1393      0.714903932 0.0040302921 1.359633 0.3763174   0.0162275629
## 521       0.568659594 0.0810983897 1.340738 0.3695512   0.0907074594
## 422       0.811319898 0.9295688973 1.332503 0.3607191   0.0281122764
## 1532      0.582779672 0.0447978815 1.326901 0.3527535   0.0031663117
## 1007      0.001783425 0.2345798262 1.324072 0.2998233   0.3309976823
## 256       0.004915547 0.0431231413 1.316983 0.3001552   0.4041522171
## 1534      0.437031585 0.3306924480 1.316774 0.3645601   0.3616819425
## 634       0.618727003 0.7197774265 1.296072 0.3535398   0.5174090100
## 1187      0.680974462 0.5213003394 1.293676 0.3010828   0.5287060830
## 775       0.084124681 0.0103075448 1.288356 0.2741632   0.6127899048
## 216       0.468628730 0.0008166891 1.265218 0.3464056   0.0003298741
## 774       0.087685197 0.8777493734 1.259963 0.2057344   0.1768672636
## 1221      0.057922044 0.2421194881 1.247462 0.3208897   0.0583485567
#numsig manova
nrow(subset(mtable1,p.adjustMANOVA<0.05))
## [1] 266
sig <- subset(mtable1,p.adjustMANOVA<0.05)

Individual comparisons.

r1 <- lapply(l1,function(m) {
  m2 <- mitch_import(x=m,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
  mres <- mitch_calc(x=m2,genesets=gs_symbols,minsetsize=5,cores=8, priority="effect")
  mtable <- mres$enrichment_result
})
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
nup <- lapply(r1,function(r) {
  ups <- subset(r,p.adjustANOVA<0.05 & s.dist>0)$set
  length(ups)
} )

ndn <- lapply(r1,function(r) {
  dns <- subset(r,p.adjustANOVA<0.05 & s.dist<0)$set
  length(dns)
} )

nums <- cbind(unlist(ndn),unlist(nup))
colnames(nums) <- c("dn","up")
nums
##                       dn  up
## alzheimers             2   1
## breast_cancer         60   2
## chronic_pain           2   4
## CKD                   15 132
## colorectal_cancer     20   1
## COPD                 214  49
## diabetes              11  76
## heart_disease         33 181
## lung_cancer            8   1
## osteoarthritis        29  14
## parkinsons             2   5
## prostate_cancer        3  17
## rheumatoid_arthritis   0   8
## stroke                 4   5
rownames(nums) <- gsub("_"," ",rownames(nums))

par(mar = c(5.1, 10.1, 4.1, 2.1))
barplot(t(nums),beside=TRUE,horiz=TRUE,las=1,
  legend.text = c("down","up"),xlab="no. pathways")
abline(v=seq(0,200,50),lty=2,lwd=0.5,col="gray")

pdf("fig8a.pdf",height=6,width=4)
par(mar = c(5.1, 10.1, 4.1, 2.1))
barplot(t(nums),beside=TRUE,horiz=TRUE,las=1,
  legend.text = c("down","up"),xlab="no. pathways")
abline(v=seq(0,200,50),lty=2,lwd=0.5,col="gray")
dev.off()
## png 
##   2
r2 <- lapply(r1,function(r) {
  ups <- head(subset(r,p.adjustANOVA<0.05 & s.dist > 0.3)$set,5)
  dns <- head(subset(r,p.adjustANOVA<0.05 & s.dist < -0.3)$set,5)
  list("ups"=ups,"dns"=dns)
} )

r2
## $alzheimers
## $alzheimers$ups
## character(0)
## 
## $alzheimers$dns
## character(0)
## 
## 
## $breast_cancer
## $breast_cancer$ups
## character(0)
## 
## $breast_cancer$dns
## [1] "REACTOME_ASSEMBLY_OF_THE_ORC_COMPLEX_AT_THE_ORIGIN_OF_REPLICATION"                                     
## [2] "REACTOME_DNA_METHYLATION"                                                                              
## [3] "REACTOME_ACTIVATED_PKN1_STIMULATES_TRANSCRIPTION_OF_AR_ANDROGEN_RECEPTOR_REGULATED_GENES_KLK2_AND_KLK3"
## [4] "REACTOME_SIRT1_NEGATIVELY_REGULATES_RRNA_EXPRESSION"                                                   
## [5] "REACTOME_CONDENSATION_OF_PROPHASE_CHROMOSOMES"                                                         
## 
## 
## $chronic_pain
## $chronic_pain$ups
## character(0)
## 
## $chronic_pain$dns
## character(0)
## 
## 
## $CKD
## $CKD$ups
## [1] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"                                              
## [2] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"                                              
## [3] "REACTOME_RESPONSE_OF_EIF2AK1_HRI_TO_HEME_DEFICIENCY"                                                   
## [4] "REACTOME_ACTIVATED_PKN1_STIMULATES_TRANSCRIPTION_OF_AR_ANDROGEN_RECEPTOR_REGULATED_GENES_KLK2_AND_KLK3"
## [5] "REACTOME_NGF_STIMULATED_TRANSCRIPTION"                                                                 
## 
## $CKD$dns
## [1] "REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE"
## [2] "REACTOME_SCAVENGING_OF_HEME_FROM_PLASMA"   
## [3] "REACTOME_ACYL_CHAIN_REMODELLING_OF_PC"     
## 
## 
## $colorectal_cancer
## $colorectal_cancer$ups
## character(0)
## 
## $colorectal_cancer$dns
## [1] "REACTOME_INTERLEUKIN_10_SIGNALING"                                   
## [2] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"                          
## [3] "REACTOME_CHEMOKINE_RECEPTORS_BIND_CHEMOKINES"                        
## [4] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"
## 
## 
## $COPD
## $COPD$ups
## [1] "REACTOME_ORGANIC_ANION_TRANSPORT"         
## [2] "REACTOME_INTERLEUKIN_36_PATHWAY"          
## [3] "REACTOME_EICOSANOIDS"                     
## [4] "REACTOME_CREATION_OF_C4_AND_C2_ACTIVATORS"
## [5] "REACTOME_FATTY_ACIDS"                     
## 
## $COPD$dns
## [1] "REACTOME_VITAMIN_C_ASCORBATE_METABOLISM"                  
## [2] "REACTOME_NFE2L2_REGULATES_PENTOSE_PHOSPHATE_PATHWAY_GENES"
## [3] "REACTOME_MAPK1_ERK2_ACTIVATION"                           
## [4] "REACTOME_SYNTHESIS_OF_5_EICOSATETRAENOIC_ACIDS"           
## [5] "REACTOME_STAT5_ACTIVATION_DOWNSTREAM_OF_FLT3_ITD_MUTANTS" 
## 
## 
## $diabetes
## $diabetes$ups
## [1] "REACTOME_KSRP_KHSRP_BINDS_AND_DESTABILIZES_MRNA"                                
## [2] "REACTOME_TP53_REGULATES_TRANSCRIPTION_OF_GENES_INVOLVED_IN_G2_CELL_CYCLE_ARREST"
## [3] "REACTOME_PD_1_SIGNALING"                                                        
## [4] "REACTOME_GENERATION_OF_SECOND_MESSENGER_MOLECULES"                              
## [5] "REACTOME_SUMOYLATION_OF_DNA_REPLICATION_PROTEINS"                               
## 
## $diabetes$dns
## [1] "REACTOME_METABOLISM_OF_ANGIOTENSINOGEN_TO_ANGIOTENSINS"    
## [2] "REACTOME_DEFENSINS"                                        
## [3] "REACTOME_O_GLYCOSYLATION_OF_TSR_DOMAIN_CONTAINING_PROTEINS"
## 
## 
## $heart_disease
## $heart_disease$ups
## [1] "REACTOME_RECYCLING_OF_EIF2_GDP"        
## [2] "REACTOME_FLT3_SIGNALING_BY_CBL_MUTANTS"
## [3] "REACTOME_FOLDING_OF_ACTIN_BY_CCT_TRIC" 
## [4] "REACTOME_ENDOSOMAL_VACUOLAR_PATHWAY"   
## [5] "REACTOME_NEGATIVE_REGULATION_OF_FLT3"  
## 
## $heart_disease$dns
## [1] "REACTOME_LECTIN_PATHWAY_OF_COMPLEMENT_ACTIVATION"              
## [2] "REACTOME_DIGESTION_AND_ABSORPTION"                             
## [3] "REACTOME_DIGESTION"                                            
## [4] "REACTOME_PTK6_REGULATES_RHO_GTPASES_RAS_GTPASE_AND_MAP_KINASES"
## [5] "REACTOME_MET_ACTIVATES_PTK2_SIGNALING"                         
## 
## 
## $lung_cancer
## $lung_cancer$ups
## character(0)
## 
## $lung_cancer$dns
## character(0)
## 
## 
## $osteoarthritis
## $osteoarthritis$ups
## [1] "REACTOME_INTERLEUKIN_10_SIGNALING"
## 
## $osteoarthritis$dns
## [1] "REACTOME_FORMATION_OF_SENESCENCE_ASSOCIATED_HETEROCHROMATIN_FOCI_SAHF"
## [2] "REACTOME_SEALING_OF_THE_NUCLEAR_ENVELOPE_NE_BY_ESCRT_III"             
## 
## 
## $parkinsons
## $parkinsons$ups
## [1] "REACTOME_ASPIRIN_ADME"
## 
## $parkinsons$dns
## character(0)
## 
## 
## $prostate_cancer
## $prostate_cancer$ups
## [1] "REACTOME_EICOSANOIDS"                                    
## [2] "REACTOME_FATTY_ACIDS"                                    
## [3] "REACTOME_ASPIRIN_ADME"                                   
## [4] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"
## [5] "REACTOME_SNRNP_ASSEMBLY"                                 
## 
## $prostate_cancer$dns
## [1] "REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_BETA_CELLS"
## [2] "REACTOME_REGULATION_OF_BETA_CELL_DEVELOPMENT"        
## 
## 
## $rheumatoid_arthritis
## $rheumatoid_arthritis$ups
## [1] "REACTOME_INTERLEUKIN_10_SIGNALING"
## 
## $rheumatoid_arthritis$dns
## character(0)
## 
## 
## $stroke
## $stroke$ups
## [1] "REACTOME_GENERATION_OF_SECOND_MESSENGER_MOLECULES"
## [2] "REACTOME_ASPIRIN_ADME"                            
## 
## $stroke$dns
## character(0)
gsets <- unique(unname(unlist(r2)))
gsets
##  [1] "REACTOME_ASSEMBLY_OF_THE_ORC_COMPLEX_AT_THE_ORIGIN_OF_REPLICATION"                                     
##  [2] "REACTOME_DNA_METHYLATION"                                                                              
##  [3] "REACTOME_ACTIVATED_PKN1_STIMULATES_TRANSCRIPTION_OF_AR_ANDROGEN_RECEPTOR_REGULATED_GENES_KLK2_AND_KLK3"
##  [4] "REACTOME_SIRT1_NEGATIVELY_REGULATES_RRNA_EXPRESSION"                                                   
##  [5] "REACTOME_CONDENSATION_OF_PROPHASE_CHROMOSOMES"                                                         
##  [6] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"                                              
##  [7] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"                                              
##  [8] "REACTOME_RESPONSE_OF_EIF2AK1_HRI_TO_HEME_DEFICIENCY"                                                   
##  [9] "REACTOME_NGF_STIMULATED_TRANSCRIPTION"                                                                 
## [10] "REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE"                                                            
## [11] "REACTOME_SCAVENGING_OF_HEME_FROM_PLASMA"                                                               
## [12] "REACTOME_ACYL_CHAIN_REMODELLING_OF_PC"                                                                 
## [13] "REACTOME_INTERLEUKIN_10_SIGNALING"                                                                     
## [14] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"                                                            
## [15] "REACTOME_CHEMOKINE_RECEPTORS_BIND_CHEMOKINES"                                                          
## [16] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"                                  
## [17] "REACTOME_ORGANIC_ANION_TRANSPORT"                                                                      
## [18] "REACTOME_INTERLEUKIN_36_PATHWAY"                                                                       
## [19] "REACTOME_EICOSANOIDS"                                                                                  
## [20] "REACTOME_CREATION_OF_C4_AND_C2_ACTIVATORS"                                                             
## [21] "REACTOME_FATTY_ACIDS"                                                                                  
## [22] "REACTOME_VITAMIN_C_ASCORBATE_METABOLISM"                                                               
## [23] "REACTOME_NFE2L2_REGULATES_PENTOSE_PHOSPHATE_PATHWAY_GENES"                                             
## [24] "REACTOME_MAPK1_ERK2_ACTIVATION"                                                                        
## [25] "REACTOME_SYNTHESIS_OF_5_EICOSATETRAENOIC_ACIDS"                                                        
## [26] "REACTOME_STAT5_ACTIVATION_DOWNSTREAM_OF_FLT3_ITD_MUTANTS"                                              
## [27] "REACTOME_KSRP_KHSRP_BINDS_AND_DESTABILIZES_MRNA"                                                       
## [28] "REACTOME_TP53_REGULATES_TRANSCRIPTION_OF_GENES_INVOLVED_IN_G2_CELL_CYCLE_ARREST"                       
## [29] "REACTOME_PD_1_SIGNALING"                                                                               
## [30] "REACTOME_GENERATION_OF_SECOND_MESSENGER_MOLECULES"                                                     
## [31] "REACTOME_SUMOYLATION_OF_DNA_REPLICATION_PROTEINS"                                                      
## [32] "REACTOME_METABOLISM_OF_ANGIOTENSINOGEN_TO_ANGIOTENSINS"                                                
## [33] "REACTOME_DEFENSINS"                                                                                    
## [34] "REACTOME_O_GLYCOSYLATION_OF_TSR_DOMAIN_CONTAINING_PROTEINS"                                            
## [35] "REACTOME_RECYCLING_OF_EIF2_GDP"                                                                        
## [36] "REACTOME_FLT3_SIGNALING_BY_CBL_MUTANTS"                                                                
## [37] "REACTOME_FOLDING_OF_ACTIN_BY_CCT_TRIC"                                                                 
## [38] "REACTOME_ENDOSOMAL_VACUOLAR_PATHWAY"                                                                   
## [39] "REACTOME_NEGATIVE_REGULATION_OF_FLT3"                                                                  
## [40] "REACTOME_LECTIN_PATHWAY_OF_COMPLEMENT_ACTIVATION"                                                      
## [41] "REACTOME_DIGESTION_AND_ABSORPTION"                                                                     
## [42] "REACTOME_DIGESTION"                                                                                    
## [43] "REACTOME_PTK6_REGULATES_RHO_GTPASES_RAS_GTPASE_AND_MAP_KINASES"                                        
## [44] "REACTOME_MET_ACTIVATES_PTK2_SIGNALING"                                                                 
## [45] "REACTOME_FORMATION_OF_SENESCENCE_ASSOCIATED_HETEROCHROMATIN_FOCI_SAHF"                                 
## [46] "REACTOME_SEALING_OF_THE_NUCLEAR_ENVELOPE_NE_BY_ESCRT_III"                                              
## [47] "REACTOME_ASPIRIN_ADME"                                                                                 
## [48] "REACTOME_SNRNP_ASSEMBLY"                                                                               
## [49] "REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_BETA_CELLS"                                                  
## [50] "REACTOME_REGULATION_OF_BETA_CELL_DEVELOPMENT"
par(mar = c(5.1, 4.1, 4.1, 2.1))

Make a heatmap with these gene sets.

top <- mtable1[which(mtable1$set %in% gsets),]
top <- top[,c(1,4:17)]
rownames(top) <- top$set
top$set=NULL
head(top,2)
##                                            s.alzheimers s.breast_cancer
## REACTOME_ORGANIC_ANION_TRANSPORT             -0.2453232       0.1799836
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE    0.3284851       0.3444995
##                                            s.chronic_pain      s.CKD
## REACTOME_ORGANIC_ANION_TRANSPORT              -0.54018726 -0.5588583
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE     0.01545384 -0.7028923
##                                            s.colorectal_can    s.COPD
## REACTOME_ORGANIC_ANION_TRANSPORT                  0.3053177 0.7422780
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE        0.3977092 0.2039301
##                                            s.diabetes s.heart_disease
## REACTOME_ORGANIC_ANION_TRANSPORT            0.2059995      -0.5490774
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE  0.2202627      -0.4092693
##                                            s.lung_cancer s.osteoarthritis
## REACTOME_ORGANIC_ANION_TRANSPORT              -0.1713844        0.5766930
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE    -0.2490796        0.3021681
##                                            s.parkinsons s.prostate_cance
## REACTOME_ORGANIC_ANION_TRANSPORT              0.2998091        0.0021998
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE   -0.4946896       -0.0972380
##                                            s.rheumatoid_art    s.stroke
## REACTOME_ORGANIC_ANION_TRANSPORT                 -0.4320880  0.05112263
## REACTOME_SENSORY_PERCEPTION_OF_SALTY_TASTE        0.3603473 -0.60968441
rownames(top) <- gsub("REACTOME_","",rownames(top))
rownames(top) <- gsub("_"," ",rownames(top))
colnames(top) <- gsub("^s.","",colnames(top))
colnames(top) <- gsub("_"," ",colnames(top))
colfunc <- colorRampPalette(c("blue", "white", "red"))

heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(6,25),
  col=colfunc(25),cexRow=0.6,cexCol=0.8)

pdf("fig8b.pdf",height=9,width=7)
heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(6,22),
  col=colfunc(25),cexRow=0.5,cexCol=0.8)
dev.off()
## png 
##   2

Mitch calc incidence

Multi-comparison for incidence.

tic()
mres2 <- mitch_calc(x=m2,genesets=gs_symbols,minsetsize=5,cores=8, priority="effect")
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
toc() #29.5s
## 75.28 sec elapsed
mtable2 <- mres2$enrichment_result
head(mtable2,20)
##                                                                                          set
## 898                                                         REACTOME_ORGANIC_ANION_TRANSPORT
## 1007                                                   REACTOME_CD22_MEDIATED_BCR_REGULATION
## 971                                                            REACTOME_MELANIN_BIOSYNTHESIS
## 521  REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE
## 1393                                                         REACTOME_INTERLEUKIN_36_PATHWAY
## 1055                                  REACTOME_METAL_SEQUESTRATION_BY_ANTIMICROBIAL_PROTEINS
## 448                                                        REACTOME_SYNTHESIS_OF_LIPOXINS_LX
## 1578                                    REACTOME_REGULATION_OF_HMOX1_EXPRESSION_AND_ACTIVITY
## 421   REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_ENDOCRINE_COMMITTED_NEUROG3_PROGENITOR_CELLS
## 123                                            REACTOME_ACYL_CHAIN_REMODELING_OF_DAG_AND_TAG
## 165                                                    REACTOME_SULFIDE_OXIDATION_TO_SULFATE
## 1187                                                           REACTOME_FASL_CD95L_SIGNALING
## 1420               REACTOME_NR1H2_NR1H3_REGULATE_GENE_EXPRESSION_TO_LIMIT_CHOLESTEROL_UPTAKE
## 1331                                                                  REACTOME_HDL_CLEARANCE
## 422               REACTOME_REGULATION_OF_GENE_EXPRESSION_IN_EARLY_PANCREATIC_PRECURSOR_CELLS
## 1234                                                              REACTOME_SIGNALING_BY_MST1
## 213                                         REACTOME_LECTIN_PATHWAY_OF_COMPLEMENT_ACTIVATION
## 337                                                     REACTOME_GLUCOCORTICOID_BIOSYNTHESIS
## 1532                                                        REACTOME_DEFECTIVE_F9_ACTIVATION
## 1001                                                  REACTOME_DEFECTIVE_CSF2RB_CAUSES_SMDP5
##      setSize      pMANOVA s.alzheimers s.breast_cancer s.chronic_pain
## 898        5 0.0097627461  -0.31964367     -0.03148805    -0.04161440
## 1007       5 0.0324964590   0.87512044      0.19625489     0.51446232
## 971        5 0.0178976276   0.14845923     -0.50431779     0.03128806
## 521        5 0.0546638769  -0.43710572     -0.15631306     0.07602945
## 1393       7 0.0160223666  -0.11277922     -0.28037662    -0.35148052
## 1055       6 0.0004000794   0.12253988     -0.73417875    -0.41629926
## 448        6 0.0033788284   0.21083890      0.02313531     0.24209506
## 1578       5 0.1133421398   0.09802745      0.49179166    -0.06933915
## 421        5 0.1452669652   0.11906190      0.33809654     0.45439505
## 123        5 0.1426703530   0.01047178     -0.60963549     0.08031997
## 165        6 0.0878475646  -0.24930685     -0.20105147     0.20706635
## 1187       5 0.1555265536   0.40169076      0.61303518     0.35511317
## 1420       5 0.3549335662   0.15814926     -0.24850468     0.13533315
## 1331       5 0.1617196056  -0.09733661     -0.48211981    -0.14307790
## 422        8 0.0202653474   0.25739806      0.03206964     0.27913769
## 1234       5 0.1417669637  -0.09075539     -0.27093901    -0.31528043
## 213        8 0.0823675582  -0.55388881     -0.18294013    -0.25052275
## 337       10 0.0044797814  -0.44311497      0.08776651    -0.05582579
## 1532       5 0.2322157608   0.50709935      0.18171075     0.21921643
## 1001       7 0.0128918727  -0.32993506      0.04405195     0.13567532
##             s.CKD s.colorectal_can       s.COPD s.covid_hospital  s.diabetes
## 898   0.399818198      0.145150441  0.813307881      0.481919825  0.33904191
## 1007 -0.125843105     -0.429942732  0.068557404     -0.160839924  0.36674848
## 971  -0.327588401      0.032015271  0.077229343     -0.131933461 -0.29919098
## 521   0.105244978      0.103681484  0.704772293      0.320498137  0.38191074
## 1393  0.298298701      0.437246753  0.650662338     -0.236000000  0.04133766
## 1055 -0.353120313      0.283623472  0.179007015     -0.412753966  0.35915034
## 448   0.269578656     -0.005454298  0.211308577     -0.161507810 -0.13528173
## 1578 -0.140041814      0.033833288 -0.197509317     -0.615634942  0.11469866
## 421   0.017362058     -0.329733661  0.374911372     -0.025088628 -0.46675757
## 123   0.211780747      0.387055722  0.241868921     -0.224997727  0.58183801
## 165   0.006848174      0.123948911 -0.219474872     -0.482584125  0.50646183
## 1187  0.038796473     -0.612253432 -0.391909826      0.286701209 -0.55293155
## 1420 -0.294173257      0.193327879 -0.016271248     -0.431142623  0.57143896
## 1331 -0.033724207      0.544295973 -0.029815471     -0.148295609  0.51684392
## 422   0.317503068     -0.155677531 -0.008739034      0.003386518 -0.48490840
## 1234 -0.364439596      0.117243887  0.499645487     -0.154404145  0.60330879
## 213   0.109004955      0.183644711  0.412393745      0.154325197  0.05855948
## 337  -0.029813156     -0.229722235  0.369577670      0.607655589 -0.14606537
## 1532  0.113498773      0.397272975 -0.107844741      0.359694573  0.24652304
## 1001 -0.119363636      0.420519481  0.595701299      0.538038961 -0.17738961
##      s.heart_disease       s.ibd s.liver_cirrhosi s.long_covid s.lung_cancer
## 898     -0.170439051  0.18745569      -0.41038087   0.30760840   -0.51291701
## 1007     0.513626034 -0.05741296       0.29062812  -0.30299064    0.03061540
## 971     -0.290155440 -0.19243705      -0.62534315  -0.55425870    0.31938915
## 521     -0.319316426  0.80929006      -0.39190983  -0.10980820    0.41068994
## 1393    -0.054246753  0.46533766      -0.06483117  -0.09228571    0.33841558
## 1055     0.309849552  0.55029317      -0.09623805   0.06601215    0.21108131
## 448      0.179249428  0.20935412       0.24323137   0.03737709    0.40439071
## 1578     0.703426961 -0.39189165       0.33996909  -0.35245887   -0.12740660
## 421     -0.226615762 -0.27793837      -0.21063540   0.39369148    0.49740933
## 123      0.569439142 -0.32897009       0.26324880   0.13502409    0.46428506
## 165      0.434692362 -0.48793237       0.17988576   0.19497599   -0.06813327
## 1187    -0.002345241 -0.10089992       0.25055904  -0.23226979    0.33458776
## 1420     0.553240614  0.18636488       0.34976820  -0.27864740    0.21623489
## 1331     0.146550314  0.48579220       0.15854922   0.30957186   -0.12987910
## 422     -0.291285968 -0.15754125      -0.35069776   0.55004773    0.46544161
## 1234     0.625743114 -0.07302972      -0.32109808   0.26661213    0.21825289
## 213     -0.178633120  0.65796173      -0.48461294   0.02631938    0.23665848
## 337     -0.300695549  0.03526845      -0.55548484   0.08744829   -0.04184207
## 1532     0.436560313 -0.41738024       0.30660849  -0.01792564    0.25670394
## 1001    -0.072987013  0.33855844      -0.20636364   0.07089610    0.55210390
##      s.osteoarthritis s.ovarian_cancer s.parkinsons s.prostate_cance
## 898        0.59969094      -0.86312153   0.04817744       0.58271066
## 1007       0.25121353       0.45014090  -0.60132715      -0.29813653
## 971       -0.23150623      -0.38638306   0.58176529      -0.24854104
## 521        0.12807927      -0.53136988  -0.13047905       0.13073357
## 1393       0.52837662      -0.39461039  -0.32990909       0.36772727
## 1055      -0.03471054       0.24467070   0.44072239      -0.21179340
## 448       -0.59803342      -0.02063543  -0.46178204      -0.34743875
## 1578      -0.37927461       0.23063358  -0.24626852      -0.09437324
## 421        0.17125716       0.07990183   0.38451050      -0.03872375
## 123       -0.35189528       0.06310335  -0.15962185      -0.08690119
## 165       -0.08566277       0.53871794  -0.27560868      -0.20873294
## 1187       0.33480593       0.19300064   0.10404509      -0.04077811
## 1420      -0.07890192       0.61112626  -0.18643760      -0.16703936
## 1331       0.06443051       0.37287519  -0.19416417      -0.49726389
## 422       -0.43748579       0.37608528   0.27178508      -0.10089095
## 1234       0.03074266       0.21710754  -0.19032815      -0.33186074
## 213        0.24540888      -0.43370153   0.08618574       0.18180372
## 337        0.49043051      -0.09618584   0.05482566      -0.19093513
## 1532      -0.18643760       0.07352059   0.04370512      -0.66117626
## 1001       0.06689610       0.10102597   0.38283117       0.13683117
##      s.rheumatoid_art    s.stroke p.alzheimers p.breast_cancer p.chronic_pain
## 898       0.501390783  0.16816653 0.2157957177     0.902952936     0.87197963
## 1007      0.144441414  0.42774293 0.0007009901     0.447274089     0.04634316
## 971       0.526006727 -0.38352877 0.5653695414     0.050823601     0.90356627
## 521       0.003072448  0.01359876 0.0905183385     0.544981510     0.76844393
## 1393      0.628337662  0.08841558 0.6053590815     0.198934247     0.10731364
## 1055      0.366892414 -0.39914852 0.6032072365     0.001841956     0.07740765
## 448      -0.546702423  0.78828235 0.3711351490     0.921824404     0.30445047
## 1578     -0.173184256  0.45428597 0.7042463576     0.056850978     0.78831152
## 421      -0.302427052 -0.65935824 0.6447646653     0.190451501     0.07847116
## 123      -0.042068903  0.39238251 0.9676545649     0.018232846     0.75578143
## 165      -0.629289578  0.21206612 0.2902704310     0.393752780     0.37975590
## 1187      0.065703118  0.06133988 0.1198224495     0.017595480     0.16908724
## 1420     -0.428197437  0.08359240 0.5402680590     0.335898621     0.60024003
## 1331     -0.269520953  0.45312244 0.7062334865     0.061901904     0.57954748
## 422      -0.404427474 -0.08789036 0.2074134334     0.875188838     0.17156494
## 1234     -0.166348514 -0.01181711 0.7252622564     0.294096861     0.22212826
## 213       0.249920451 -0.14216555 0.0066663132     0.370245112     0.21980981
## 337       0.481920262 -0.20202755 0.0152446769     0.630813807     0.75984529
## 1532     -0.034505954  0.20150895 0.0495603995     0.481652784     0.39594591
## 1001      0.074935065 -0.31948052 0.1306190283     0.840051264     0.53419770
##          p.CKD p.colorectal_can      p.COPD p.covid_hospital p.diabetes
## 898  0.1215579       0.57406733 0.001634124     0.0620101370 0.18921476
## 1007 0.6260411       0.09592678 0.790642295     0.5333982510 0.15554910
## 971  0.2046011       0.90133625 0.764896330     0.6094277057 0.24662665
## 521  0.6836090       0.68806016 0.006346177     0.2145709709 0.13916207
## 1393 0.1717161       0.04513703 0.002869648     0.2795775648 0.84978547
## 1055 0.1341563       0.22893767 0.447660708     0.0799649354 0.12763572
## 448  0.2528221       0.98154167 0.370070448     0.4932865439 0.56607400
## 1578 0.5876194       0.89576466 0.444375740     0.0171213432 0.65693319
## 421  0.9463974       0.20165203 0.146553653     0.9226062479 0.07068384
## 123  0.4121649       0.13391432 0.348962286     0.3836059409 0.02424686
## 165  0.9768257       0.59904747 0.351862687     0.0406450174 0.03167935
## 1187 0.8805812       0.01774029 0.129104850     0.2669062425 0.03225458
## 1420 0.2546403       0.45407854 0.949760502     0.0950031758 0.02690319
## 1331 0.8960988       0.03504860 0.908084356     0.5657981595 0.04534091
## 422  0.1199192       0.44577112 0.965859263     0.9867664768 0.01754221
## 1234 0.1581680       0.64982357 0.053006103     0.5499031830 0.01947292
## 213  0.5934195       0.36840487 0.043391671     0.4497328308 0.77425511
## 337  0.8703239       0.20842584 0.042992843     0.0008755351 0.42381997
## 1532 0.6602957       0.12394820 0.676231888     0.1636547475 0.33976644
## 1001 0.5844634       0.05401358 0.006343274     0.0136920631 0.41637176
##      p.heart_disease       p.ibd p.liver_cirrhosi p.long_covid p.lung_cancer
## 898      0.509254863 0.467904134      0.112021328  0.233583557    0.04700340
## 1007     0.046699492 0.824063475      0.260410135  0.240677093    0.90562971
## 971      0.261186231 0.456160981      0.015448427  0.031842572    0.21616151
## 521      0.216266100 0.001723336      0.129104850  0.670680875    0.11175144
## 1393     0.803719433 0.032999046      0.766443674  0.672429624    0.12101612
## 1055     0.188727695 0.019575319      0.683108212  0.779468298    0.37058539
## 448      0.447045974 0.374513463      0.302186208  0.874025805    0.08626999
## 1578     0.006447184 0.129122609      0.188007555  0.172295924    0.62175759
## 421      0.380194926 0.281801419      0.414697747  0.127373625    0.05407804
## 123      0.027441864 0.202698123      0.308014766  0.601072684    0.07218843
## 165      0.065189178 0.038468954      0.445434582  0.408203210    0.77257417
## 1187     0.992754085 0.696005847      0.331918899  0.368422590    0.19509377
## 1420     0.032158229 0.470497798      0.175594825  0.280575647    0.40240256
## 1331     0.570379768 0.059941980      0.539244078  0.230612757    0.61500974
## 422      0.153667385 0.440343994      0.085849737  0.007054683    0.02262077
## 1234     0.015382703 0.777334012      0.213714042  0.301874997    0.39802564
## 213      0.381618076 0.001268767      0.017611120  0.897430955    0.24640476
## 337      0.099648455 0.846866203      0.002350342  0.632053017    0.81878070
## 1532     0.090921328 0.106033956      0.235106847  0.944660172    0.32019764
## 1001     0.738080196 0.120859221      0.344412617  0.745319557    0.01141615
##      p.osteoarthritis p.ovarian_cancer p.parkinsons p.prostate_cance
## 898       0.020214660     0.0008296455   0.85200665       0.02403466
## 1007      0.330657450     0.0813071903   0.01987620       0.24829583
## 971       0.369999040     0.1345915931   0.02426462       0.33582792
## 521       0.619918596     0.0396155802   0.61337726       0.61268528
## 1393      0.015479391     0.0706051298   0.13064932       0.09202163
## 1055      0.882945778     0.2993342680   0.06154774       0.36897339
## 448       0.011182726     0.9302488124   0.05012657       0.14053289
## 1578      0.141911480     0.3718058216   0.34026529       0.71477981
## 421       0.507223980     0.7570126686   0.13649092       0.88080333
## 123       0.172983043     0.8069545272   0.53650275       0.73648635
## 165       0.716330957     0.0222963662   0.24236296       0.37593246
## 1187      0.194802736     0.4548428920   0.68702402       0.87453081
## 1420      0.759959428     0.0179509122   0.47032464       0.51773971
## 1331      0.802977187     0.1487593607   0.45212847       0.05414838
## 422       0.032126397     0.0654655662   0.18313022       0.62120297
## 1234      0.905239277     0.4005063046   0.46111219       0.19875866
## 213       0.229368956     0.0336453221   0.67293577       0.37322526
## 337       0.007238764     0.5984133300   0.76401887       0.29578699
## 1532      0.470324641     0.7758772404   0.86560755       0.01045280
## 1001      0.759231122     0.6434644535   0.07942443       0.53072043
##      p.rheumatoid_art     p.stroke   s.dist        SD p.adjustMANOVA
## 898       0.052181858 0.5149184711 1.900249 0.4314334    0.043442897
## 1007      0.575939353 0.0976386973 1.673063 0.3767668    0.114998245
## 971       0.041653633 0.1374949184 1.564275 0.3438913    0.072742338
## 521       0.990507383 0.9580037563 1.553280 0.3611464    0.172944289
## 1393      0.003988694 0.6854154660 1.550521 0.3502816    0.066268831
## 1055      0.119628477 0.0904227571 1.521502 0.3576982    0.002546242
## 448       0.020386595 0.0008252684 1.475699 0.3465885    0.017612813
## 1578      0.502456985 0.0785428557 1.454509 0.3423921    0.302614298
## 421       0.241553120 0.0106665429 1.445577 0.3403565    0.361406601
## 123       0.870593671 0.1286437737 1.439684 0.3281687    0.357124482
## 165       0.007595294 0.3683571909 1.434760 0.3370802    0.252826170
## 1187      0.799168083 0.8122472020 1.410650 0.3270706    0.376658703
## 1420      0.097283008 0.7461672958 1.400691 0.3262996    0.642558893
## 1331      0.296631057 0.0793109758 1.396861 0.3245276    0.386526335
## 422       0.047602765 0.6668528760 1.358484 0.3201732    0.080020090
## 1234      0.519472803 0.9635018094 1.343887 0.3163733    0.357026617
## 213       0.220920575 0.4862385881 1.331837 0.3132589    0.240226520
## 337       0.008313992 0.2686176496 1.326620 0.3126598    0.022462336
## 1532      0.893704460 0.4352065260 1.325428 0.2946817    0.493520133
## 1001      0.731356272 0.1432586361 1.325190 0.2880779    0.054557873
#numsig manova
nrow(subset(mtable2,p.adjustMANOVA<0.05))
## [1] 382
sig <- subset(mtable2,p.adjustMANOVA<0.05)

Individual comparisons.

r1 <- lapply(l2,function(m) {
  m2 <- mitch_import(x=m,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
  mres <- mitch_calc(x=m2,genesets=gs_symbols,minsetsize=5,cores=8, priority="effect")
  mtable <- mres$enrichment_result
})
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
## The input is a single dataframe; one contrast only. Converting
##         it to a list for you.
## Note: Mean no. genes in input = 752722
## Note: no. genes in output = 22007
## Warning in mitch_import(x = m, DEtype = "prescored", geneTable = gt, geneIDcol = "CpG"): Warning: less than half of the input genes are also in the
##         output
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
nup <- lapply(r1,function(r) {
  ups <- subset(r,p.adjustANOVA<0.05 & s.dist>0)$set
  length(ups)
} )

ndn <- lapply(r1,function(r) {
  dns <- subset(r,p.adjustANOVA<0.05 & s.dist<0)$set
  length(dns)
} )

nums <- cbind(unlist(ndn),unlist(nup))
colnames(nums) <- c("dn","up")
nums
##                        dn  up
## alzheimers              1   0
## breast_cancer          11  53
## chronic_pain            8  93
## CKD                     1   7
## colorectal_cancer     115   4
## COPD                  306  94
## covid_hospitalisation   0   0
## diabetes               69  10
## heart_disease          11   0
## ibd                     8   6
## liver_cirrhosis        85 379
## long_covid              4  15
## lung_cancer             2   4
## osteoarthritis          1   3
## ovarian_cancer         44 126
## parkinsons              5  48
## prostate_cancer         5  16
## rheumatoid_arthritis    1   5
## stroke                 20  10
rownames(nums) <- gsub("ibd","IBD",rownames(nums))
rownames(nums) <- gsub("_"," ",rownames(nums))

par(mar = c(5.1, 10.1, 4.1, 2.1))
barplot(t(nums),beside=TRUE,horiz=TRUE,las=1,
  legend.text = c("down","up"),xlab="no. pathways")
abline(v=seq(0,200,50),lty=2,lwd=0.5,col="gray")

pdf("fig8c.pdf",height=6,width=4)
par(mar = c(5.1, 10.1, 4.1, 2.1))
barplot(t(nums),beside=TRUE,horiz=TRUE,las=1,
  legend.text = c("down","up"),xlab="no. pathways")
abline(v=seq(0,200,50),lty=2,lwd=0.5,col="gray")
dev.off()
## png 
##   2
r2 <- lapply(r1,function(r) {
  ups <- head(subset(r,p.adjustANOVA<0.05 & s.dist > 0.3)$set,3)
  dns <- head(subset(r,p.adjustANOVA<0.05 & s.dist < -0.3)$set,3)
  list("ups"=ups,"dns"=dns)
} )

r2
## $alzheimers
## $alzheimers$ups
## character(0)
## 
## $alzheimers$dns
## character(0)
## 
## 
## $breast_cancer
## $breast_cancer$ups
## [1] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"       
## [2] "REACTOME_CALNEXIN_CALRETICULIN_CYCLE"                           
## [3] "REACTOME_SARS_COV_1_ACTIVATES_MODULATES_INNATE_IMMUNE_RESPONSES"
## 
## $breast_cancer$dns
## [1] "REACTOME_METAL_SEQUESTRATION_BY_ANTIMICROBIAL_PROTEINS"
## 
## 
## $chronic_pain
## $chronic_pain$ups
## [1] "REACTOME_SIGNALING_BY_CSF3_G_CSF"    
## [2] "REACTOME_INSULIN_RECEPTOR_RECYCLING" 
## [3] "REACTOME_ONCOGENE_INDUCED_SENESCENCE"
## 
## $chronic_pain$dns
## [1] "REACTOME_CLASS_C_3_METABOTROPIC_GLUTAMATE_PHEROMONE_RECEPTORS"
## 
## 
## $CKD
## $CKD$ups
## [1] "REACTOME_CHEMOKINE_RECEPTORS_BIND_CHEMOKINES"
## 
## $CKD$dns
## character(0)
## 
## 
## $colorectal_cancer
## $colorectal_cancer$ups
## character(0)
## 
## $colorectal_cancer$dns
## [1] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"            
## [2] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"                          
## [3] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"
## 
## 
## $COPD
## $COPD$ups
## [1] "REACTOME_ORGANIC_ANION_TRANSPORT"                                                       
## [2] "REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE"
## [3] "REACTOME_HIGHLY_SODIUM_PERMEABLE_POSTSYNAPTIC_ACETYLCHOLINE_NICOTINIC_RECEPTORS"        
## 
## $COPD$dns
## [1] "REACTOME_RUNX1_REGULATES_TRANSCRIPTION_OF_GENES_INVOLVED_IN_INTERLEUKIN_SIGNALING"
## [2] "REACTOME_SYNTHESIS_OF_GDP_MANNOSE"                                                
## [3] "REACTOME_TLR3_MEDIATED_TICAM1_DEPENDENT_PROGRAMMED_CELL_DEATH"                    
## 
## 
## $covid_hospitalisation
## $covid_hospitalisation$ups
## character(0)
## 
## $covid_hospitalisation$dns
## character(0)
## 
## 
## $diabetes
## $diabetes$ups
## [1] "REACTOME_STRIATED_MUSCLE_CONTRACTION"                    
## [2] "REACTOME_REGULATION_OF_TP53_ACTIVITY_THROUGH_ACETYLATION"
## 
## $diabetes$dns
## [1] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"                          
## [2] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"            
## [3] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"
## 
## 
## $heart_disease
## $heart_disease$ups
## character(0)
## 
## $heart_disease$dns
## character(0)
## 
## 
## $ibd
## $ibd$ups
## [1] "REACTOME_CHEMOKINE_RECEPTORS_BIND_CHEMOKINES"
## 
## $ibd$dns
## [1] "REACTOME_INTERLEUKIN_12_SIGNALING"                                                          
## [2] "REACTOME_GENE_AND_PROTEIN_EXPRESSION_BY_JAK_STAT_SIGNALING_AFTER_INTERLEUKIN_12_STIMULATION"
## [3] "REACTOME_INTERLEUKIN_12_FAMILY_SIGNALING"                                                   
## 
## 
## $liver_cirrhosis
## $liver_cirrhosis$ups
## [1] "REACTOME_BETA_OXIDATION_OF_OCTANOYL_COA_TO_HEXANOYL_COA"    
## [2] "REACTOME_BETA_OXIDATION_OF_DECANOYL_COA_TO_OCTANOYL_COA_COA"
## [3] "REACTOME_ZINC_INFLUX_INTO_CELLS_BY_THE_SLC39_GENE_FAMILY"   
## 
## $liver_cirrhosis$dns
## [1] "REACTOME_CYP2E1_REACTIONS"                                      
## [2] "REACTOME_DIGESTION_OF_DIETARY_LIPID"                            
## [3] "REACTOME_ERYTHROCYTES_TAKE_UP_OXYGEN_AND_RELEASE_CARBON_DIOXIDE"
## 
## 
## $long_covid
## $long_covid$ups
## [1] "REACTOME_NEGATIVE_REGULATION_OF_FGFR1_SIGNALING"
## 
## $long_covid$dns
## [1] "REACTOME_CLASS_C_3_METABOTROPIC_GLUTAMATE_PHEROMONE_RECEPTORS"
## [2] "REACTOME_SENSORY_PERCEPTION_OF_TASTE"                         
## 
## 
## $lung_cancer
## $lung_cancer$ups
## character(0)
## 
## $lung_cancer$dns
## character(0)
## 
## 
## $osteoarthritis
## $osteoarthritis$ups
## character(0)
## 
## $osteoarthritis$dns
## character(0)
## 
## 
## $ovarian_cancer
## $ovarian_cancer$ups
## [1] "REACTOME_PROSTANOID_LIGAND_RECEPTORS"              
## [2] "REACTOME_ATF6_ATF6_ALPHA_ACTIVATES_CHAPERONE_GENES"
## [3] "REACTOME_INTERLEUKIN_6_SIGNALING"                  
## 
## $ovarian_cancer$dns
## [1] "REACTOME_ORGANIC_ANION_TRANSPORT" "REACTOME_ACTIVATION_OF_C3_AND_C5"
## [3] "REACTOME_PREDNISONE_ADME"        
## 
## 
## $parkinsons
## $parkinsons$ups
## [1] "REACTOME_SCAVENGING_BY_CLASS_A_RECEPTORS"           
## [2] "REACTOME_BETA_DEFENSINS"                            
## [3] "REACTOME_SIRT1_NEGATIVELY_REGULATES_RRNA_EXPRESSION"
## 
## $parkinsons$dns
## [1] "REACTOME_PASSIVE_TRANSPORT_BY_AQUAPORINS"
## [2] "REACTOME_AQUAPORIN_MEDIATED_TRANSPORT"   
## 
## 
## $prostate_cancer
## $prostate_cancer$ups
## [1] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"
## [2] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"              
## [3] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"
## 
## $prostate_cancer$dns
## [1] "REACTOME_SIGNALING_BY_CYTOSOLIC_FGFR1_FUSION_MUTANTS"
## [2] "REACTOME_FGFR1_MUTANT_RECEPTOR_ACTIVATION"           
## [3] "REACTOME_SIGNALING_BY_FGFR1_IN_DISEASE"              
## 
## 
## $rheumatoid_arthritis
## $rheumatoid_arthritis$ups
## character(0)
## 
## $rheumatoid_arthritis$dns
## character(0)
## 
## 
## $stroke
## $stroke$ups
## [1] "REACTOME_SYNTHESIS_OF_LIPOXINS_LX"                                     
## [2] "REACTOME_SIGNALING_BY_NODAL"                                           
## [3] "REACTOME_THE_ROLE_OF_NEF_IN_HIV_1_REPLICATION_AND_DISEASE_PATHOGENESIS"
## 
## $stroke$dns
## [1] "REACTOME_EUKARYOTIC_TRANSLATION_INITIATION"                          
## [2] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"            
## [3] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"
gsets <- unique(unname(unlist(r2)))
gsets
##  [1] "REACTOME_SARS_COV_2_MODULATES_HOST_TRANSLATION_MACHINERY"                                   
##  [2] "REACTOME_CALNEXIN_CALRETICULIN_CYCLE"                                                       
##  [3] "REACTOME_SARS_COV_1_ACTIVATES_MODULATES_INNATE_IMMUNE_RESPONSES"                            
##  [4] "REACTOME_METAL_SEQUESTRATION_BY_ANTIMICROBIAL_PROTEINS"                                     
##  [5] "REACTOME_SIGNALING_BY_CSF3_G_CSF"                                                           
##  [6] "REACTOME_INSULIN_RECEPTOR_RECYCLING"                                                        
##  [7] "REACTOME_ONCOGENE_INDUCED_SENESCENCE"                                                       
##  [8] "REACTOME_CLASS_C_3_METABOTROPIC_GLUTAMATE_PHEROMONE_RECEPTORS"                              
##  [9] "REACTOME_CHEMOKINE_RECEPTORS_BIND_CHEMOKINES"                                               
## [10] "REACTOME_SARS_COV_1_MODULATES_HOST_TRANSLATION_MACHINERY"                                   
## [11] "REACTOME_EUKARYOTIC_TRANSLATION_ELONGATION"                                                 
## [12] "REACTOME_SRP_DEPENDENT_COTRANSLATIONAL_PROTEIN_TARGETING_TO_MEMBRANE"                       
## [13] "REACTOME_ORGANIC_ANION_TRANSPORT"                                                           
## [14] "REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE"    
## [15] "REACTOME_HIGHLY_SODIUM_PERMEABLE_POSTSYNAPTIC_ACETYLCHOLINE_NICOTINIC_RECEPTORS"            
## [16] "REACTOME_RUNX1_REGULATES_TRANSCRIPTION_OF_GENES_INVOLVED_IN_INTERLEUKIN_SIGNALING"          
## [17] "REACTOME_SYNTHESIS_OF_GDP_MANNOSE"                                                          
## [18] "REACTOME_TLR3_MEDIATED_TICAM1_DEPENDENT_PROGRAMMED_CELL_DEATH"                              
## [19] "REACTOME_STRIATED_MUSCLE_CONTRACTION"                                                       
## [20] "REACTOME_REGULATION_OF_TP53_ACTIVITY_THROUGH_ACETYLATION"                                   
## [21] "REACTOME_INTERLEUKIN_12_SIGNALING"                                                          
## [22] "REACTOME_GENE_AND_PROTEIN_EXPRESSION_BY_JAK_STAT_SIGNALING_AFTER_INTERLEUKIN_12_STIMULATION"
## [23] "REACTOME_INTERLEUKIN_12_FAMILY_SIGNALING"                                                   
## [24] "REACTOME_BETA_OXIDATION_OF_OCTANOYL_COA_TO_HEXANOYL_COA"                                    
## [25] "REACTOME_BETA_OXIDATION_OF_DECANOYL_COA_TO_OCTANOYL_COA_COA"                                
## [26] "REACTOME_ZINC_INFLUX_INTO_CELLS_BY_THE_SLC39_GENE_FAMILY"                                   
## [27] "REACTOME_CYP2E1_REACTIONS"                                                                  
## [28] "REACTOME_DIGESTION_OF_DIETARY_LIPID"                                                        
## [29] "REACTOME_ERYTHROCYTES_TAKE_UP_OXYGEN_AND_RELEASE_CARBON_DIOXIDE"                            
## [30] "REACTOME_NEGATIVE_REGULATION_OF_FGFR1_SIGNALING"                                            
## [31] "REACTOME_SENSORY_PERCEPTION_OF_TASTE"                                                       
## [32] "REACTOME_PROSTANOID_LIGAND_RECEPTORS"                                                       
## [33] "REACTOME_ATF6_ATF6_ALPHA_ACTIVATES_CHAPERONE_GENES"                                         
## [34] "REACTOME_INTERLEUKIN_6_SIGNALING"                                                           
## [35] "REACTOME_ACTIVATION_OF_C3_AND_C5"                                                           
## [36] "REACTOME_PREDNISONE_ADME"                                                                   
## [37] "REACTOME_SCAVENGING_BY_CLASS_A_RECEPTORS"                                                   
## [38] "REACTOME_BETA_DEFENSINS"                                                                    
## [39] "REACTOME_SIRT1_NEGATIVELY_REGULATES_RRNA_EXPRESSION"                                        
## [40] "REACTOME_PASSIVE_TRANSPORT_BY_AQUAPORINS"                                                   
## [41] "REACTOME_AQUAPORIN_MEDIATED_TRANSPORT"                                                      
## [42] "REACTOME_SIGNALING_BY_CYTOSOLIC_FGFR1_FUSION_MUTANTS"                                       
## [43] "REACTOME_FGFR1_MUTANT_RECEPTOR_ACTIVATION"                                                  
## [44] "REACTOME_SIGNALING_BY_FGFR1_IN_DISEASE"                                                     
## [45] "REACTOME_SYNTHESIS_OF_LIPOXINS_LX"                                                          
## [46] "REACTOME_SIGNALING_BY_NODAL"                                                                
## [47] "REACTOME_THE_ROLE_OF_NEF_IN_HIV_1_REPLICATION_AND_DISEASE_PATHOGENESIS"                     
## [48] "REACTOME_EUKARYOTIC_TRANSLATION_INITIATION"
par(mar = c(5.1, 4.1, 4.1, 2.1))

Make a heatmap with these gene sets.

top <- mtable2[which(mtable2$set %in% gsets),]
top <- top[,c(1,4:17)]
rownames(top) <- top$set
top$set=NULL
head(top,2)
##                                                                                         s.alzheimers
## REACTOME_ORGANIC_ANION_TRANSPORT                                                          -0.3196437
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE   -0.4371057
##                                                                                         s.breast_cancer
## REACTOME_ORGANIC_ANION_TRANSPORT                                                            -0.03148805
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE     -0.15631306
##                                                                                         s.chronic_pain
## REACTOME_ORGANIC_ANION_TRANSPORT                                                           -0.04161440
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE     0.07602945
##                                                                                             s.CKD
## REACTOME_ORGANIC_ANION_TRANSPORT                                                        0.3998182
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE 0.1052450
##                                                                                         s.colorectal_can
## REACTOME_ORGANIC_ANION_TRANSPORT                                                               0.1451504
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE        0.1036815
##                                                                                            s.COPD
## REACTOME_ORGANIC_ANION_TRANSPORT                                                        0.8133079
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE 0.7047723
##                                                                                         s.covid_hospital
## REACTOME_ORGANIC_ANION_TRANSPORT                                                               0.4819198
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE        0.3204981
##                                                                                         s.diabetes
## REACTOME_ORGANIC_ANION_TRANSPORT                                                         0.3390419
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE  0.3819107
##                                                                                         s.heart_disease
## REACTOME_ORGANIC_ANION_TRANSPORT                                                             -0.1704391
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE      -0.3193164
##                                                                                             s.ibd
## REACTOME_ORGANIC_ANION_TRANSPORT                                                        0.1874557
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE 0.8092901
##                                                                                         s.liver_cirrhosi
## REACTOME_ORGANIC_ANION_TRANSPORT                                                              -0.4103809
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE       -0.3919098
##                                                                                         s.long_covid
## REACTOME_ORGANIC_ANION_TRANSPORT                                                           0.3076084
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE   -0.1098082
##                                                                                         s.lung_cancer
## REACTOME_ORGANIC_ANION_TRANSPORT                                                           -0.5129170
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE     0.4106899
##                                                                                         s.osteoarthritis
## REACTOME_ORGANIC_ANION_TRANSPORT                                                               0.5996909
## REACTOME_FICOLINS_BIND_TO_REPETITIVE_CARBOHYDRATE_STRUCTURES_ON_THE_TARGET_CELL_SURFACE        0.1280793
rownames(top) <- gsub("REACTOME_","",rownames(top))
rownames(top) <- gsub("_"," ",rownames(top))
colnames(top) <- gsub("^s.","",colnames(top))
colnames(top) <- gsub("_"," ",colnames(top))
colnames(top) <- gsub("ibd","IBD",colnames(top))

colfunc <- colorRampPalette(c("blue", "white", "red"))

heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(6,22),
  col=colfunc(25),cexRow=0.6,cexCol=0.7)

pdf("fig8d.pdf",height=9,width=7)
heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(6,20),
  col=colfunc(25),cexRow=0.5,cexCol=0.8)
dev.off()
## png 
##   2

Session information

save.image("multi_ewas_example.Rdata")

sessionInfo()
## R version 4.3.2 (2023-10-31)
## 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/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] parallel  stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] png_0.1-8                                          
##  [2] gridExtra_2.3                                      
##  [3] missMethyl_1.36.0                                  
##  [4] IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.1 
##  [5] beeswarm_0.4.0                                     
##  [6] kableExtra_1.3.4                                   
##  [7] gplots_3.1.3                                       
##  [8] mitch_1.15.0                                       
##  [9] tictoc_1.2                                         
## [10] HGNChelper_0.8.1                                   
## [11] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0
## [12] IlluminaHumanMethylation450kmanifest_0.4.0         
## [13] minfi_1.48.0                                       
## [14] bumphunter_1.44.0                                  
## [15] locfit_1.5-9.8                                     
## [16] iterators_1.0.14                                   
## [17] foreach_1.5.2                                      
## [18] Biostrings_2.70.1                                  
## [19] XVector_0.42.0                                     
## [20] SummarizedExperiment_1.32.0                        
## [21] Biobase_2.62.0                                     
## [22] MatrixGenerics_1.14.0                              
## [23] matrixStats_1.2.0                                  
## [24] GenomicRanges_1.54.1                               
## [25] GenomeInfoDb_1.38.2                                
## [26] IRanges_2.36.0                                     
## [27] S4Vectors_0.40.2                                   
## [28] BiocGenerics_0.48.1                                
## [29] eulerr_7.0.0                                       
## [30] limma_3.58.1                                       
## 
## loaded via a namespace (and not attached):
##   [1] splines_4.3.2             later_1.3.2              
##   [3] BiocIO_1.12.0             bitops_1.0-7             
##   [5] filelock_1.0.3            tibble_3.2.1             
##   [7] preprocessCore_1.64.0     XML_3.99-0.16            
##   [9] lifecycle_1.0.4           lattice_0.22-5           
##  [11] MASS_7.3-60               base64_2.0.1             
##  [13] scrime_1.3.5              magrittr_2.0.3           
##  [15] sass_0.4.8                rmarkdown_2.25           
##  [17] jquerylib_0.1.4           yaml_2.3.8               
##  [19] httpuv_1.6.13             doRNG_1.8.6              
##  [21] askpass_1.2.0             DBI_1.1.3                
##  [23] RColorBrewer_1.1-3        abind_1.4-5              
##  [25] zlibbioc_1.48.0           rvest_1.0.3              
##  [27] quadprog_1.5-8            purrr_1.0.2              
##  [29] RCurl_1.98-1.13           rappdirs_0.3.3           
##  [31] GenomeInfoDbData_1.2.11   genefilter_1.84.0        
##  [33] annotate_1.80.0           svglite_2.1.3            
##  [35] DelayedMatrixStats_1.24.0 codetools_0.2-19         
##  [37] DelayedArray_0.28.0       xml2_1.3.6               
##  [39] tidyselect_1.2.0          beanplot_1.3.1           
##  [41] BiocFileCache_2.10.1      webshot_0.5.5            
##  [43] illuminaio_0.44.0         GenomicAlignments_1.38.0 
##  [45] jsonlite_1.8.8            multtest_2.58.0          
##  [47] ellipsis_0.3.2            survival_3.5-7           
##  [49] systemfonts_1.0.5         tools_4.3.2              
##  [51] progress_1.2.3            Rcpp_1.0.11              
##  [53] glue_1.6.2                SparseArray_1.2.2        
##  [55] xfun_0.41                 dplyr_1.1.4              
##  [57] HDF5Array_1.30.0          fastmap_1.1.1            
##  [59] GGally_2.2.0              rhdf5filters_1.14.1      
##  [61] fansi_1.0.6               openssl_2.1.1            
##  [63] caTools_1.18.2            digest_0.6.33            
##  [65] R6_2.5.1                  mime_0.12                
##  [67] colorspace_2.1-0          gtools_3.9.5             
##  [69] biomaRt_2.58.0            RSQLite_2.3.4            
##  [71] utf8_1.2.4                tidyr_1.3.0              
##  [73] generics_0.1.3            data.table_1.14.10       
##  [75] rtracklayer_1.62.0        prettyunits_1.2.0        
##  [77] httr_1.4.7                htmlwidgets_1.6.4        
##  [79] S4Arrays_1.2.0            ggstats_0.5.1            
##  [81] pkgconfig_2.0.3           gtable_0.3.4             
##  [83] blob_1.2.4                siggenes_1.76.0          
##  [85] htmltools_0.5.7           echarts4r_0.4.5          
##  [87] scales_1.3.0              rstudioapi_0.15.0        
##  [89] knitr_1.45                reshape2_1.4.4           
##  [91] tzdb_0.4.0                rjson_0.2.21             
##  [93] nlme_3.1-163              curl_5.2.0               
##  [95] org.Hs.eg.db_3.18.0       cachem_1.0.8             
##  [97] rhdf5_2.46.1              stringr_1.5.1            
##  [99] KernSmooth_2.23-22        AnnotationDbi_1.64.1     
## [101] restfulr_0.0.15           GEOquery_2.70.0          
## [103] pillar_1.9.0              grid_4.3.2               
## [105] reshape_0.8.9             vctrs_0.6.5              
## [107] promises_1.2.1            dbplyr_2.4.0             
## [109] xtable_1.8-4              evaluate_0.23            
## [111] readr_2.1.4               GenomicFeatures_1.54.1   
## [113] cli_3.6.2                 compiler_4.3.2           
## [115] Rsamtools_2.18.0          rlang_1.1.2              
## [117] crayon_1.5.2              rngtools_1.5.2           
## [119] nor1mix_1.3-2             mclust_6.0.1             
## [121] plyr_1.8.9                stringi_1.8.3            
## [123] viridisLite_0.4.2         BiocParallel_1.36.0      
## [125] munsell_0.5.0             Matrix_1.6-1.1           
## [127] hms_1.1.3                 sparseMatrixStats_1.14.0 
## [129] bit64_4.0.5               ggplot2_3.4.4            
## [131] Rhdf5lib_1.24.1           KEGGREST_1.42.0          
## [133] statmod_1.5.0             shiny_1.8.0              
## [135] highr_0.10                memoise_2.0.1            
## [137] bslib_0.6.1               bit_4.0.5