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

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

GO sets 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")
}

getOption('timeout')
## [1] 60
options(timeout=180)

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_","",myfiles1))
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("c5.go.v2023.2.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
## 21.644 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()
## 372.899 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
## 110.023 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
## 155.456 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
## 216.195 sec elapsed
mtable1 <- mres1$enrichment_result
head(mtable1,20)
##                                                                                                                                          set
## 7530                                                                                                 GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX
## 7602                                                                                                            GOCC_B_CELL_RECEPTOR_COMPLEX
## 2468                                                                             GOBP_MICROGLIAL_CELL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE
## 2469                                                                                              GOBP_MICROGLIAL_CELL_MEDIATED_CYTOTOXICITY
## 7854                                                                                                                GOCC_FC_RECEPTOR_COMPLEX
## 8066                                                                                                          GOCC_MULTIVESICULAR_BODY_LUMEN
## 8778                                                                                                    GOMF_CCR1_CHEMOKINE_RECEPTOR_BINDING
## 9129                                                                                                           GOMF_HEMOGLOBIN_ALPHA_BINDING
## 9790                                                                                             GOMF_PROTEINASE_ACTIVATED_RECEPTOR_ACTIVITY
## 8593                                                                                                    GOMF_ALKANE_1_MONOOXYGENASE_ACTIVITY
## 7031                                                                                                       GOBP_STEM_CELL_FATE_SPECIFICATION
## 9206                                                                                                                        GOMF_IGG_BINDING
## 9243                                                                                                     GOMF_INTERLEUKIN_2_RECEPTOR_BINDING
## 7500                                                                                                         GOBP_XENOBIOTIC_GLUCURONIDATION
## 1557                                                                                                   GOBP_FOREBRAIN_NEURON_FATE_COMMITMENT
## 1537                                                                                                          GOBP_FLAVONOID_GLUCURONIDATION
## 9792                                                                                                GOMF_PROTEIN_ARGININE_DEIMINASE_ACTIVITY
## 1638                                                                                                      GOBP_GLIAL_CELL_FATE_SPECIFICATION
## 815  GOBP_CEREBELLAR_PURKINJE_CELL_GRANULE_CELL_PRECURSOR_CELL_SIGNALING_INVOLVED_IN_REGULATION_OF_GRANULE_CELL_PRECURSOR_CELL_PROLIFERATION
## 5063                                                                  GOBP_PROXIMAL_DISTAL_PATTERN_FORMATION_INVOLVED_IN_NEPHRON_DEVELOPMENT
##      setSize      pMANOVA s.alzheimers s.breast_cancer s.chronic_pain
## 7530       5 8.306666e-07   -0.4578856     -0.01768930    -0.45937642
## 7602       5 1.813229e-03   -0.4789746     -0.20818107     0.51578947
## 2468       5 6.565220e-04   -0.7558949      0.31526225     0.60030906
## 2469       5 1.126888e-04   -0.1648577      0.14118716     0.75969457
## 7854       5 1.407369e-05   -0.6021816      0.29084629     0.37892919
## 8066       6 3.461516e-04   -0.8896414      0.89223217    -0.36748330
## 8778       5 1.497541e-03   -0.5642578     -0.53658758     0.52558858
## 9129       5 5.128000e-06   -0.2866648     -0.05695846    -0.65730388
## 9790       5 2.363170e-03    0.6366330     -0.73311517    -0.05197709
## 8593       5 8.015867e-04   -0.1444232      0.56174893    -0.13426052
## 7031       6 2.617250e-03    0.3192885     -0.43543475     0.80369074
## 9206       7 2.677852e-06   -0.3904416     -0.14909091     0.32938961
## 9243       5 6.522409e-04    0.6367603     -0.52313426    -0.21352604
## 7500       6 9.385950e-05   -0.4821902     -0.28913837    -0.43585898
## 1557       7 1.899548e-03    0.1503117     -0.48776623     0.30851948
## 1537       5 4.371169e-03   -0.3988546     -0.22457958    -0.34667757
## 9792       5 2.425725e-02   -0.4425052      0.47341151    -0.40299973
## 1638       7 1.615875e-03   -0.2029740     -0.66303896     0.58357143
## 815        5 3.692451e-02   -0.2792110     -0.28030179     0.54920462
## 5063       5 6.958514e-03    0.1820744     -0.46021271     0.46770294
##            s.CKD s.colorectal_can     s.COPD  s.diabetes s.heart_disease
## 7530  0.79643669       0.35034997  0.7049359  0.90944460      0.77552950
## 7602  0.49404600      -0.18878284  0.1141169  0.56902100      0.56427597
## 2468 -0.55674939      -0.78885556 -0.2107263 -0.31935279     -0.08868285
## 2469 -0.72926098      -0.39561858 -0.5693119 -0.43094264     -0.26724843
## 7854 -0.18700118      -0.48141078 -0.1086628  0.59700027      0.45666758
## 8066 -0.01534779       0.01107525  0.6101995  0.02901383     -0.28301744
## 8778  0.03708754      -0.78961913 -0.1316789  0.01336242      0.21197164
## 9129  0.15224071      -0.79103718  0.5051177 -0.80483592     -0.40374511
## 9790 -0.23757840      -0.60956277 -0.6116898 -0.59156440     -0.11149895
## 8593  0.43554222      -0.12442505  0.9386783 -0.08275611      0.13455140
## 7031  0.22829265      -0.47850855 -0.5288547  0.20924806      0.37096799
## 9206 -0.71309091      -0.43596104 -0.5394935 -0.55381818     -0.18510390
## 9243  0.34725934      -0.65808563 -0.1405145 -0.26426688     -0.37020271
## 7500  0.06928473       0.11460085  0.6397739 -0.31775828     -0.56767117
## 1557  0.57774026      -0.32950649 -0.4150000  0.27553247      0.68118182
## 1537 -0.04643214       0.22781565  0.6595946 -0.49584583     -0.49410054
## 9792 -0.26023089       0.38372875  0.3660576  0.20759931     -0.31968003
## 1638  0.27902597      -0.36433766 -0.5231299  0.27874026      0.44442857
## 815   0.70686301      -0.71513499 -0.2251432 -0.05263158      0.51226252
## 5063  0.05161349      -0.30335424 -0.2616126 -0.24415962      0.60787201
##      s.lung_cancer s.osteoarthritis s.parkinsons s.prostate_cance
## 7530    0.58687392       0.13418780   0.24415962       0.46088537
## 7602    0.36943914       0.67579311  -0.25414053       0.44366876
## 2468   -0.51906190       0.46781202  -0.48408327       0.05979456
## 2469    0.08497409       0.28148350  -0.22463412      -0.69124625
## 7854    0.49710026       0.46553950  -0.07959276      -0.81408963
## 8066   -0.47209975       0.32930321  -0.14727361       0.56333803
## 8778   -0.58494682       0.65506772  -0.41061722      -0.12664303
## 9129   -0.19592764      -0.08348332  -0.06559404       0.55909463
## 9790   -0.43296064      -0.51728025  -0.22063449      -0.49200982
## 8593   -0.19883647       0.20563585   0.52995182       0.91846196
## 7031    0.16829538      -0.73352726  -0.39780010      -0.22720179
## 9206    0.15207792      -0.20963636  -0.25242857      -0.51103896
## 9243   -0.37689301      -0.28999182  -0.41070812      -0.53127897
## 7500    0.12547914      -0.31495538   0.60835114       0.38233111
## 1557    0.46785714      -0.72359740  -0.09380519      -0.44133766
## 1537    0.01968912      -0.29060994   0.54293246       0.33993273
## 9792   -0.60929006       0.78845559  -0.36673030       0.10071812
## 1638    0.50555844      -0.54033766  -0.10271429      -0.49964935
## 815    -0.01227161      -0.39630943  -0.47153895      -0.44059631
## 5063    0.53564221      -0.73449686  -0.09388237      -0.60061813
##      s.rheumatoid_art     s.stroke p.alzheimers p.breast_cancer p.chronic_pain
## 7530       0.82739751  0.703990546 0.0762047435    0.9453886569   0.0752532046
## 7602       0.74642305  0.665357695 0.0636223362    0.4201561366   0.0457823802
## 2468       0.36436688 -0.242432506 0.0034185891    0.2221549176   0.0200862117
## 2469       0.41952550 -0.525806745 0.5232228073    0.5845682142   0.0032602373
## 7854       0.57371148 -0.246923007 0.0197014254    0.2600524753   0.1422748182
## 8066      -0.15322031  0.109904095 0.0001604508    0.0001535198   0.1190338937
## 8778      -0.03725116 -0.589364603 0.0288809886    0.0377146482   0.0418161961
## 9129      -0.24654122  0.466757567 0.2669669079    0.8254337317   0.0109127437
## 9790      -0.02476139 -0.060849014 0.0136853026    0.0045238282   0.8404857347
## 8593       0.24221434  0.335878556 0.5759873915    0.0296008671   0.6031320521
## 7031       0.36425617 -0.419132464 0.1756110068    0.0647314859   0.0006506709
## 9206       0.23087013 -0.834935065 0.0736298199    0.4945584863   0.1312563495
## 9243      -0.70569948 -0.044159622 0.0136664856    0.0427812360   0.4083230425
## 7500      -0.48143266  0.576746512 0.0408093396    0.2200127267   0.0644711400
## 1557       0.04393506 -0.001064935 0.4910311333    0.0254258819   0.1574967746
## 1537      -0.56414871  0.548950095 0.1224585251    0.3844904763   0.1794419765
## 9792      -0.37252977 -0.236051268 0.0866057967    0.0667620637   0.1186208859
## 1638       0.08616883  0.085285714 0.3523958294    0.0023808366   0.0074974758
## 815       -0.09097355  0.170111808 0.2796039016    0.2777296095   0.0334361075
## 5063      -0.30351786 -0.037614762 0.4807761510    0.0747236754   0.0701153892
##            p.CKD p.colorectal_can      p.COPD   p.diabetes p.heart_disease
## 7530 0.002039674      0.174877587 0.006333990 0.0004280458     0.002669736
## 7602 0.055724319      0.464759218 0.658562645 0.0275556637     0.028875828
## 2468 0.031081516      0.002250397 0.414496393 0.2162137992     0.731290697
## 2469 0.004740024      0.125521465 0.027476455 0.0951566125     0.300722646
## 7854 0.468983864      0.062286347 0.673916806 0.0207821748     0.076989485
## 8066 0.948092331      0.962529765 0.009637970 0.9020504668     0.229933930
## 8778 0.885804517      0.002228304 0.610118062 0.9587329806     0.411743667
## 9129 0.555507422      0.002187800 0.050457595 0.0018274559     0.117940895
## 9790 0.357578378      0.018246697 0.017845326 0.0219712078     0.665915183
## 8593 0.091677435      0.629937152 0.000277537 0.7486205531     0.602347157
## 7031 0.332851147      0.042372520 0.024868736 0.3747554964     0.115574357
## 9206 0.001085080      0.045772654 0.013439417 0.0111630918     0.396395393
## 9243 0.178713060      0.010818468 0.586359305 0.3061475835     0.151692703
## 7500 0.768839108      0.626883759 0.006646936 0.1776900042     0.016034983
## 1557 0.008116668      0.131119578 0.057244859 0.2068053532     0.001800919
## 1537 0.857309319      0.377677485 0.010638538 0.0548382173     0.055697293
## 9792 0.313593808      0.137289940 0.156329231 0.4214561380     0.215743498
## 1638 0.201106524      0.095058458 0.016533477 0.2015682526     0.041721856
## 815  0.006192031      0.005614667 0.383298569 0.8385046427     0.047285409
## 5063 0.841586779      0.240113104 0.311031347 0.3444166241     0.018571352
##      p.lung_cancer p.osteoarthritis p.parkinsons p.prostate_cance
## 7530    0.02304433     0.6033283479  0.344416624     0.0742999617
## 7602    0.15253884     0.0088682149  0.325053979     0.0857808347
## 2468    0.04442401     0.0700500414  0.060847527     0.8168921835
## 2469    0.74211973     0.2757088010  0.384375031     0.0074296397
## 7854    0.05422760     0.0714218226  0.757923110     0.0016172679
## 8066    0.04521443     0.1624507532  0.532160683     0.0168605646
## 8778    0.02349824     0.0111864606  0.111814897     0.6238479644
## 9129    0.44803194     0.7464871406  0.799494392     0.0303792234
## 9790    0.09361737     0.0451592893  0.392897148     0.0567411243
## 8593    0.44132107     0.4258610254  0.040146049     0.0003749814
## 7031    0.47529949     0.0018592906  0.091516560     0.3351664720
## 9206    0.48595175     0.3368150929  0.247459968     0.0192056496
## 9243    0.14443113     0.2614552515  0.111735580     0.0396494053
## 7500    0.59454467     0.1815454989  0.009859677     0.1048400293
## 1557    0.03206175     0.0009143411  0.667357485     0.0431638898
## 1537    0.93922606     0.2604399550  0.035508130     0.1880547885
## 9792    0.01829872     0.0022620496  0.155569592     0.6965263483
## 1638    0.02053639     0.0132946893  0.637929567     0.0220605885
## 815     0.96209907     0.1248626167  0.067847177     0.0879731154
## 5063    0.03805320     0.0044485257  0.716198954     0.0200222549
##      p.rheumatoid_art     p.stroke   s.dist        SD p.adjustMANOVA
## 7530      0.001353798 0.0064046957 2.217695 0.4566315   2.156992e-05
## 7602      0.003844266 0.0099755836 1.824333 0.4085021   1.885279e-02
## 2468      0.158251016 0.3478403904 1.742234 0.4559562   8.005812e-03
## 2469      0.104250566 0.0417313136 1.720768 0.4454221   1.768281e-03
## 7854      0.026302168 0.3389834914 1.719685 0.4737908   2.785067e-04
## 8066      0.515733374 0.6410761515 1.697687 0.4705788   4.641516e-03
## 8778      0.885304190 0.0224689559 1.695447 0.4374281   1.604329e-02
## 9129      0.339730830 0.0706838353 1.695050 0.4483233   1.118648e-04
## 9790      0.923612622 0.8137219592 1.691189 0.3598489   2.356490e-02
## 8593      0.348274400 0.1933764391 1.686244 0.3831494   9.426475e-03
## 7031      0.122309621 0.0754122511 1.662604 0.4577017   2.559086e-02
## 9206      0.290162624 0.0001302616 1.660161 0.3483112   6.156654e-05
## 9243      0.006277396 0.8642234564 1.637702 0.3705200   7.973729e-03
## 7500      0.041126927 0.0144201968 1.597551 0.4422202   1.509869e-03
## 1557      0.840469948 0.9961070631 1.567864 0.4348461   1.957128e-02
## 1537      0.028911971 0.0335181305 1.556794 0.4300375   3.855296e-02
## 9792      0.149136045 0.3606771631 1.551975 0.4273906   1.421397e-01
## 1638      0.692997389 0.6959860572 1.550259 0.4273933   1.706091e-02
## 815       0.724628665 0.5100684069 1.547902 0.4225251   1.920563e-01
## 5063      0.239859613 0.8841925166 1.531482 0.4154246   5.588113e-02
#numsig manova
nrow(subset(mtable1,p.adjustMANOVA<0.05))
## [1] 1233
sig <- subset(mtable1,p.adjustMANOVA<0.05)

Individual comparisons.

r1 <- lapply(1:length(l1),function(i) {
  name=names(l1[i])
  m <- l1[[i]]
  m2 <- mitch_import(x=m,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
  mres <- mitch_calc(x=m2,genesets=gs_symbols,minsetsize=5,cores=2, priority="significance")
  mtable <- mres$enrichment_result
  #mitch_report(res=mres,outfile=paste("mitchreport_prev_",name,".html",sep="",overwrite=TRUE))
})
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
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
##  [1,]  15  25
##  [2,]  26  10
##  [3,]  27 131
##  [4,]  47 169
##  [5,] 250  24
##  [6,] 759 166
##  [7,]  36 328
##  [8,]  80 191
##  [9,]  42  38
## [10,] 336  98
## [11,] 135  11
## [12,]  80  20
## [13,]   2  65
## [14,]  83  14
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
## [[1]]
## [[1]]$ups
## character(0)
## 
## [[1]]$dns
## [1] "GOBP_CALCIUM_ION_REGULATED_EXOCYTOSIS"
## [2] "GOCC_MULTIVESICULAR_BODY_LUMEN"       
## 
## 
## [[2]]
## [[2]]$ups
## [1] "GOCC_MULTIVESICULAR_BODY_LUMEN"
## 
## [[2]]$dns
## [1] "GOBP_NEURON_FATE_COMMITMENT"          
## [2] "GOBP_EMBRYONIC_FORELIMB_MORPHOGENESIS"
## 
## 
## [[3]]
## [[3]]$ups
## [1] "GOBP_GRANULOCYTE_ACTIVATION"                                                                   
## [2] "GOBP_FOREBRAIN_REGIONALIZATION"                                                                
## [3] "GOBP_NEURON_FATE_SPECIFICATION"                                                                
## [4] "GOBP_TELENCEPHALON_REGIONALIZATION"                                                            
## [5] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_PEPTIDE_OR_POLYSACCHARIDE_ANTIGEN_VIA_MHC_CLASS_II"
## 
## [[3]]$dns
## [1] "GOBP_PLASMA_MEMBRANE_FUSION"                                                                    
## [2] "GOMF_P_TYPE_TRANSMEMBRANE_TRANSPORTER_ACTIVITY"                                                 
## [3] "GOBP_REGULATION_OF_XENOBIOTIC_DETOXIFICATION_BY_TRANSMEMBRANE_EXPORT_ACROSS_THE_PLASMA_MEMBRANE"
## [4] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"                                                  
## [5] "GOMF_HIGH_VOLTAGE_GATED_CALCIUM_CHANNEL_ACTIVITY"                                               
## 
## 
## [[4]]
## [[4]]$ups
## [1] "GOCC_RIBOSOMAL_SUBUNIT"                 
## [2] "GOCC_RIBOSOME"                          
## [3] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"
## [4] "GOBP_CYTOPLASMIC_TRANSLATION"           
## [5] "GOCC_LARGE_RIBOSOMAL_SUBUNIT"           
## 
## [[4]]$dns
## [1] "GOBP_INTESTINAL_CHOLESTEROL_ABSORPTION"       
## [2] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"      
## [3] "GOBP_I_KAPPAB_PHOSPHORYLATION"                
## [4] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"
## [5] "GOBP_LIPID_DIGESTION"                         
## 
## 
## [[5]]
## [[5]]$ups
## [1] "GOBP_SENSORY_PERCEPTION_OF_TASTE"                                           
## [2] "GOBP_DETECTION_OF_CHEMICAL_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION_OF_TASTE"
## [3] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"                                    
## [4] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"                              
## [5] "GOCC_PHOTORECEPTOR_DISC_MEMBRANE"                                           
## 
## [[5]]$dns
## [1] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT"
## [2] "GOBP_MONOCYTE_CHEMOTAXIS"              
## [3] "GOBP_NEURON_FATE_COMMITMENT"           
## [4] "GOBP_REGULATION_OF_MONOCYTE_CHEMOTAXIS"
## [5] "GOBP_FOREBRAIN_REGIONALIZATION"        
## 
## 
## [[6]]
## [[6]]$ups
## [1] "GOBP_DETECTION_OF_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION"
## [2] "GOBP_SENSORY_PERCEPTION_OF_SMELL"                         
## [3] "GOBP_SENSORY_PERCEPTION_OF_CHEMICAL_STIMULUS"             
## [4] "GOMF_OLFACTORY_RECEPTOR_ACTIVITY"                         
## [5] "GOBP_KERATINIZATION"                                      
## 
## [[6]]$dns
## [1] "GOBP_NEURON_FATE_COMMITMENT"             
## [2] "GOCC_SPECIFIC_GRANULE_MEMBRANE"          
## [3] "GOMF_STRUCTURAL_CONSTITUENT_OF_CHROMATIN"
## [4] "GOCC_TERTIARY_GRANULE_MEMBRANE"          
## [5] "GOCC_AZUROPHIL_GRANULE_MEMBRANE"         
## 
## 
## [[7]]
## [[7]]$ups
## [1] "GOCC_IMMUNOLOGICAL_SYNAPSE"                                                    
## [2] "GOBP_NUCLEAR_TRANSCRIBED_MRNA_CATABOLIC_PROCESS_NONSENSE_MEDIATED_DECAY"       
## [3] "GOBP_REGULATION_OF_INTRINSIC_APOPTOTIC_SIGNALING_PATHWAY_BY_P53_CLASS_MEDIATOR"
## [4] "GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX"                                       
## [5] "GOMF_OXIDOREDUCTASE_ACTIVITY_ACTING_ON_A_HEME_GROUP_OF_DONORS"                 
## 
## [[7]]$dns
## [1] "GOBP_KERATINIZATION"                          
## [2] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"
## [3] "GOCC_CATENIN_COMPLEX"                         
## [4] "GOBP_REGULATION_OF_PODOSOME_ASSEMBLY"         
## [5] "GOBP_PODOSOME_ASSEMBLY"                       
## 
## 
## [[8]]
## [[8]]$ups
## [1] "GOCC_RIBOSOMAL_SUBUNIT"                 
## [2] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"
## [3] "GOCC_RIBOSOME"                          
## [4] "GOCC_LARGE_RIBOSOMAL_SUBUNIT"           
## [5] "GOBP_CYTOPLASMIC_TRANSLATION"           
## 
## [[8]]$dns
## [1] "GOCC_RNAI_EFFECTOR_COMPLEX"                                               
## [2] "GOBP_INTERMEDIATE_FILAMENT_ORGANIZATION"                                  
## [3] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"                            
## [4] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"                                  
## [5] "GOBP_NEGATIVE_REGULATION_OF_VASCULAR_ENDOTHELIAL_GROWTH_FACTOR_PRODUCTION"
## 
## 
## [[9]]
## [[9]]$ups
## character(0)
## 
## [[9]]$dns
## [1] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"
## 
## 
## [[10]]
## [[10]]$ups
## [1] "GOBP_EOSINOPHIL_MIGRATION"           "GOMF_CCR_CHEMOKINE_RECEPTOR_BINDING"
## [3] "GOMF_CHEMOKINE_RECEPTOR_BINDING"     "GOBP_LYMPHOCYTE_CHEMOTAXIS"         
## [5] "GOMF_CHEMOKINE_ACTIVITY"            
## 
## [[10]]$dns
## [1] "GOBP_NEURON_FATE_COMMITMENT"                 
## [2] "GOBP_EMBRYONIC_APPENDAGE_MORPHOGENESIS"      
## [3] "GOBP_EMBRYONIC_SKELETAL_SYSTEM_MORPHOGENESIS"
## [4] "GOBP_CELL_FATE_SPECIFICATION"                
## [5] "GOBP_CELL_FATE_DETERMINATION"                
## 
## 
## [[11]]
## [[11]]$ups
## [1] "GOMF_OLFACTORY_RECEPTOR_ACTIVITY"               
## [2] "GOMF_MHC_CLASS_I_RECEPTOR_ACTIVITY"             
## [3] "GOMF_ALDITOL_NADPPLUS_1_OXIDOREDUCTASE_ACTIVITY"
## 
## [[11]]$dns
## [1] "GOBP_MIRNA_MEDIATED_GENE_SILENCING_BY_MRNA_DESTABILIZATION"    
## [2] "GOMF_NEUROPEPTIDE_RECEPTOR_BINDING"                            
## [3] "GOMF_CHEMOKINE_ACTIVITY"                                       
## [4] "GOBP_POSITIVE_REGULATION_OF_SMOOTH_MUSCLE_CELL_DIFFERENTIATION"
## [5] "GOBP_POSITIVE_REGULATION_OF_EPIDERMIS_DEVELOPMENT"             
## 
## 
## [[12]]
## [[12]]$ups
## [1] "GOBP_URONIC_ACID_METABOLIC_PROCESS"  
## [2] "GOBP_CELLULAR_GLUCURONIDATION"       
## [3] "GOMF_ALKANE_1_MONOOXYGENASE_ACTIVITY"
## 
## [[12]]$dns
## [1] "GOBP_NEURON_FATE_COMMITMENT"                
## [2] "GOBP_CEREBRAL_CORTEX_NEURON_DIFFERENTIATION"
## [3] "GOBP_CELL_DIFFERENTIATION_IN_SPINAL_CORD"   
## [4] "GOBP_NEUROTRANSMITTER_REUPTAKE"             
## [5] "GOBP_NEPHRIC_DUCT_MORPHOGENESIS"            
## 
## 
## [[13]]
## [[13]]$ups
## [1] "GOMF_C_C_CHEMOKINE_BINDING"                              
## [2] "GOBP_GRANULOCYTE_ACTIVATION"                             
## [3] "GOMF_CHEMOKINE_BINDING"                                  
## [4] "GOMF_G_PROTEIN_COUPLED_CHEMOATTRACTANT_RECEPTOR_ACTIVITY"
## [5] "GOCC_IMMUNOLOGICAL_SYNAPSE"                              
## 
## [[13]]$dns
## character(0)
## 
## 
## [[14]]
## [[14]]$ups
## [1] "GOMF_OXYGEN_BINDING"                         
## [2] "GOMF_ARACHIDONIC_ACID_MONOOXYGENASE_ACTIVITY"
## 
## [[14]]$dns
## [1] "GOMF_IGG_BINDING"                               
## [2] "GOBP_MULTIVESICULAR_BODY_SORTING_PATHWAY"       
## [3] "GOBP_FATTY_ACID_DERIVATIVE_BIOSYNTHETIC_PROCESS"
gsets <- unique(unname(unlist(r2)))
gsets
##  [1] "GOBP_CALCIUM_ION_REGULATED_EXOCYTOSIS"                                                          
##  [2] "GOCC_MULTIVESICULAR_BODY_LUMEN"                                                                 
##  [3] "GOBP_NEURON_FATE_COMMITMENT"                                                                    
##  [4] "GOBP_EMBRYONIC_FORELIMB_MORPHOGENESIS"                                                          
##  [5] "GOBP_GRANULOCYTE_ACTIVATION"                                                                    
##  [6] "GOBP_FOREBRAIN_REGIONALIZATION"                                                                 
##  [7] "GOBP_NEURON_FATE_SPECIFICATION"                                                                 
##  [8] "GOBP_TELENCEPHALON_REGIONALIZATION"                                                             
##  [9] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_PEPTIDE_OR_POLYSACCHARIDE_ANTIGEN_VIA_MHC_CLASS_II" 
## [10] "GOBP_PLASMA_MEMBRANE_FUSION"                                                                    
## [11] "GOMF_P_TYPE_TRANSMEMBRANE_TRANSPORTER_ACTIVITY"                                                 
## [12] "GOBP_REGULATION_OF_XENOBIOTIC_DETOXIFICATION_BY_TRANSMEMBRANE_EXPORT_ACROSS_THE_PLASMA_MEMBRANE"
## [13] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"                                                  
## [14] "GOMF_HIGH_VOLTAGE_GATED_CALCIUM_CHANNEL_ACTIVITY"                                               
## [15] "GOCC_RIBOSOMAL_SUBUNIT"                                                                         
## [16] "GOCC_RIBOSOME"                                                                                  
## [17] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"                                                        
## [18] "GOBP_CYTOPLASMIC_TRANSLATION"                                                                   
## [19] "GOCC_LARGE_RIBOSOMAL_SUBUNIT"                                                                   
## [20] "GOBP_INTESTINAL_CHOLESTEROL_ABSORPTION"                                                         
## [21] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"                                                        
## [22] "GOBP_I_KAPPAB_PHOSPHORYLATION"                                                                  
## [23] "GOBP_LIPID_DIGESTION"                                                                           
## [24] "GOBP_SENSORY_PERCEPTION_OF_TASTE"                                                               
## [25] "GOBP_DETECTION_OF_CHEMICAL_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION_OF_TASTE"                    
## [26] "GOCC_PHOTORECEPTOR_DISC_MEMBRANE"                                                               
## [27] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT"                                                         
## [28] "GOBP_MONOCYTE_CHEMOTAXIS"                                                                       
## [29] "GOBP_REGULATION_OF_MONOCYTE_CHEMOTAXIS"                                                         
## [30] "GOBP_DETECTION_OF_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION"                                      
## [31] "GOBP_SENSORY_PERCEPTION_OF_SMELL"                                                               
## [32] "GOBP_SENSORY_PERCEPTION_OF_CHEMICAL_STIMULUS"                                                   
## [33] "GOMF_OLFACTORY_RECEPTOR_ACTIVITY"                                                               
## [34] "GOBP_KERATINIZATION"                                                                            
## [35] "GOCC_SPECIFIC_GRANULE_MEMBRANE"                                                                 
## [36] "GOMF_STRUCTURAL_CONSTITUENT_OF_CHROMATIN"                                                       
## [37] "GOCC_TERTIARY_GRANULE_MEMBRANE"                                                                 
## [38] "GOCC_AZUROPHIL_GRANULE_MEMBRANE"                                                                
## [39] "GOCC_IMMUNOLOGICAL_SYNAPSE"                                                                     
## [40] "GOBP_NUCLEAR_TRANSCRIBED_MRNA_CATABOLIC_PROCESS_NONSENSE_MEDIATED_DECAY"                        
## [41] "GOBP_REGULATION_OF_INTRINSIC_APOPTOTIC_SIGNALING_PATHWAY_BY_P53_CLASS_MEDIATOR"                 
## [42] "GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX"                                                        
## [43] "GOMF_OXIDOREDUCTASE_ACTIVITY_ACTING_ON_A_HEME_GROUP_OF_DONORS"                                  
## [44] "GOCC_CATENIN_COMPLEX"                                                                           
## [45] "GOBP_REGULATION_OF_PODOSOME_ASSEMBLY"                                                           
## [46] "GOBP_PODOSOME_ASSEMBLY"                                                                         
## [47] "GOCC_RNAI_EFFECTOR_COMPLEX"                                                                     
## [48] "GOBP_INTERMEDIATE_FILAMENT_ORGANIZATION"                                                        
## [49] "GOBP_NEGATIVE_REGULATION_OF_VASCULAR_ENDOTHELIAL_GROWTH_FACTOR_PRODUCTION"                      
## [50] "GOBP_EOSINOPHIL_MIGRATION"                                                                      
## [51] "GOMF_CCR_CHEMOKINE_RECEPTOR_BINDING"                                                            
## [52] "GOMF_CHEMOKINE_RECEPTOR_BINDING"                                                                
## [53] "GOBP_LYMPHOCYTE_CHEMOTAXIS"                                                                     
## [54] "GOMF_CHEMOKINE_ACTIVITY"                                                                        
## [55] "GOBP_EMBRYONIC_APPENDAGE_MORPHOGENESIS"                                                         
## [56] "GOBP_EMBRYONIC_SKELETAL_SYSTEM_MORPHOGENESIS"                                                   
## [57] "GOBP_CELL_FATE_SPECIFICATION"                                                                   
## [58] "GOBP_CELL_FATE_DETERMINATION"                                                                   
## [59] "GOMF_MHC_CLASS_I_RECEPTOR_ACTIVITY"                                                             
## [60] "GOMF_ALDITOL_NADPPLUS_1_OXIDOREDUCTASE_ACTIVITY"                                                
## [61] "GOBP_MIRNA_MEDIATED_GENE_SILENCING_BY_MRNA_DESTABILIZATION"                                     
## [62] "GOMF_NEUROPEPTIDE_RECEPTOR_BINDING"                                                             
## [63] "GOBP_POSITIVE_REGULATION_OF_SMOOTH_MUSCLE_CELL_DIFFERENTIATION"                                 
## [64] "GOBP_POSITIVE_REGULATION_OF_EPIDERMIS_DEVELOPMENT"                                              
## [65] "GOBP_URONIC_ACID_METABOLIC_PROCESS"                                                             
## [66] "GOBP_CELLULAR_GLUCURONIDATION"                                                                  
## [67] "GOMF_ALKANE_1_MONOOXYGENASE_ACTIVITY"                                                           
## [68] "GOBP_CEREBRAL_CORTEX_NEURON_DIFFERENTIATION"                                                    
## [69] "GOBP_CELL_DIFFERENTIATION_IN_SPINAL_CORD"                                                       
## [70] "GOBP_NEUROTRANSMITTER_REUPTAKE"                                                                 
## [71] "GOBP_NEPHRIC_DUCT_MORPHOGENESIS"                                                                
## [72] "GOMF_C_C_CHEMOKINE_BINDING"                                                                     
## [73] "GOMF_CHEMOKINE_BINDING"                                                                         
## [74] "GOMF_G_PROTEIN_COUPLED_CHEMOATTRACTANT_RECEPTOR_ACTIVITY"                                       
## [75] "GOMF_OXYGEN_BINDING"                                                                            
## [76] "GOMF_ARACHIDONIC_ACID_MONOOXYGENASE_ACTIVITY"                                                   
## [77] "GOMF_IGG_BINDING"                                                                               
## [78] "GOBP_MULTIVESICULAR_BODY_SORTING_PATHWAY"                                                       
## [79] "GOBP_FATTY_ACID_DERIVATIVE_BIOSYNTHETIC_PROCESS"
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
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX   -0.4578856      -0.0176893
## GOCC_MULTIVESICULAR_BODY_LUMEN            -0.8896414       0.8922322
##                                         s.chronic_pain       s.CKD
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX     -0.4593764  0.79643669
## GOCC_MULTIVESICULAR_BODY_LUMEN              -0.3674833 -0.01534779
##                                         s.colorectal_can    s.COPD s.diabetes
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX       0.35034997 0.7049359 0.90944460
## GOCC_MULTIVESICULAR_BODY_LUMEN                0.01107525 0.6101995 0.02901383
##                                         s.heart_disease s.lung_cancer
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX       0.7755295     0.5868739
## GOCC_MULTIVESICULAR_BODY_LUMEN               -0.2830174    -0.4720998
##                                         s.osteoarthritis s.parkinsons
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX        0.1341878    0.2441596
## GOCC_MULTIVESICULAR_BODY_LUMEN                 0.3293032   -0.1472736
##                                         s.prostate_cance s.rheumatoid_art
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX        0.4608854        0.8273975
## GOCC_MULTIVESICULAR_BODY_LUMEN                 0.5633380       -0.1532203
##                                          s.stroke
## GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX 0.7039905
## GOCC_MULTIVESICULAR_BODY_LUMEN          0.1099041
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
## 252.689 sec elapsed
mtable2 <- mres2$enrichment_result
head(mtable2,20)
##                                                                                     set
## 7530                                            GOCC_ALPHA_BETA_T_CELL_RECEPTOR_COMPLEX
## 208  GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_ENDOGENOUS_LIPID_ANTIGEN_VIA_MHC_CLASS_IB
## 9310                                                         GOMF_LIPID_ANTIGEN_BINDING
## 2469                                         GOBP_MICROGLIAL_CELL_MEDIATED_CYTOTOXICITY
## 5063             GOBP_PROXIMAL_DISTAL_PATTERN_FORMATION_INVOLVED_IN_NEPHRON_DEVELOPMENT
## 7500                                                    GOBP_XENOBIOTIC_GLUCURONIDATION
## 7602                                                       GOCC_B_CELL_RECEPTOR_COMPLEX
## 8778                                               GOMF_CCR1_CHEMOKINE_RECEPTOR_BINDING
## 1537                                                     GOBP_FLAVONOID_GLUCURONIDATION
## 9288                                          GOMF_LARGE_RIBOSOMAL_SUBUNIT_RRNA_BINDING
## 9792                                           GOMF_PROTEIN_ARGININE_DEIMINASE_ACTIVITY
## 9790                                        GOMF_PROTEINASE_ACTIVATED_RECEPTOR_ACTIVITY
## 8781                                               GOMF_CCR6_CHEMOKINE_RECEPTOR_BINDING
## 7791                                                                      GOCC_EGG_COAT
## 9634                                               GOMF_O_PALMITOYLTRANSFERASE_ACTIVITY
## 3769                                                          GOBP_PEPTIDE_MODIFICATION
## 5215                                   GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION
## 8455                                                              GOCC_TROPONIN_COMPLEX
## 5276                              GOBP_REGULATION_OF_BINDING_OF_SPERM_TO_ZONA_PELLUCIDA
## 7031                                                  GOBP_STEM_CELL_FATE_SPECIFICATION
##      setSize      pMANOVA s.alzheimers s.breast_cancer s.chronic_pain
## 7530       5 2.967828e-10    0.2978457      0.40050904   0.3838014726
## 208        5 9.617044e-06   -0.3270794     -0.31298973  -0.6218707390
## 9310       5 9.617044e-06   -0.3270794     -0.31298973  -0.6218707390
## 2469       5 4.288610e-03    0.7246069      0.34245978   0.5989273702
## 5063       5 3.019845e-03    0.1081174      0.03914190   0.4442323425
## 7500       6 1.407061e-04    0.1882793     -0.22258079  -0.3994818417
## 7602       5 4.868775e-03    0.4322153     -0.17492955   0.7985274066
## 8778       5 3.933367e-03    0.4438142      0.56113081  -0.0002908826
## 1537       5 6.362728e-03    0.2569766     -0.36736660  -0.4634487774
## 9288       5 2.774158e-02   -0.3303518      0.01641669   0.5125715844
## 9792       5 2.387506e-02   -0.3413144     -0.13493319  -0.0125443142
## 9790       5 1.029881e-02    0.6654668     -0.28295609  -0.3616580311
## 8781       5 4.200578e-03   -0.3023180      0.12547950  -0.3192255250
## 7791       5 1.456380e-02   -0.6824289     -0.09031906  -0.0689573675
## 9634       5 5.537396e-02    0.2025998     -0.22592492   0.2079447323
## 3769       5 6.971777e-02    0.4957913     -0.44615944  -0.0205799473
## 5215       6 1.431455e-02   -0.4479342      0.35974122   0.2117176492
## 8455       9 5.829701e-08   -0.5954784      0.16638886   0.1814912467
## 5276       5 4.586549e-02   -0.4940460     -0.04615944   0.0317425689
## 7031       6 5.657710e-03    0.2360650      0.29760768   0.0006969380
##            s.CKD s.colorectal_can      s.COPD s.covid_hospital  s.diabetes
## 7530  0.84801382      -0.71497137  0.64074175       0.53398782  0.04792292
## 208   0.21521680      -0.59298246  0.33196982      -0.20352695 -0.48119262
## 9310  0.21521680      -0.59298246  0.33196982      -0.20352695 -0.48119262
## 2469 -0.58685574      -0.10451777 -0.21230797       0.47310245  0.17954731
## 5063  0.39492773      -0.04386874 -0.09015544       0.04146896 -0.71271703
## 7500  0.56936806      -0.24701907  0.33122737      -0.30295593 -0.13961487
## 7602 -0.28179256      -0.32640669  0.15520407      -0.19952732  0.39354604
## 8778  0.55289519      -0.54920462  0.19370966       0.43692392 -0.78736479
## 1537  0.51308063      -0.12984274  0.28844650      -0.21036269 -0.21298064
## 9288 -0.19234615      -0.46903009 -0.53562403      -0.42321607 -0.60983547
## 9792  0.03116080       0.19683665  0.69560949       0.04143260  0.46075811
## 9790  0.07239342       0.27995637 -0.37183892       0.04052359 -0.13160622
## 8781  0.39027361      -0.38603763 -0.08161076       0.12467957 -0.42041633
## 7791  0.41767112      -0.15349514  0.57569312       0.54196891  0.18727388
## 9634 -0.21334424       0.02674302 -0.14220525       0.07922916  0.33626034
## 3769 -0.52027997       0.48111990 -0.40461776      -0.36416689  0.51371693
## 5215 -0.12075209      -0.12816084 -0.29363817       0.24107995 -0.22673212
## 8455  0.51366286       0.51774404  0.33094928      -0.05552020  0.56000040
## 5276  0.32486138       0.32126170  0.58738297       0.05055904 -0.20558131
## 7031  0.32534885      -0.04424041 -0.02131721       0.33556050 -0.30256200
##      s.heart_disease       s.ibd s.liver_cirrhosi s.long_covid s.lung_cancer
## 7530     -0.75942187 -0.19670939       0.65446778  0.452049814   -0.82961549
## 208      -0.73044269  0.23219707      -0.85104990 -0.052431597   -0.76313062
## 9310     -0.73044269  0.23219707      -0.85104990 -0.052431597   -0.76313062
## 2469      0.37096628 -0.13289701      -0.08262885 -0.051468048    0.19370966
## 5063     -0.34182347 -0.57160258      -0.42703391  0.241814381    0.40874466
## 7500     -0.57657985  0.37121040      -0.47855401 -0.682059906   -0.56971653
## 7602      0.18654668 -0.19492773       0.49259158 -0.146732115   -0.22036179
## 8778     -0.14193255 -0.04797746      -0.13155168 -0.443314244    0.41343514
## 1537     -0.51722571  0.35300427      -0.57805654 -0.651413508   -0.50420871
## 9288     -0.38865558  0.21623489       0.05606763  0.359694573    0.28324698
## 9792      0.04663212  0.56478502      -0.55349514 -0.072938824   -0.03481502
## 9790      0.56960276 -0.60710844       0.12371603 -0.008162894   -0.39892737
## 8781     -0.52004363  0.01541678       0.17958367 -0.189819107    0.59265521
## 7791      0.22372512  0.11137169      -0.38140169  0.336933006    0.26219435
## 9634      0.40976275 -0.29142805       0.39505500 -0.281592582   -0.41832561
## 3769      0.58492864  0.14113262       0.30300882 -0.104026907   -0.19932733
## 5215     -0.02821084 -0.55836856       0.19426390  0.596260776   -0.13699377
## 8455      0.18308735  0.02894203      -0.40741077  0.595347052   -0.18818883
## 5276     -0.12240705  0.45232252      -0.22210708 -0.200527225   -0.08959186
## 7031     -0.12070663 -0.14058452      -0.11378271  0.599684863    0.50315895
##      s.osteoarthritis s.ovarian_cancer s.parkinsons s.prostate_cance
## 7530       0.69371875      -0.13804200   0.51509863      -0.35422234
## 208       -0.38094719      -0.07066630   0.65199527      -0.25675848
## 9310      -0.38094719      -0.07066630   0.65199527      -0.25675848
## 2469      -0.32775202       0.45948550  -0.69153713      -0.83563312
## 5063      -0.72338878       0.07190255   0.37374784       0.07550223
## 7500       0.04531612      -0.64889475  -0.43485902       0.03449843
## 7602       0.59287338       0.44208708  -0.17176620      -0.58305609
## 8778      -0.17005727      -0.25664940   0.45792201      -0.14513226
## 1537       0.12651577      -0.61730752  -0.39616399      -0.04837742
## 9288      -0.05410417       0.14467776   0.69520953       0.38816471
## 9792       0.48481047      -0.74209617   0.33793292       0.49246432
## 9790      -0.79550950       0.15614944  -0.02014362      -0.33911463
## 8781       0.24539587      -0.66175802   0.66388510       0.08011999
## 7791       0.09113717      -0.41901645  -0.27088447       0.15949459
## 9634      -0.58698300       0.12715208  -0.02457958      -0.79329152
## 3769      -0.26366694       0.23661485  -0.46112172      -0.26272157
## 5215      -0.30891020       0.83231065   0.21805069       0.05931549
## 8455       0.56131365      -0.49031730   0.01208191      -0.14613450
## 5276       0.14364149      -0.76342151  -0.04479593       0.03946914
## 7031      -0.40164841       0.60198779   0.19518810      -0.58888232
##      s.rheumatoid_art    s.stroke p.alzheimers p.breast_cancer p.chronic_pain
## 7530       0.63025180  0.78125625  0.248757684      0.12091536    0.137215461
## 208        0.48008363  0.17274793  0.205305462      0.22550562    0.016029495
## 9310       0.48008363  0.17274793  0.205305462      0.22550562    0.016029495
## 2469      -0.32407963  0.20147259  0.005013531      0.18479283    0.020374321
## 5063      -0.84105081  0.07952004  0.675459852      0.87952600    0.085383533
## 7500       0.31472812  0.06354257  0.424491631      0.34508916    0.090154006
## 7602      -0.02665212  0.68415599  0.094183576      0.49816024    0.001984834
## 8778       0.47666576  0.04117807  0.085678162      0.02978058    0.999101270
## 1537       0.29064630 -0.07188437  0.319683817      0.15485360    0.072703230
## 9288      -0.29613671 -0.46119444  0.200808072      0.94931204    0.047152062
## 9792       0.25630397  0.33620580  0.186266048      0.60131768    0.961257482
## 9790      -0.35680393 -0.32037088  0.009963399      0.27320463    0.161367217
## 8781       0.26128534  0.54647759  0.241722932      0.62703912    0.216396893
## 7791       0.76133079 -0.28424689  0.008222481      0.72653000    0.789449571
## 9634      -0.80967185  0.13238796  0.432724911      0.38164903    0.420683978
## 3769       0.24085083  0.40809017  0.054864895      0.08403624    0.936482050
## 5215      -0.64627365 -0.23979213  0.057415442      0.12701027    0.369144675
## 8455       0.21798951  0.11629340  0.001976611      0.38738833    0.345773342
## 5276       0.85184983 -0.26048541  0.055724319      0.85813845    0.902172418
## 7031      -0.72640638 -0.02480190  0.316654207      0.20679716    0.997641228
##            p.CKD p.colorectal_can      p.COPD p.covid_hospital  p.diabetes
## 7530 0.001022773      0.005625600 0.013089209       0.03865187 0.852779549
## 208  0.404621645      0.021655454 0.198611108       0.43062199 0.062405034
## 9310 0.404621645      0.021655454 0.198611108       0.43062199 0.062405034
## 2469 0.023048573      0.685677927 0.411002094       0.06694017 0.486886687
## 5063 0.126183019      0.865109229 0.727005600       0.87242322 0.005778196
## 7500 0.015721492      0.294719770 0.160009731       0.19875419 0.553700816
## 7602 0.275181941      0.206238927 0.547838104       0.43973574 0.127514269
## 8778 0.032265935      0.033436108 0.453187703       0.09065251 0.002294111
## 1537 0.046933121      0.615108741 0.264005451       0.41530216 0.409521330
## 9288 0.456373776      0.069323713 0.038059732       0.10123836 0.018194802
## 9792 0.903956598      0.445928593 0.007063258       0.87253412 0.074379973
## 9790 0.779223585      0.278322207 0.149891596       0.87530752 0.610315370
## 8781 0.130710799      0.134940410 0.751984577       0.62923710 0.103517042
## 7791 0.105790732      0.552254509 0.025787581       0.03583595 0.468335861
## 9634 0.408722239      0.917520399 0.581862225       0.75899465 0.192870629
## 3769 0.043927157      0.062444638 0.117148699       0.15847950 0.046660649
## 5215 0.608503831      0.586691144 0.212917673       0.30648271 0.336166535
## 8455 0.007617060      0.007149591 0.085564983       0.77302809 0.003621616
## 5276 0.208395039      0.213480763 0.022925703       0.84478155 0.425983766
## 7031 0.167555380      0.851143185 0.927950431       0.15461430 0.199338673
##      p.heart_disease      p.ibd p.liver_cirrhosi p.long_covid p.lung_cancer
## 7530     0.003271376 0.44622272     0.0112609266  0.080024487   0.001313946
## 208      0.004672764 0.36857255     0.0009809045  0.839109868   0.003122823
## 9310     0.004672764 0.36857255     0.0009809045  0.839109868   0.003122823
## 2469     0.150850146 0.60681737     0.7489940988  0.842027283   0.453187703
## 5063     0.185610218 0.02685953     0.0981956471  0.349070979   0.113458722
## 7500     0.014448508 0.11533667     0.0423529173  0.003810332   0.015657786
## 7602     0.470064970 0.45035213     0.0564490453  0.569901693   0.393482341
## 8778     0.582586470 0.85261392     0.6104633702  0.086031515   0.109376655
## 1537     0.045181959 0.17163292     0.0251852562  0.011646892   0.050873683
## 9288     0.132314099 0.40240256     0.8281209751  0.163654747   0.272711828
## 9792     0.856701390 0.02873164     0.0320790646  0.777603871   0.892758121
## 9790     0.027397444 0.01871962     0.6318890379  0.974783574   0.122390372
## 8781     0.044023193 0.95239556     0.4867984691  0.462311796   0.021727968
## 7791     0.386301880 0.66627342     0.1396897671  0.191981807   0.309956559
## 9634     0.112562646 0.25910038     0.1260609498  0.275522772   0.105245096
## 3769     0.023502562 0.58471334     0.2406488717  0.687075816   0.440194317
## 5215     0.904748244 0.01785311     0.4099173409  0.011425267   0.561169461
## 8455     0.341548041 0.88049013     0.0343003463  0.001981162   0.328265800
## 5276     0.635499260 0.07984259     0.3897462276  0.437446985   0.728644576
## 7031     0.608638760 0.55095024     0.6293462654  0.010960894   0.032808348
##      p.osteoarthritis p.ovarian_cancer p.parkinsons p.prostate_cance
## 7530      0.007219984     0.5929645344  0.046073576      0.170159095
## 208       0.140162229     0.7843589772  0.011572482      0.320094834
## 9310      0.140162229     0.7843589772  0.011572482      0.320094834
## 2469      0.204375072     0.0751839623  0.007404694      0.001211211
## 5063      0.005087430     0.7806821487  0.147810974      0.770004260
## 7500      0.847567551     0.0059100155  0.065086199      0.883655974
## 7602      0.021679602     0.0869038275  0.505962469      0.023951116
## 8778      0.510204064     0.3203004723  0.076181419      0.574115294
## 1537      0.624196655     0.0168222629  0.125001097      0.851399480
## 9288      0.834050944     0.5753150251  0.007096155      0.132803493
## 9792      0.060460812     0.0040542958  0.190666156      0.056512830
## 9790      0.002064437     0.5454025095  0.937825962      0.189119868
## 8781      0.341979179     0.0103852095  0.010141386      0.756370207
## 7791      0.724153596     0.1046715722  0.294194061      0.536827629
## 9634      0.023018863     0.6224540444  0.924171771      0.002124797
## 3769      0.307246977     0.3595316074  0.074151556      0.308984654
## 5215      0.190071561     0.0004139711  0.354996557      0.801345718
## 8455      0.003543336     0.0108564572  0.949955208      0.447766610
## 5276      0.578054833     0.0031114362  0.862286426      0.878526573
## 7031      0.088422759     0.0106580808  0.407693445      0.012485719
##      p.rheumatoid_art    p.stroke   s.dist        SD p.adjustMANOVA
## 7530     0.0146586664 0.002481473 2.481886 0.5459289   1.036309e-08
## 208      0.0630112555 0.503534226 2.042330 0.4411952   1.607998e-04
## 9310     0.0630112555 0.503534226 2.042330 0.4411952   1.607998e-04
## 2469     0.2094919805 0.435289388 1.870952 0.4408620   3.321482e-02
## 5063     0.0011251185 0.758137381 1.767848 0.4090072   2.481609e-02
## 7500     0.1818608063 0.787516908 1.748228 0.3835745   1.781638e-03
## 7602     0.9177997559 0.008061467 1.740831 0.3979147   3.654617e-02
## 8778     0.0649102972 0.873310514 1.711486 0.4004272   3.086064e-02
## 1537     0.2603803168 0.780736184 1.708672 0.3700332   4.521763e-02
## 9288     0.2514831982 0.074105942 1.683992 0.3925347   1.426252e-01
## 9792     0.3209522294 0.192942828 1.681577 0.3804905   1.273544e-01
## 9790     0.1670668575 0.214753062 1.662727 0.3753188   6.762971e-02
## 8781     0.3116369937 0.034323922 1.646742 0.3876947   3.268146e-02
## 7791     0.0031941293 0.271022449 1.634065 0.3785010   8.857584e-02
## 9634     0.0017146700 0.608195791 1.627284 0.3699823   2.333243e-01
## 3769     0.3509947557 0.114037731 1.625987 0.3827579   2.742901e-01
## 5215     0.0061138609 0.309073833 1.625006 0.3823339   8.732983e-02
## 8455     0.2574548429 0.545761971 1.612936 0.3627795   1.474283e-06
## 5276     0.0009701404 0.313120735 1.601081 0.3768928   2.045553e-01
## 7031     0.0020587850 0.916212941 1.598014 0.3752068   4.111082e-02
#numsig manova
nrow(subset(mtable2,p.adjustMANOVA<0.05))
## [1] 1474
sig <- subset(mtable2,p.adjustMANOVA<0.05)

Individual comparisons.

r1 <- lapply(1:length(l2),function(i) {
  name=names(l2[i])
  m <- l2[[i]]
  m2 <- mitch_import(x=m,DEtype="prescored",geneTable=gt,geneIDcol="CpG")
  mres <- mitch_calc(x=m2,genesets=gs_symbols,minsetsize=5,cores=2, priority="significance")
  mtable <- mres$enrichment_result
  #mitch_report(res=mres,outfile=paste("mitchreport_incid_",name,".html",sep="",overwrite=TRUE))
})
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
## 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: When prioritising by significance (ie: small
##             p-values), large effect sizes might be missed.
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
##  [1,]   4   6
##  [2,]  52 191
##  [3,]  31 207
##  [4,]   0   7
##  [5,]  48   2
##  [6,] 511 309
##  [7,]  13   4
##  [8,]  42  44
##  [9,]  19  51
## [10,]  48  22
## [11,] 513 892
## [12,]  21  75
## [13,]  41 102
## [14,]   0   0
## [15,] 123 445
## [16,]   4  16
## [17,]  30  23
## [18,] 119  32
## [19,]  32  37
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
## [[1]]
## [[1]]$ups
## character(0)
## 
## [[1]]$dns
## character(0)
## 
## 
## [[2]]
## [[2]]$ups
## [1] "GOBP_T_CELL_CYTOKINE_PRODUCTION"     
## [2] "GOBP_FORELIMB_MORPHOGENESIS"         
## [3] "GOBP_T_HELPER_1_TYPE_IMMUNE_RESPONSE"
## 
## [[2]]$dns
## [1] "GOBP_KERATINIZATION"                                                        
## [2] "GOMF_METALLOCARBOXYPEPTIDASE_ACTIVITY"                                      
## [3] "GOBP_NEGATIVE_REGULATION_OF_LEUKOCYTE_ADHESION_TO_VASCULAR_ENDOTHELIAL_CELL"
## 
## 
## [[3]]
## [[3]]$ups
## [1] "GOBP_MEGAKARYOCYTE_DIFFERENTIATION"                
## [2] "GOBP_POSITIVE_REGULATION_OF_DNA_RECOMBINATION"     
## [3] "GOCC_PROTON_TRANSPORTING_TWO_SECTOR_ATPASE_COMPLEX"
## 
## [[3]]$dns
## [1] "GOMF_ODORANT_BINDING"                            
## [2] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"         
## [3] "GOMF_HIGH_VOLTAGE_GATED_CALCIUM_CHANNEL_ACTIVITY"
## 
## 
## [[4]]
## [[4]]$ups
## character(0)
## 
## [[4]]$dns
## character(0)
## 
## 
## [[5]]
## [[5]]$ups
## character(0)
## 
## [[5]]$dns
## [1] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"
## [2] "GOCC_RIBOSOMAL_SUBUNIT"                 
## [3] "GOBP_CYTOPLASMIC_TRANSLATION"           
## 
## 
## [[6]]
## [[6]]$ups
## [1] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"       
## [2] "GOBP_KERATINIZATION"                                 
## [3] "GOMF_LIGAND_GATED_MONOATOMIC_CATION_CHANNEL_ACTIVITY"
## 
## [[6]]$dns
## [1] "GOCC_ENDOPLASMIC_RETICULUM_PROTEIN_CONTAINING_COMPLEX"
## [2] "GOMF_STRUCTURAL_CONSTITUENT_OF_CHROMATIN"             
## [3] "GOCC_CATALYTIC_STEP_2_SPLICEOSOME"                    
## 
## 
## [[7]]
## [[7]]$ups
## [1] "GOMF_C_C_CHEMOKINE_BINDING"
## 
## [[7]]$dns
## character(0)
## 
## 
## [[8]]
## [[8]]$ups
## [1] "GOBP_SENSORY_PERCEPTION_OF_TASTE"               
## [2] "GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY"
## 
## [[8]]$dns
## [1] "GOCC_RIBOSOMAL_SUBUNIT"                 
## [2] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"
## [3] "GOBP_CYTOPLASMIC_TRANSLATION"           
## 
## 
## [[9]]
## [[9]]$ups
## [1] "GOBP_RESPONSE_TO_ZINC_ION_STARVATION"
## 
## [[9]]$dns
## [1] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_ENDOGENOUS_ANTIGEN"
## [2] "GOCC_T_CELL_RECEPTOR_COMPLEX"                                  
## [3] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_VIA_MHC_CLASS_IB"     
## 
## 
## [[10]]
## [[10]]$ups
## [1] "GOBP_RESPONSE_TO_CHEMOKINE"      "GOMF_CHEMOKINE_ACTIVITY"        
## [3] "GOMF_CHEMOKINE_RECEPTOR_BINDING"
## 
## [[10]]$dns
## character(0)
## 
## 
## [[11]]
## [[11]]$ups
## [1] "GOCC_CHROMOSOME_CENTROMERIC_REGION"         
## [2] "GOCC_SPLICEOSOMAL_COMPLEX"                  
## [3] "GOBP_DNA_TEMPLATED_TRANSCRIPTION_ELONGATION"
## 
## [[11]]$dns
## [1] "GOMF_VOLTAGE_GATED_CHANNEL_ACTIVITY"                  
## [2] "GOMF_VOLTAGE_GATED_MONOATOMIC_CATION_CHANNEL_ACTIVITY"
## [3] "GOMF_POTASSIUM_CHANNEL_ACTIVITY"                      
## 
## 
## [[12]]
## [[12]]$ups
## [1] "GOBP_EMBRYONIC_DIGESTIVE_TRACT_DEVELOPMENT"
## [2] "GOBP_FOREBRAIN_REGIONALIZATION"            
## [3] "GOBP_DOPAMINERGIC_NEURON_DIFFERENTIATION"  
## 
## [[12]]$dns
## [1] "GOMF_TASTE_RECEPTOR_ACTIVITY"                                                         
## [2] "GOMF_BITTER_TASTE_RECEPTOR_ACTIVITY"                                                  
## [3] "GOBP_CALCIUM_DEPENDENT_CELL_CELL_ADHESION_VIA_PLASMA_MEMBRANE_CELL_ADHESION_MOLECULES"
## 
## 
## [[13]]
## [[13]]$ups
## [1] "GOBP_POSITIVE_REGULATION_OF_BIOMINERAL_TISSUE_DEVELOPMENT"
## [2] "GOBP_REGULATION_OF_ADENYLATE_CYCLASE_ACTIVITY"            
## [3] "GOBP_ACTIVATION_OF_ADENYLATE_CYCLASE_ACTIVITY"            
## 
## [[13]]$dns
## [1] "GOCC_T_CELL_RECEPTOR_COMPLEX"        
## [2] "GOMF_GROWTH_HORMONE_RECEPTOR_BINDING"
## 
## 
## [[14]]
## [[14]]$ups
## character(0)
## 
## [[14]]$dns
## character(0)
## 
## 
## [[15]]
## [[15]]$ups
## [1] "GOBP_DOPAMINERGIC_NEURON_DIFFERENTIATION"
## [2] "GOMF_PROSTANOID_RECEPTOR_ACTIVITY"       
## [3] "GOBP_TELENCEPHALON_REGIONALIZATION"      
## 
## [[15]]$dns
## [1] "GOBP_DETECTION_OF_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION"
## [2] "GOBP_SENSORY_PERCEPTION_OF_CHEMICAL_STIMULUS"             
## [3] "GOMF_OLFACTORY_RECEPTOR_ACTIVITY"                         
## 
## 
## [[16]]
## [[16]]$ups
## character(0)
## 
## [[16]]$dns
## [1] "GOMF_NEUROPEPTIDE_ACTIVITY"
## 
## 
## [[17]]
## [[17]]$ups
## [1] "GOCC_CYTOSOLIC_SMALL_RIBOSOMAL_SUBUNIT"
## [2] "GOCC_SMALL_SUBUNIT_PROCESSOME"         
## [3] "GOCC_SMALL_RIBOSOMAL_SUBUNIT"          
## 
## [[17]]$dns
## [1] "GOBP_NEUTROPHIL_DEGRANULATION"                         
## [2] "GOBP_NEUTROPHIL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE"
## 
## 
## [[18]]
## [[18]]$ups
## [1] "GOBP_KERATINIZATION"                           
## [2] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS" 
## [3] "GOBP_CALCIUM_ION_IMPORT_ACROSS_PLASMA_MEMBRANE"
## 
## [[18]]$dns
## [1] "GOBP_NEURON_FATE_COMMITMENT"    "GOBP_FOREBRAIN_REGIONALIZATION"
## [3] "GOBP_URETER_DEVELOPMENT"       
## 
## 
## [[19]]
## [[19]]$ups
## [1] "GOCC_IMMUNOLOGICAL_SYNAPSE"                
## [2] "GOMF_LIGAND_GATED_CALCIUM_CHANNEL_ACTIVITY"
## 
## [[19]]$dns
## [1] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT"
## [2] "GOMF_C_ACYLTRANSFERASE_ACTIVITY"       
## [3] "GOCC_BOX_H_ACA_RNP_COMPLEX"
gsets <- unique(unname(unlist(r2)))
gsets
##  [1] "GOBP_T_CELL_CYTOKINE_PRODUCTION"                                                      
##  [2] "GOBP_FORELIMB_MORPHOGENESIS"                                                          
##  [3] "GOBP_T_HELPER_1_TYPE_IMMUNE_RESPONSE"                                                 
##  [4] "GOBP_KERATINIZATION"                                                                  
##  [5] "GOMF_METALLOCARBOXYPEPTIDASE_ACTIVITY"                                                
##  [6] "GOBP_NEGATIVE_REGULATION_OF_LEUKOCYTE_ADHESION_TO_VASCULAR_ENDOTHELIAL_CELL"          
##  [7] "GOBP_MEGAKARYOCYTE_DIFFERENTIATION"                                                   
##  [8] "GOBP_POSITIVE_REGULATION_OF_DNA_RECOMBINATION"                                        
##  [9] "GOCC_PROTON_TRANSPORTING_TWO_SECTOR_ATPASE_COMPLEX"                                   
## [10] "GOMF_ODORANT_BINDING"                                                                 
## [11] "GOBP_SENSORY_PERCEPTION_OF_BITTER_TASTE"                                              
## [12] "GOMF_HIGH_VOLTAGE_GATED_CALCIUM_CHANNEL_ACTIVITY"                                     
## [13] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"                                              
## [14] "GOCC_RIBOSOMAL_SUBUNIT"                                                               
## [15] "GOBP_CYTOPLASMIC_TRANSLATION"                                                         
## [16] "GOMF_STRUCTURAL_CONSTITUENT_OF_SKIN_EPIDERMIS"                                        
## [17] "GOMF_LIGAND_GATED_MONOATOMIC_CATION_CHANNEL_ACTIVITY"                                 
## [18] "GOCC_ENDOPLASMIC_RETICULUM_PROTEIN_CONTAINING_COMPLEX"                                
## [19] "GOMF_STRUCTURAL_CONSTITUENT_OF_CHROMATIN"                                             
## [20] "GOCC_CATALYTIC_STEP_2_SPLICEOSOME"                                                    
## [21] "GOMF_C_C_CHEMOKINE_BINDING"                                                           
## [22] "GOBP_SENSORY_PERCEPTION_OF_TASTE"                                                     
## [23] "GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY"                                      
## [24] "GOBP_RESPONSE_TO_ZINC_ION_STARVATION"                                                 
## [25] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_OF_ENDOGENOUS_ANTIGEN"                       
## [26] "GOCC_T_CELL_RECEPTOR_COMPLEX"                                                         
## [27] "GOBP_ANTIGEN_PROCESSING_AND_PRESENTATION_VIA_MHC_CLASS_IB"                            
## [28] "GOBP_RESPONSE_TO_CHEMOKINE"                                                           
## [29] "GOMF_CHEMOKINE_ACTIVITY"                                                              
## [30] "GOMF_CHEMOKINE_RECEPTOR_BINDING"                                                      
## [31] "GOCC_CHROMOSOME_CENTROMERIC_REGION"                                                   
## [32] "GOCC_SPLICEOSOMAL_COMPLEX"                                                            
## [33] "GOBP_DNA_TEMPLATED_TRANSCRIPTION_ELONGATION"                                          
## [34] "GOMF_VOLTAGE_GATED_CHANNEL_ACTIVITY"                                                  
## [35] "GOMF_VOLTAGE_GATED_MONOATOMIC_CATION_CHANNEL_ACTIVITY"                                
## [36] "GOMF_POTASSIUM_CHANNEL_ACTIVITY"                                                      
## [37] "GOBP_EMBRYONIC_DIGESTIVE_TRACT_DEVELOPMENT"                                           
## [38] "GOBP_FOREBRAIN_REGIONALIZATION"                                                       
## [39] "GOBP_DOPAMINERGIC_NEURON_DIFFERENTIATION"                                             
## [40] "GOMF_TASTE_RECEPTOR_ACTIVITY"                                                         
## [41] "GOMF_BITTER_TASTE_RECEPTOR_ACTIVITY"                                                  
## [42] "GOBP_CALCIUM_DEPENDENT_CELL_CELL_ADHESION_VIA_PLASMA_MEMBRANE_CELL_ADHESION_MOLECULES"
## [43] "GOBP_POSITIVE_REGULATION_OF_BIOMINERAL_TISSUE_DEVELOPMENT"                            
## [44] "GOBP_REGULATION_OF_ADENYLATE_CYCLASE_ACTIVITY"                                        
## [45] "GOBP_ACTIVATION_OF_ADENYLATE_CYCLASE_ACTIVITY"                                        
## [46] "GOMF_GROWTH_HORMONE_RECEPTOR_BINDING"                                                 
## [47] "GOMF_PROSTANOID_RECEPTOR_ACTIVITY"                                                    
## [48] "GOBP_TELENCEPHALON_REGIONALIZATION"                                                   
## [49] "GOBP_DETECTION_OF_STIMULUS_INVOLVED_IN_SENSORY_PERCEPTION"                            
## [50] "GOBP_SENSORY_PERCEPTION_OF_CHEMICAL_STIMULUS"                                         
## [51] "GOMF_OLFACTORY_RECEPTOR_ACTIVITY"                                                     
## [52] "GOMF_NEUROPEPTIDE_ACTIVITY"                                                           
## [53] "GOCC_CYTOSOLIC_SMALL_RIBOSOMAL_SUBUNIT"                                               
## [54] "GOCC_SMALL_SUBUNIT_PROCESSOME"                                                        
## [55] "GOCC_SMALL_RIBOSOMAL_SUBUNIT"                                                         
## [56] "GOBP_NEUTROPHIL_DEGRANULATION"                                                        
## [57] "GOBP_NEUTROPHIL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE"                               
## [58] "GOBP_CALCIUM_ION_IMPORT_ACROSS_PLASMA_MEMBRANE"                                       
## [59] "GOBP_NEURON_FATE_COMMITMENT"                                                          
## [60] "GOBP_URETER_DEVELOPMENT"                                                              
## [61] "GOCC_IMMUNOLOGICAL_SYNAPSE"                                                           
## [62] "GOMF_LIGAND_GATED_CALCIUM_CHANNEL_ACTIVITY"                                           
## [63] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT"                                               
## [64] "GOMF_C_ACYLTRANSFERASE_ACTIVITY"                                                      
## [65] "GOCC_BOX_H_ACA_RNP_COMPLEX"
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:22)]
rownames(top) <- top$set
top$set=NULL
head(top,2)
##                                                 s.alzheimers s.breast_cancer
## GOCC_T_CELL_RECEPTOR_COMPLEX                      0.20664377       0.1277341
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY  -0.01209256      -0.2702005
##                                                 s.chronic_pain      s.CKD
## GOCC_T_CELL_RECEPTOR_COMPLEX                        0.06777373  0.4299844
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY    -0.04396963 -0.1331818
##                                                 s.colorectal_can      s.COPD
## GOCC_T_CELL_RECEPTOR_COMPLEX                          -0.4088178  0.34126090
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY        0.4612265 -0.04248761
##                                                 s.covid_hospital s.diabetes
## GOCC_T_CELL_RECEPTOR_COMPLEX                           0.5241919 -0.1622051
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY       -0.2009820  0.6802655
##                                                 s.heart_disease      s.ibd
## GOCC_T_CELL_RECEPTOR_COMPLEX                         -0.6168815 -0.2074482
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY       0.1515388 -0.1240533
##                                                 s.liver_cirrhosi s.long_covid
## GOCC_T_CELL_RECEPTOR_COMPLEX                           0.2825736    0.1664650
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY        0.5511297   -0.2108469
##                                                 s.lung_cancer s.osteoarthritis
## GOCC_T_CELL_RECEPTOR_COMPLEX                       -0.5723869        0.2850987
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY    -0.4617993       -0.1061145
##                                                 s.ovarian_cancer s.parkinsons
## GOCC_T_CELL_RECEPTOR_COMPLEX                          -0.1095963    0.3905611
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY       -0.1200982   -0.5388189
##                                                 s.prostate_cance
## GOCC_T_CELL_RECEPTOR_COMPLEX                          -0.1413323
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY       -0.4407692
##                                                 s.rheumatoid_art  s.stroke
## GOCC_T_CELL_RECEPTOR_COMPLEX                           0.2725778 0.5711068
## GOMF_HISTONE_H3K4_TRIMETHYLTRANSFERASE_ACTIVITY       -0.2124290 0.2552439
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.7)
dev.off()
## png 
##   2

Make a special heatmap for the cancer bioinformamtics symposium.

names(r1) <- names(l2)

r3 <- r1[grep("cancer",names(r1))]

r4 <- lapply(r3,function(r) {
  r <- subset(r,p.adjustANOVA<0.05)
  ups <- head(r[order(-r$s.dist),],3)$set
  dns <- head(r[order(r$s.dist),],3)$set
  list("ups"=ups,"dns"=dns)
} )

r4
## $breast_cancer
## $breast_cancer$ups
## [1] "GOBP_RESPONSE_TO_SELENIUM_ION"                        
## [2] "GOBP_NEGATIVE_REGULATION_OF_IMMUNOGLOBULIN_PRODUCTION"
## [3] "GOBP_LATERAL_MESODERM_DEVELOPMENT"                    
## 
## $breast_cancer$dns
## [1] "GOBP_NEGATIVE_REGULATION_OF_LEUKOCYTE_ADHESION_TO_VASCULAR_ENDOTHELIAL_CELL"
## [2] "GOMF_ATPASE_COUPLED_INORGANIC_ANION_TRANSMEMBRANE_TRANSPORTER_ACTIVITY"     
## [3] "GOBP_POSITIVE_REGULATION_OF_LIPOPROTEIN_PARTICLE_CLEARANCE"                 
## 
## 
## $colorectal_cancer
## $colorectal_cancer$ups
## [1] "GOCC_RNAI_EFFECTOR_COMPLEX"                   
## [2] "GOBP_REGULATORY_NCRNA_MEDIATED_GENE_SILENCING"
## [3] "GOCC_CHROMOSOME"                              
## 
## $colorectal_cancer$dns
## [1] "GOCC_CYTOSOLIC_SMALL_RIBOSOMAL_SUBUNIT" 
## [2] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT" 
## [3] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"
## 
## 
## $lung_cancer
## $lung_cancer$ups
## [1] "GOBP_METANEPHRIC_GLOMERULUS_VASCULATURE_DEVELOPMENT"
## [2] "GOBP_CARDIAC_CHAMBER_FORMATION"                     
## [3] "GOMF_BMP_RECEPTOR_BINDING"                          
## 
## $lung_cancer$dns
## [1] "GOMF_GROWTH_HORMONE_RECEPTOR_BINDING"
## [2] "GOCC_T_CELL_RECEPTOR_COMPLEX"        
## [3] "GOBP_PROTEIN_AUTOUBIQUITINATION"     
## 
## 
## $ovarian_cancer
## $ovarian_cancer$ups
## [1] "GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION"             
## [2] "GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS"
## [3] "GOBP_REGULATION_OF_MESODERMAL_CELL_DIFFERENTIATION"           
## 
## $ovarian_cancer$dns
## [1] "GOBP_REGULATION_OF_ENAMEL_MINERALIZATION" 
## [2] "GOMF_GUANYLATE_CYCLASE_REGULATOR_ACTIVITY"
## [3] "GOBP_INTESTINAL_CHOLESTEROL_ABSORPTION"   
## 
## 
## $prostate_cancer
## $prostate_cancer$ups
## [1] "GOCC_CYTOSOLIC_SMALL_RIBOSOMAL_SUBUNIT"
## [2] "GOCC_SMALL_SUBUNIT_PROCESSOME"         
## [3] "GOCC_SMALL_RIBOSOMAL_SUBUNIT"          
## 
## $prostate_cancer$dns
## [1] "GOBP_NEUTROPHIL_DEGRANULATION"                         
## [2] "GOBP_NEUTROPHIL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE"
## [3] "GOBP_NEUROPEPTIDE_SIGNALING_PATHWAY"
gsets <- unique(unname(unlist(r4)))
gsets
##  [1] "GOBP_RESPONSE_TO_SELENIUM_ION"                                              
##  [2] "GOBP_NEGATIVE_REGULATION_OF_IMMUNOGLOBULIN_PRODUCTION"                      
##  [3] "GOBP_LATERAL_MESODERM_DEVELOPMENT"                                          
##  [4] "GOBP_NEGATIVE_REGULATION_OF_LEUKOCYTE_ADHESION_TO_VASCULAR_ENDOTHELIAL_CELL"
##  [5] "GOMF_ATPASE_COUPLED_INORGANIC_ANION_TRANSMEMBRANE_TRANSPORTER_ACTIVITY"     
##  [6] "GOBP_POSITIVE_REGULATION_OF_LIPOPROTEIN_PARTICLE_CLEARANCE"                 
##  [7] "GOCC_RNAI_EFFECTOR_COMPLEX"                                                 
##  [8] "GOBP_REGULATORY_NCRNA_MEDIATED_GENE_SILENCING"                              
##  [9] "GOCC_CHROMOSOME"                                                            
## [10] "GOCC_CYTOSOLIC_SMALL_RIBOSOMAL_SUBUNIT"                                     
## [11] "GOCC_CYTOSOLIC_LARGE_RIBOSOMAL_SUBUNIT"                                     
## [12] "GOMF_STRUCTURAL_CONSTITUENT_OF_RIBOSOME"                                    
## [13] "GOBP_METANEPHRIC_GLOMERULUS_VASCULATURE_DEVELOPMENT"                        
## [14] "GOBP_CARDIAC_CHAMBER_FORMATION"                                             
## [15] "GOMF_BMP_RECEPTOR_BINDING"                                                  
## [16] "GOMF_GROWTH_HORMONE_RECEPTOR_BINDING"                                       
## [17] "GOCC_T_CELL_RECEPTOR_COMPLEX"                                               
## [18] "GOBP_PROTEIN_AUTOUBIQUITINATION"                                            
## [19] "GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION"                           
## [20] "GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS"              
## [21] "GOBP_REGULATION_OF_MESODERMAL_CELL_DIFFERENTIATION"                         
## [22] "GOBP_REGULATION_OF_ENAMEL_MINERALIZATION"                                   
## [23] "GOMF_GUANYLATE_CYCLASE_REGULATOR_ACTIVITY"                                  
## [24] "GOBP_INTESTINAL_CHOLESTEROL_ABSORPTION"                                     
## [25] "GOCC_SMALL_SUBUNIT_PROCESSOME"                                              
## [26] "GOCC_SMALL_RIBOSOMAL_SUBUNIT"                                               
## [27] "GOBP_NEUTROPHIL_DEGRANULATION"                                              
## [28] "GOBP_NEUTROPHIL_ACTIVATION_INVOLVED_IN_IMMUNE_RESPONSE"                     
## [29] "GOBP_NEUROPEPTIDE_SIGNALING_PATHWAY"
top <- mtable2[which(mtable2$set %in% gsets),]
top <- top[,c(1,4:22)]
top <- top[,colnames(top) %in% c("set","s.breast_cancer","s.colorectal_can","s.lung_cancer","s.ovarian_cancer","s.prostate_cance")]

rownames(top) <- top$set
top$set=NULL
head(top,3)
##                                                               s.breast_cancer
## GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION                    0.3597412
## GOCC_T_CELL_RECEPTOR_COMPLEX                                        0.1277341
## GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS       0.1936882
##                                                               s.colorectal_can
## GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION                    -0.1281608
## GOCC_T_CELL_RECEPTOR_COMPLEX                                        -0.4088178
## GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS        0.1383270
##                                                               s.lung_cancer
## GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION                 -0.1369938
## GOCC_T_CELL_RECEPTOR_COMPLEX                                     -0.5723869
## GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS     0.7355878
##                                                               s.ovarian_cancer
## GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION                     0.8323107
## GOCC_T_CELL_RECEPTOR_COMPLEX                                        -0.1095963
## GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS        0.7460570
##                                                               s.prostate_cance
## GOBP_REGULATION_OF_AMACRINE_CELL_DIFFERENTIATION                    0.05931549
## GOCC_T_CELL_RECEPTOR_COMPLEX                                       -0.14133225
## GOBP_NEGATIVE_REGULATION_OF_MHC_CLASS_II_BIOSYNTHETIC_PROCESS      -0.34486311
rownames(top) <- gsub("REACTOME_","",rownames(top))
rownames(top) <- gsub("_"," ",rownames(top))

colnames(top) <- c("breast","colorectal","lung","ovarian","prostate")
head(top)
##                                                                                 breast
## GOBP REGULATION OF AMACRINE CELL DIFFERENTIATION                             0.3597412
## GOCC T CELL RECEPTOR COMPLEX                                                 0.1277341
## GOBP NEGATIVE REGULATION OF MHC CLASS II BIOSYNTHETIC PROCESS                0.1936882
## GOBP NEGATIVE REGULATION OF LEUKOCYTE ADHESION TO VASCULAR ENDOTHELIAL CELL -0.6173271
## GOBP METANEPHRIC GLOMERULUS VASCULATURE DEVELOPMENT                          0.2956632
## GOMF GUANYLATE CYCLASE REGULATOR ACTIVITY                                   -0.1984295
##                                                                              colorectal
## GOBP REGULATION OF AMACRINE CELL DIFFERENTIATION                            -0.12816084
## GOCC T CELL RECEPTOR COMPLEX                                                -0.40881779
## GOBP NEGATIVE REGULATION OF MHC CLASS II BIOSYNTHETIC PROCESS                0.13832705
## GOBP NEGATIVE REGULATION OF LEUKOCYTE ADHESION TO VASCULAR ENDOTHELIAL CELL  0.40129610
## GOBP METANEPHRIC GLOMERULUS VASCULATURE DEVELOPMENT                         -0.21389823
## GOMF GUANYLATE CYCLASE REGULATOR ACTIVITY                                    0.05311605
##                                                                                    lung
## GOBP REGULATION OF AMACRINE CELL DIFFERENTIATION                            -0.13699377
## GOCC T CELL RECEPTOR COMPLEX                                                -0.57238687
## GOBP NEGATIVE REGULATION OF MHC CLASS II BIOSYNTHETIC PROCESS                0.73558778
## GOBP NEGATIVE REGULATION OF LEUKOCYTE ADHESION TO VASCULAR ENDOTHELIAL CELL -0.07885731
## GOBP METANEPHRIC GLOMERULUS VASCULATURE DEVELOPMENT                          0.71028679
## GOMF GUANYLATE CYCLASE REGULATOR ACTIVITY                                   -0.14829083
##                                                                                 ovarian
## GOBP REGULATION OF AMACRINE CELL DIFFERENTIATION                             0.83231065
## GOCC T CELL RECEPTOR COMPLEX                                                -0.10959632
## GOBP NEGATIVE REGULATION OF MHC CLASS II BIOSYNTHETIC PROCESS                0.74605700
## GOBP NEGATIVE REGULATION OF LEUKOCYTE ADHESION TO VASCULAR ENDOTHELIAL CELL -0.08702822
## GOBP METANEPHRIC GLOMERULUS VASCULATURE DEVELOPMENT                          0.41701771
## GOMF GUANYLATE CYCLASE REGULATOR ACTIVITY                                   -0.65843902
##                                                                                prostate
## GOBP REGULATION OF AMACRINE CELL DIFFERENTIATION                             0.05931549
## GOCC T CELL RECEPTOR COMPLEX                                                -0.14133225
## GOBP NEGATIVE REGULATION OF MHC CLASS II BIOSYNTHETIC PROCESS               -0.34486311
## GOBP NEGATIVE REGULATION OF LEUKOCYTE ADHESION TO VASCULAR ENDOTHELIAL CELL  0.10381226
## GOBP METANEPHRIC GLOMERULUS VASCULATURE DEVELOPMENT                          0.14075017
## GOMF GUANYLATE CYCLASE REGULATOR ACTIVITY                                    0.15383654
saveRDS(top,file="cancerheat.Rds")

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

heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(10,25),
  col=colfunc(25),cexRow=0.75,cexCol=1.2)

pdf("cancerheat.pdf",height=7,width=7)
heatmap.2(as.matrix(top),scale="none",trace="none",margins=c(10,25),
  col=colfunc(25),cexRow=0.7,cexCol=1.2)
dev.off()
## png 
##   2

Comparison of prevalence and incidence

diseases <- colnames(m2)[which(colnames(m2) %in%  colnames(m1))]

dres <- lapply(diseases, function(d) {
  mydisease <- d
  df <- data.frame( m1[,which(colnames(m1)==mydisease)] ,
    m2[,which(colnames(m2)==mydisease)] , row.names=rownames(m1))
  colnames(df) <- c("prev","indic")
  dres <- mitch_calc(df,genesets=gs_symbols,minsetsize=5,cores=6,priority="effect")
  #subset(dres$enrichment_result,p.adjustMANOVA<0.05)
})
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
names(dres) <- diseases

a <- lapply(dres,function(d) {
  sig <- nrow(subset(d$enrichment_result,p.adjustMANOVA<0.05))
  same <- nrow(subset(d$enrichment_result, p.adjustMANOVA<0.05 & sign(s.prev) ==  sign(s.indic) ) )
  diff = sig - same
  return(c(sig,same,diff))
})
a <- do.call(rbind,a)
colnames(a) <- c("sig","same","different")

lapply(dres,function(d) {
  subset(d$enrichment_result,p.adjustMANOVA<0.05) %>% kbl %>% kable_paper("hover", full_width = F)
})
## $alzheimers
## 
## $breast_cancer
## 
## $chronic_pain
## 
## $CKD
## 
## $colorectal_cancer
## 
## $COPD
## 
## $diabetes
## 
## $heart_disease
## 
## $lung_cancer
## 
## $osteoarthritis
## 
## $parkinsons
## 
## $prostate_cancer
## 
## $rheumatoid_arthritis
## 
## $stroke
lapply(1:length(dres),function(i) {
  d <- dres[[i]]
  dname <- names(dres)[i]
  res <- d$enrichment_result
  sig <- subset(res,p.adjustMANOVA<0.05)
  P = signif(cor(res$s.prev,res$s.indic),3)
  S = signif(cor(res$s.prev,res$s.indic,method="spearman"),3)
  HEADER=paste("no sig=",nrow(sig),"P=",P,"S=",S)
  plot(res$s.prev,res$s.indic,pch=19,cex=0.8,main=dname)
  mtext(HEADER)
  abline(v=0,h=0,lty=2,col="blue")
  points(sig$s.prev,sig$s.indic,pch=19,col="red")
})

## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## 
## [[9]]
## NULL
## 
## [[10]]
## NULL
## 
## [[11]]
## NULL
## 
## [[12]]
## NULL
## 
## [[13]]
## NULL
## 
## [[14]]
## NULL

Session information

save.image("multi_ewas_example.Rdata")

sessionInfo()
## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Australia/Melbourne
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] 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.38.0                                  
##  [4] IlluminaHumanMethylation450kanno.ilmn12.hg19_0.6.1 
##  [5] beeswarm_0.4.0                                     
##  [6] kableExtra_1.4.0                                   
##  [7] gplots_3.1.3.1                                     
##  [8] mitch_1.16.0                                       
##  [9] tictoc_1.2.1                                       
## [10] HGNChelper_0.8.14                                  
## [11] IlluminaHumanMethylationEPICanno.ilm10b4.hg19_0.6.0
## [12] IlluminaHumanMethylation450kmanifest_0.4.0         
## [13] minfi_1.50.0                                       
## [14] bumphunter_1.46.0                                  
## [15] locfit_1.5-9.10                                    
## [16] iterators_1.0.14                                   
## [17] foreach_1.5.2                                      
## [18] Biostrings_2.72.0                                  
## [19] XVector_0.44.0                                     
## [20] SummarizedExperiment_1.34.0                        
## [21] Biobase_2.64.0                                     
## [22] MatrixGenerics_1.16.0                              
## [23] matrixStats_1.3.0                                  
## [24] GenomicRanges_1.56.0                               
## [25] GenomeInfoDb_1.40.0                                
## [26] IRanges_2.38.0                                     
## [27] S4Vectors_0.42.0                                   
## [28] BiocGenerics_0.50.0                                
## [29] eulerr_7.0.2                                       
## [30] limma_3.60.0                                       
## 
## loaded via a namespace (and not attached):
##   [1] splines_4.4.1             later_1.3.2              
##   [3] BiocIO_1.14.0             bitops_1.0-7             
##   [5] tibble_3.2.1              preprocessCore_1.66.0    
##   [7] XML_3.99-0.17             lifecycle_1.0.4          
##   [9] lattice_0.22-6            MASS_7.3-61              
##  [11] base64_2.0.1              scrime_1.3.5             
##  [13] magrittr_2.0.3            sass_0.4.9               
##  [15] rmarkdown_2.27            jquerylib_0.1.4          
##  [17] yaml_2.3.9                httpuv_1.6.15            
##  [19] doRNG_1.8.6               askpass_1.2.0            
##  [21] DBI_1.2.3                 RColorBrewer_1.1-3       
##  [23] abind_1.4-5               zlibbioc_1.50.0          
##  [25] quadprog_1.5-8            purrr_1.0.2              
##  [27] RCurl_1.98-1.14           GenomeInfoDbData_1.2.12  
##  [29] genefilter_1.86.0         annotate_1.82.0          
##  [31] svglite_2.1.3             DelayedMatrixStats_1.26.0
##  [33] codetools_0.2-20          DelayedArray_0.30.1      
##  [35] xml2_1.3.6                tidyselect_1.2.1         
##  [37] UCSC.utils_1.0.0          beanplot_1.3.1           
##  [39] illuminaio_0.46.0         GenomicAlignments_1.40.0 
##  [41] jsonlite_1.8.8            multtest_2.60.0          
##  [43] survival_3.7-0            systemfonts_1.1.0        
##  [45] tools_4.4.1               Rcpp_1.0.12              
##  [47] glue_1.7.0                SparseArray_1.4.3        
##  [49] xfun_0.45                 dplyr_1.1.4              
##  [51] HDF5Array_1.32.0          fastmap_1.2.0            
##  [53] GGally_2.2.1              rhdf5filters_1.16.0      
##  [55] fansi_1.0.6               openssl_2.2.0            
##  [57] caTools_1.18.2            digest_0.6.36            
##  [59] R6_2.5.1                  mime_0.12                
##  [61] colorspace_2.1-0          gtools_3.9.5             
##  [63] RSQLite_2.3.7             utf8_1.2.4               
##  [65] tidyr_1.3.1               generics_0.1.3           
##  [67] data.table_1.15.4         rtracklayer_1.64.0       
##  [69] httr_1.4.7                htmlwidgets_1.6.4        
##  [71] S4Arrays_1.4.0            ggstats_0.6.0            
##  [73] pkgconfig_2.0.3           gtable_0.3.5             
##  [75] blob_1.2.4                siggenes_1.78.0          
##  [77] htmltools_0.5.8.1         echarts4r_0.4.5          
##  [79] scales_1.3.0              knitr_1.48               
##  [81] rstudioapi_0.16.0         reshape2_1.4.4           
##  [83] tzdb_0.4.0                rjson_0.2.21             
##  [85] nlme_3.1-165              curl_5.2.1               
##  [87] org.Hs.eg.db_3.19.1       cachem_1.1.0             
##  [89] rhdf5_2.48.0              stringr_1.5.1            
##  [91] KernSmooth_2.23-24        AnnotationDbi_1.66.0     
##  [93] restfulr_0.0.15           GEOquery_2.72.0          
##  [95] pillar_1.9.0              grid_4.4.1               
##  [97] reshape_0.8.9             vctrs_0.6.5              
##  [99] promises_1.3.0            xtable_1.8-4             
## [101] evaluate_0.24.0           readr_2.1.5              
## [103] GenomicFeatures_1.56.0    cli_3.6.3                
## [105] compiler_4.4.1            Rsamtools_2.20.0         
## [107] rlang_1.1.4               crayon_1.5.3             
## [109] rngtools_1.5.2            nor1mix_1.3-3            
## [111] mclust_6.1.1              plyr_1.8.9               
## [113] stringi_1.8.4             viridisLite_0.4.2        
## [115] BiocParallel_1.38.0       munsell_0.5.1            
## [117] Matrix_1.7-0              hms_1.1.3                
## [119] sparseMatrixStats_1.16.0  bit64_4.0.5              
## [121] ggplot2_3.5.1             Rhdf5lib_1.26.0          
## [123] KEGGREST_1.44.0           statmod_1.5.0            
## [125] shiny_1.8.1.1             highr_0.11               
## [127] memoise_2.0.1.9000        bslib_0.7.0              
## [129] bit_4.0.5                 splitstackshape_1.4.8