Source: https://github.com/markziemann/mst1tg_mito_rna-seq

Loading packages

# to be run in R4
suppressPackageStartupMessages({
  library("tidyverse")
  library("reshape2")
  library("gplots")
  library("mitch")
})

Import profiling data

young <- read.csv("Mst1TG_young_deseq.tsv",sep="\t")
rownames(young) <- sapply((strsplit(rownames(young),"\\.")),"[[",1)
old <- read.csv("Mst1TG_old_deseq.tsv",sep="\t")
rownames(old) <- sapply((strsplit(rownames(old),"\\.")),"[[",1)
x <- list("young" = young , "old" = old)

# import these in again for heatmaps
young <- read.csv("Mst1TG_young_deseq.tsv",sep="\t")
old <- read.csv("Mst1TG_old_deseq.tsv",sep="\t")

Gene sets

gsets <- gmt_import("../ref/ReactomePathways_mouse.gmt")

# gene accession to symbol mapping
gt <- read.csv("../ref/mart_export.txt",sep="\t")
gt <- gt[,c(1,4)]

mitch

Lets begin with priority by significance.

yy <- mitch_import(x, DEtype="deseq2", geneTable=gt)
## Note: Mean no. genes in input = 17755
## Note: no. genes in output = 14877
## Note: estimated proportion of input genes in output = 0.838
res <- mitch_calc(yy, gsets, priority="significance")
## Note: When prioritising by significance (ie: small 
##             p-values), large effect sizes might be missed.
head(res$enrichment_result,20)
##                                                                                                                      set
## 1175                                                      The-citric-acid-(TCA)-cycle-and-respiratory-electron-transport
## 963  Respiratory-electron-transport,-ATP-synthesis-by-chemiosmotic-coupling,-and-heat-production-by-uncoupling-proteins.
## 962                                                                                       Respiratory-electron-transport
## 601                                                                                                           Metabolism
## 635                                                                                            Mitochondrial-translation
## 636                                                                                 Mitochondrial-translation-elongation
## 638                                                                                Mitochondrial-translation-termination
## 637                                                                                 Mitochondrial-translation-initiation
## 335                                                                                    Extracellular-matrix-organization
## 193                                                                                                 Complex-I-biogenesis
## 1215                                                                                                         Translation
## 826                                                                                                 Protein-localization
## 633                                                                                         Mitochondrial-protein-import
## 836                                                                      Pyruvate-metabolism-and-Citric-Acid-(TCA)-cycle
## 630                                                                                             Mitochondrial-biogenesis
## 186                                                                          Collagen-biosynthesis-and-modifying-enzymes
## 208                                                                                                    Cristae-formation
## 629                                                                              Mitochondrial-Fatty-Acid-Beta-Oxidation
## 189                                                                                                   Collagen-formation
## 1023                                                                                                 Signal-Transduction
##      setSize      pMANOVA    s.young       s.old      p.young        p.old
## 1175     168 2.515849e-83 -0.8361385 -0.81430465 1.230669e-78 1.234084e-74
## 963      121 9.359276e-66 -0.8833095 -0.83745735 1.258076e-63 2.530445e-57
## 962      100 4.626085e-57 -0.9035826 -0.85861000 2.801421e-55 4.761159e-50
## 601     1615 2.726231e-49 -0.2001755 -0.22456349 9.652047e-40 1.236627e-49
## 635       94 6.954962e-44 -0.8253673 -0.75822286 1.108541e-43 4.243812e-37
## 636       88 2.901428e-41 -0.8273809 -0.75794817 3.378270e-41 8.105151e-35
## 638       88 4.505778e-41 -0.8254722 -0.75609175 5.147975e-41 1.179238e-34
## 637       88 1.348162e-40 -0.8214244 -0.74964501 1.253713e-40 4.304968e-34
## 335      228 1.350544e-38  0.4991275  0.45777569 1.410377e-38 1.080239e-32
## 193       54 1.621653e-33 -0.9302161 -0.90362325 2.281589e-32 1.245806e-30
## 1215     243 6.643594e-31 -0.4108691 -0.42384188 2.925991e-28 5.659389e-30
## 826      142 7.412507e-29 -0.5118837 -0.53720327 6.064025e-26 2.039938e-28
## 633       57 8.672171e-23 -0.7619007 -0.68645027 2.285529e-23 2.947540e-19
## 836       51 4.483657e-21 -0.7249612 -0.76031508 3.153090e-19 5.373685e-21
## 630       88 1.702298e-19 -0.5304265 -0.55687581 7.776007e-18 1.670651e-19
## 186       56 1.436322e-17  0.6369799  0.65537076 1.592143e-16 2.099903e-17
## 208       29 4.274261e-17 -0.9046104 -0.86083346 3.206166e-17 9.786321e-16
## 629       31 5.132212e-17 -0.8584391 -0.84985203 1.245379e-16 2.491625e-16
## 189       75 1.224413e-16  0.5455389  0.54164212 3.060851e-16 4.962533e-16
## 1023    1718 3.251919e-14  0.1166064  0.09353717 3.255389e-15 2.628458e-10
##         s.dist          SD p.adjustMANOVA
## 1175 1.1671417 0.015438895   3.288214e-80
## 963  1.2171978 0.032422401   6.116287e-63
## 962  1.2464641 0.031800425   2.015431e-54
## 601  0.3008305 0.017244941   8.907961e-47
## 635  1.1207734 0.047478264   1.818027e-41
## 636  1.1220716 0.049096367   6.320277e-39
## 638  1.1194102 0.049059420   8.412931e-39
## 637  1.1120727 0.050755696   2.202560e-38
## 335  0.6772643 0.029240169   1.961289e-36
## 193  1.2968565 0.018803954   2.119500e-31
## 1215 0.5903011 0.009173139   7.893798e-29
## 826  0.7420325 0.017903671   8.073456e-27
## 633  1.0255275 0.053351514   8.718867e-21
## 836  1.0505464 0.024998980   4.185814e-19
## 630  0.7690663 0.018702498   1.483269e-17
## 186  0.9139224 0.013004325   1.173296e-15
## 208  1.2487411 0.030954971   3.286152e-15
## 629  1.2079595 0.006071986   3.726556e-15
## 189  0.7687580 0.002755433   8.422672e-15
## 1023 0.1494866 0.016312415   2.125129e-12
unlink("Mst1TG_young_and_old_sig_mitch.html")
# top N gene heatmap
mitch_report(res, outfile = "Mst1TG_young_and_old_sig_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_sig_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str2293367beded.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
# heatmaps of top sets by significance
# colour scheme
colfunc <- colorRampPalette(c("blue", "white", "red"))

topsets <- head(res$enrichment_result,50)$set
mytopsets <- gsets[which(names( gsets ) %in% topsets)]
yo <- young[,7:ncol(young)]
colnames(yo) <- paste("y",colnames(yo))
ol <- old[,7:ncol(old)]
colnames(ol) <- paste("o",colnames(ol))
mx <- merge(yo,ol,by=0)
rownames(mx) <- mx$Row.names
mx$Row.names = NULL

i = 1
par(mar = c(10, 8, 8, 4) + 0.2)
for ( i in seq_along(mytopsets) ) {
  g <- as.vector(unlist(mytopsets[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME=names(mytopsets[i])
  heatmap.2( as.matrix(z), col=colfunc(25),scale="row",
   trace="none",margins = c(6,20), cexRow=.4, cexCol=.8)
  mtext(SETNAME)
}

Now prioritise by effect size.

res <- mitch_calc(yy, gsets, priority = "effect")
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
head(res$enrichment_result,20)
##                                                                                                                      set
## 361                                                                            Formation-of-ATP-by-chemiosmotic-coupling
## 193                                                                                                 Complex-I-biogenesis
## 176                                                                                        Citric-acid-cycle-(TCA-cycle)
## 208                                                                                                    Cristae-formation
## 962                                                                                       Respiratory-electron-transport
## 963  Respiratory-electron-transport,-ATP-synthesis-by-chemiosmotic-coupling,-and-heat-production-by-uncoupling-proteins.
## 629                                                                              Mitochondrial-Fatty-Acid-Beta-Oxidation
## 110                                                                                 Branched-chain-amino-acid-catabolism
## 1175                                                      The-citric-acid-(TCA)-cycle-and-respiratory-electron-transport
## 1298                                                                                rRNA-processing-in-the-mitochondrion
## 1304                                                                                tRNA-processing-in-the-mitochondrion
## 636                                                                                 Mitochondrial-translation-elongation
## 635                                                                                            Mitochondrial-translation
## 638                                                                                Mitochondrial-translation-termination
## 637                                                                                 Mitochondrial-translation-initiation
## 632                                                                         Mitochondrial-iron-sulfur-cluster-biogenesis
## 440                                                                        Glyoxylate-metabolism-and-glycine-degradation
## 836                                                                      Pyruvate-metabolism-and-Citric-Acid-(TCA)-cycle
## 187                                                                                         Collagen-chain-trimerization
## 633                                                                                         Mitochondrial-protein-import
##      setSize      pMANOVA    s.young      s.old      p.young        p.old
## 361       16 1.292423e-10 -0.9329789 -0.9194031 1.017112e-10 1.887907e-10
## 193       54 1.621653e-33 -0.9302161 -0.9036232 2.281589e-32 1.245806e-30
## 176       22 2.511926e-13 -0.8942872 -0.8892751 3.711622e-13 5.015120e-13
## 208       29 4.274261e-17 -0.9046104 -0.8608335 3.206166e-17 9.786321e-16
## 962      100 4.626085e-57 -0.9035826 -0.8586100 2.801421e-55 4.761159e-50
## 963      121 9.359276e-66 -0.8833095 -0.8374574 1.258076e-63 2.530445e-57
## 629       31 5.132212e-17 -0.8584391 -0.8498520 1.245379e-16 2.491625e-16
## 110       21 2.430098e-11 -0.8328525 -0.8426674 3.838241e-11 2.259224e-11
## 1175     168 2.515849e-83 -0.8361385 -0.8143047 1.230669e-78 1.234084e-74
## 1298      22 1.564605e-11 -0.7831156 -0.8542333 2.002556e-10 3.928719e-12
## 1304      18 3.426684e-09 -0.7504019 -0.8415326 3.521252e-08 6.262141e-10
## 636       88 2.901428e-41 -0.8273809 -0.7579482 3.378270e-41 8.105151e-35
## 635       94 6.954962e-44 -0.8253673 -0.7582229 1.108541e-43 4.243812e-37
## 638       88 4.505778e-41 -0.8254722 -0.7560918 5.147975e-41 1.179238e-34
## 637       88 1.348162e-40 -0.8214244 -0.7496450 1.253713e-40 4.304968e-34
## 632       10 6.993237e-05 -0.7409968 -0.7750185 4.948957e-05 2.191278e-05
## 440       25 7.782677e-11 -0.7513547 -0.7477350 7.741915e-11 9.534951e-11
## 836       51 4.483657e-21 -0.7249612 -0.7603151 3.153090e-19 5.373685e-21
## 187       33 1.118654e-13  0.7367001  0.7402562 2.337306e-13 1.793245e-13
## 633       57 8.672171e-23 -0.7619007 -0.6864503 2.285529e-23 2.947540e-19
##        s.dist          SD p.adjustMANOVA
## 361  1.309867 0.009599542   4.826277e-09
## 193  1.296857 0.018803954   2.119500e-31
## 176  1.261174 0.003544080   1.492313e-11
## 208  1.248741 0.030954971   3.286152e-15
## 962  1.246464 0.031800425   2.015431e-54
## 963  1.217198 0.032422401   6.116287e-63
## 629  1.207960 0.006071986   3.726556e-15
## 110  1.184792 0.006940152   1.134335e-09
## 1175 1.167142 0.015438895   3.288214e-80
## 1298 1.158872 0.050287861   7.573845e-10
## 1304 1.127511 0.064439138   1.210453e-07
## 636  1.122072 0.049096367   6.320277e-39
## 635  1.120773 0.047478264   1.818027e-41
## 638  1.119410 0.049059420   8.412931e-39
## 637  1.112073 0.050755696   2.202560e-38
## 632  1.072255 0.024056946   9.451158e-04
## 440  1.060020 0.002559525   3.184758e-09
## 836  1.050546 0.024998980   4.185814e-19
## 187  1.044369 0.002514596   6.962290e-12
## 633  1.025527 0.053351514   8.718867e-21
unlink("Mst1TG_young_and_old_eff_mitch.html")
mitch_report(res, outfile = "Mst1TG_young_and_old_eff_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_eff_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str2293403f58c.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
# heatmaps of top sets by effect size
topsets <- head(res$enrichment_result,50)$set
mytopsets <- gsets[which(names( gsets ) %in% topsets)]
i=1
par(mar = c(10, 8, 8, 4) + 0.2)
for ( i in seq_along(mytopsets) ) {
  g <- as.vector(unlist(mytopsets[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME = names(mytopsets[i])
  heatmap.2( as.matrix(z), col = colfunc(25),scale = "row",
   trace="none",margins = c(6,20), cexRow = .4, cexCol = .8)
  mtext(SETNAME)
}

Now prioritise by discordant effect size.

res <- mitch_calc(yy, gsets, priority = "SD")
## Note: Prioritisation by SD after selecting sets with 
##             p.adjustMANOVA<=0.05.
head(res$enrichment_result,20)
##                                                                                set
## 1171                                          Termination-of-O-glycan-biosynthesis
## 1111                                              Synaptic-adhesion-like-molecules
## 519                                                Interferon-alpha/beta-signaling
## 1174                        The-canonical-retinoid-cycle-in-rods-(twilight-vision)
## 658                         N-glycan-antennae-elongation-in-the-medial/trans-Golgi
## 166                                            Chemokine-receptors-bind-chemokines
## 730                                               O-linked-glycosylation-of-mucins
## 460                                                            HS-GAG-biosynthesis
## 1266                        WNT5A-dependent-internalization-of-FZD2,-FZD5-and-ROR2
## 461                                                             HS-GAG-degradation
## 350  FOXO-mediated-transcription-of-oxidative-stress,-metabolic-and-neuronal-genes
## 1022                                                        Sialic-acid-metabolism
## 285                       Downregulation-of-SMAD2/3:SMAD4-transcriptional-activity
## 1126                     Synthesis-of-active-ubiquitin:-roles-of-E1-and-E2-enzymes
## 1236                                                       Triglyceride-catabolism
## 1242                       Ubiquitin-Mediated-Degradation-of-Phosphorylated-Cdc25A
## 1290                                           p53-Independent-DNA-Damage-Response
## 1291                                    p53-Independent-G1/S-DNA-damage-checkpoint
## 86                                         Assembly-of-the-pre-replicative-complex
## 948                                    Regulation-of-ornithine-decarboxylase-(ODC)
##      setSize      pMANOVA     s.young         s.old      p.young        p.old
## 1171      10 1.115890e-03  0.39081187 -0.0052599717 0.0323685019 9.770257e-01
## 1111      15 1.732267e-03  0.28323689 -0.0347373615 0.0575633910 8.158480e-01
## 519       40 1.387142e-08  0.04785671  0.3600053919 0.6006283244 8.180409e-05
## 1174      12 4.087033e-04  0.24527413  0.5572149344 0.1412962416 8.309092e-04
## 658       20 2.410343e-04  0.35078414  0.0531197415 0.0066187051 6.809598e-01
## 166       20 2.501491e-03  0.29927980  0.0474321868 0.0205218841 7.135212e-01
## 730       32 1.254537e-05  0.38636746  0.1405776356 0.0001554919 1.688774e-01
## 460       23 1.159881e-04  0.43421476  0.1915455360 0.0003126898 1.118798e-01
## 1266      13 5.292945e-03  0.44633394  0.2064461373 0.0053319120 1.975302e-01
## 461       18 4.696817e-04  0.47066125  0.2343660034 0.0005463251 8.522719e-02
## 350       23 9.528103e-03  0.09551519 -0.1308914009 0.4279310937 2.773219e-01
## 1022      26 3.270409e-03  0.23833671  0.0168131646 0.0354594522 8.820684e-01
## 285       23 6.014951e-03  0.24809011  0.0279532376 0.0394778318 8.165394e-01
## 1126      29 3.254697e-03 -0.01472856 -0.2248485806 0.8908463045 3.615487e-02
## 1236      15 9.291510e-06 -0.50318037 -0.7077827121 0.0007405841 2.065018e-06
## 1242      48 2.720323e-05 -0.31450480 -0.1268151370 0.0001642006 1.286981e-01
## 1290      48 2.720323e-05 -0.31450480 -0.1268151370 0.0001642006 1.286981e-01
## 1291      48 2.720323e-05 -0.31450480 -0.1268151370 0.0001642006 1.286981e-01
## 86        64 6.669333e-05 -0.18632493 -0.0003354317 0.0099862346 9.962998e-01
## 948       46 3.967504e-05 -0.32015490 -0.1351077209 0.0001728409 1.130494e-01
##         s.dist        SD p.adjustMANOVA
## 1171 0.3908473 0.2800651   8.733342e-03
## 1111 0.2853591 0.2248417   1.271951e-02
## 519  0.3631723 0.2207225   4.316653e-07
## 1174 0.6088086 0.2205755   3.842987e-03
## 658  0.3547833 0.2104805   2.540579e-03
## 166  0.3030152 0.1780832   1.646570e-02
## 730  0.4111470 0.1737997   2.309409e-04
## 460  0.4745863 0.1715931   1.430155e-03
## 1266 0.4917662 0.1696263   3.158849e-02
## 461  0.5257846 0.1670860   4.292825e-03
## 350  0.1620361 0.1600936   4.845615e-02
## 1022 0.2389290 0.1566408   2.045179e-02
## 285  0.2496599 0.1556603   3.448045e-02
## 1126 0.2253305 0.1485773   2.045139e-02
## 1236 0.8684163 0.1446757   1.760001e-04
## 1242 0.3391096 0.1327166   4.389460e-04
## 1290 0.3391096 0.1327166   4.389460e-04
## 1291 0.3391096 0.1327166   4.389460e-04
## 86   0.1863252 0.1315144   9.273211e-04
## 948  0.3474957 0.1308481   6.092662e-04
unlink("Mst1TG_young_and_old_dis_mitch.html")
mitch_report(res, outfile = "Mst1TG_young_and_old_dis_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_dis_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str22934c80552d.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
# heatmaps of top sets by discordant size
topsets <- head(res$enrichment_result,50)$set
mytopsets <- gsets[which(names( gsets ) %in% topsets)]
i=1
par(mar = c(10, 8, 8, 4) + 0.2)
for ( i in seq_along(mytopsets) ) {
  g <- as.vector(unlist(mytopsets[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME = names(mytopsets[i])
  heatmap.2( as.matrix(z), col = colfunc(25),scale = "row",
   trace="none",margins = c(6,20), cexRow = .4, cexCol = .8)
  mtext(SETNAME)
}

Custom gene set analysis

Run mitch with some hand-picked gene sets that are relevant to the Mst1 model.

# gene sets of interest
gsets <- gmt_import("../ref/pathways_of_interest_mouse.gmt")

# mitch pathways of interest
yy <- mitch_import(x, DEtype="deseq2", geneTable=gt)
## Note: Mean no. genes in input = 17755
## Note: no. genes in output = 14877
## Note: estimated proportion of input genes in output = 0.838
res <- mitch_calc(yy, gsets, priority="significance")
## Note: When prioritising by significance (ie: small 
##             p-values), large effect sizes might be missed.
head(res$enrichment_result,20)
##                                                                         set
## 24           The-citric-acid-(TCA)-cycle-and-respiratory-electron-transport
## 20                                           Respiratory-electron-transport
## 15                                                Mitochondrial-translation
## 13                                             Mitochondrial-protein-import
## 18                          Pyruvate-metabolism-and-Citric-Acid-(TCA)-cycle
## 10                                                 Mitochondrial-biogenesis
## 9                                   Mitochondrial-Fatty-Acid-Beta-Oxidation
## 5                                             Citric-acid-cycle-(TCA-cycle)
## 26                                     rRNA-processing-in-the-mitochondrion
## 2                                      Branched-chain-amino-acid-catabolism
## 14                                        Mitochondrial-tRNA-aminoacylation
## 25                   Transcriptional-activation-of-mitochondrial-biogenesis
## 12                             Mitochondrial-iron-sulfur-cluster-biogenesis
## 11                                      Mitochondrial-calcium-ion-transport
## 17 Oxygen-dependent-proline-hydroxylation-of-Hypoxia-inducible-Factor-Alpha
## 4                                              Cellular-response-to-hypoxia
## 22                                                Smooth-Muscle-Contraction
## 7                                                                Glycolysis
## 21                                                       Signaling-by-Hippo
## 16                                                       Muscle-contraction
##    setSize      pMANOVA     s.young       s.old      p.young        p.old
## 24     167 1.252333e-82 -0.83525078 -0.81311829 5.140819e-78 5.461735e-74
## 20     100 4.626085e-57 -0.90358259 -0.85861000 2.801421e-55 4.761159e-50
## 15      94 6.954962e-44 -0.82536726 -0.75822286 1.108541e-43 4.243812e-37
## 13      57 8.672171e-23 -0.76190070 -0.68645027 2.285529e-23 2.947540e-19
## 18      51 4.483657e-21 -0.72496118 -0.76031508 3.153090e-19 5.373685e-21
## 10      88 1.702298e-19 -0.53042648 -0.55687581 7.776007e-18 1.670651e-19
## 9       31 5.132212e-17 -0.85843911 -0.84985203 1.245379e-16 2.491625e-16
## 5       22 2.511926e-13 -0.89428720 -0.88927511 3.711622e-13 5.015120e-13
## 26      22 1.564605e-11 -0.78311557 -0.85423335 2.002556e-10 3.928719e-12
## 2       19 5.851091e-11 -0.85859115 -0.87076252 9.044799e-11 4.893714e-11
## 14      19 3.662479e-08 -0.75631770 -0.71231518 1.135934e-08 7.591141e-08
## 25      51 3.864014e-08 -0.41798854 -0.46831084 2.427091e-07 7.229049e-09
## 12      10 6.993237e-05 -0.74099684 -0.77501850 4.948957e-05 2.191278e-05
## 11      21 1.528545e-04 -0.49488422 -0.50940457 8.639334e-05 5.318105e-05
## 17      60 4.598722e-04 -0.27615577 -0.16661267 2.172375e-04 2.569236e-02
## 4       68 8.973591e-04 -0.24792952 -0.14957121 4.101207e-04 3.305621e-02
## 22      31 9.211060e-03  0.03144107  0.21101807 7.619922e-01 4.206934e-02
## 7       63 1.433187e-02 -0.12364966 -0.20145251 8.984079e-02 5.713843e-03
## 21      20 1.540622e-02  0.37300263  0.30910682 3.883350e-03 1.672262e-02
## 16     148 2.975029e-02 -0.04379208  0.03414573 3.585713e-01 4.740819e-01
##        s.dist          SD p.adjustMANOVA
## 24 1.16567801 0.015650031   3.256067e-81
## 20 1.24646406 0.031800425   6.013911e-56
## 15 1.12077340 0.047478264   6.027634e-43
## 13 1.02552750 0.053351514   5.636911e-22
## 18 1.05054640 0.024998980   2.331501e-20
## 10 0.76906627 0.018702498   7.376623e-19
## 9  1.20795951 0.006071986   1.906250e-16
## 5  1.26117399 0.003544080   8.163761e-13
## 26 1.15887213 0.050287861   4.519969e-11
## 2  1.22286799 0.008606453   1.521284e-10
## 14 1.03894628 0.031114482   8.372031e-08
## 25 0.62771766 0.035583240   8.372031e-08
## 12 1.07225463 0.024056946   1.398647e-04
## 11 0.71021364 0.010267436   2.838726e-04
## 17 0.32252409 0.077458663   7.971118e-04
## 4  0.28955240 0.069549829   1.458209e-03
## 22 0.21334752 0.126980108   1.408750e-02
## 7  0.23637333 0.055014923   2.070159e-02
## 21 0.48443574 0.045181158   2.108219e-02
## 16 0.05553086 0.055110351   3.867538e-02
unlink("Mst1TG_young_and_old_pathwayofinterest_mitch.html")
# top N gene heatmap
mitch_report(res, outfile = "Mst1TG_young_and_old_pathwayofinterest_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_pathwayofinterest_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str2293779f612.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
# heatmaps of pathways of interest
# colour scheme
colfunc <- colorRampPalette(c("blue", "white", "red"))

topsets <- head(res$enrichment_result,50)$set
mytopsets <- gsets[which(names( gsets ) %in% topsets)]
yo <- young[,7:ncol(young)]
colnames(yo) <- paste("y",colnames(yo))
ol <- old[,7:ncol(old)]
colnames(ol) <- paste("o",colnames(ol))
mx <- merge(yo,ol,by=0)
rownames(mx) <- mx$Row.names
mx$Row.names = NULL

i = 1
par(mar = c(10, 8, 8, 4) + 0.2)
for ( i in seq_along(mytopsets) ) {
  g <- as.vector(unlist(mytopsets[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME=names(mytopsets[i])
  heatmap.2( as.matrix(z), col=colfunc(25),scale="row",
   trace="none",margins = c(6,20), cexRow=.4, cexCol=.8)
  mtext(SETNAME)
}

Mitochondrial complexes

mt <- gmt_import("../ref/mt_complexes_mouse.gmt")

# have a look and check the gene names are correct
mt
## $`Complex-1`
##  [1] "1700029P11Rik" "mt-Nd1"        "mt-Nd2"        "mt-Nd3"       
##  [5] "mt-Nd4"        "mt-Nd4l"       "mt-Nd5"        "mt-Nd6"       
##  [9] "Ndufa1"        "Ndufa10"       "Ndufa11"       "Ndufa12"      
## [13] "Ndufa13"       "Ndufa2"        "Ndufa3"        "Ndufa5"       
## [17] "Ndufa6"        "Ndufa7"        "Ndufa8"        "Ndufa9"       
## [21] "Ndufab1"       "Ndufb10"       "Ndufb1-ps"     "Ndufb2"       
## [25] "Ndufb3"        "Ndufb4"        "Ndufb5"        "Ndufb6"       
## [29] "Ndufb7"        "Ndufb8"        "Ndufb9"        "Ndufc1"       
## [33] "Ndufc2"        "Ndufs1"        "Ndufs2"        "Ndufs3"       
## [37] "Ndufs4"        "Ndufs5"        "Ndufs6"        "Ndufs7"       
## [41] "Ndufs8"        "Ndufv1"        "Ndufv2"        "Ndufv3"       
## 
## $`Complex-1-Assembly-Factors`
##  [1] "Acad9"    "Ecsit"    "Foxred1"  "Ndufaf1"  "Ndufaf2"  "Ndufaf4" 
##  [7] "Ndufaf5"  "Ndufaf6"  "Ndufaf7"  "Ndufaf8"  "Nubpl"    "Timmdc1" 
## [13] "Tmem126b"
## 
## $`Complex-2`
## [1] "Sdha" "Sdhb" "Sdhc" "Sdhd"
## 
## $`Complex-2-Assembly-Factors`
## [1] "Sdhaf1" "Sdhaf2" "Sdhaf3" "Sdhaf4"
## 
## $`Complex-3`
## [1] "Cyc1"    "mt-Cytb" "Uqcr10"  "Uqcr11"  "Uqcrb"   "Uqcrc1"  "Uqcrc2" 
## [8] "Uqcrfs1" "Uqcrq"  
## 
## $`Complex-3-Assembly-Factors`
## [1] "Bcs1l" "Lyrm7" "Ptcd2" "Ttc19" "Uqcc1" "Uqcc2" "Uqcc3"
## 
## $`Complex-4`
## [1] "Cox5a"  "Cox5b"  "Cox6c"  "Cox7b"  "Cox7c"  "mt-Co1" "mt-Co2" "mt-Co3"
## 
## $`Complex-4-Assembly-Factors`
##  [1] "Apopt1"  "Cep89"   "Coa3"    "Coa4"    "Coa5"    "Coa6"    "Coa7"   
##  [8] "Cox10"   "Cox11"   "Cox14"   "Cox16"   "Cox18"   "Cox19"   "Cox20"  
## [15] "Fastkd2" "Gm21987" "Lrpprc"  "Ndufa4"  "Oxa1l"   "Pet100"  "Pet117" 
## [22] "Sco1"    "Sco2"    "Surf1"   "Taco1"  
## 
## $`Complex-5`
##  [1] "Atp5a1"  "Atp5b"   "Atp5c1"  "Atp5d"   "Atp5e"   "Atp5g3"  "Atp5h"  
##  [8] "Atp5j"   "Atp5j2"  "Atp5k"   "Atp5l"   "Atp5o"   "Atp5pb"  "mt-Atp6"
## [15] "mt-Atp8"
## 
## $`Complex-5-Assembly-Factors`
## [1] "Atpaf1" "Atpaf2" "Tmem70"
## 
## attr(,"originfile")
## [1] "../ref/mt_complexes_mouse.gmt"
# mitch pathways of interest
res <- mitch_calc(yy, mt, priority="effect",minsetsize=3)
## Note: Enrichments with large effect sizes may not be 
##             statistically significant.
head(res$enrichment_result,20)
##                           set setSize      pMANOVA    s.young      s.old
## 3                   Complex-2       4 1.630452e-03 -0.9933773 -0.9735090
## 7                   Complex-4       8 7.489554e-06 -0.9618838 -0.9204889
## 1                   Complex-1      43 5.682735e-28 -0.9484747 -0.9254259
## 5                   Complex-3       9 2.035360e-06 -0.9607360 -0.9060473
## 9                   Complex-5      15 4.962915e-10 -0.9358364 -0.9197416
## 10 Complex-5-Assembly-Factors       3 1.395221e-02 -0.9142575 -0.9381023
## 2  Complex-1-Assembly-Factors      13 2.965384e-07 -0.8456363 -0.8233419
## 4  Complex-2-Assembly-Factors       4 1.885567e-02 -0.8053184 -0.7200968
## 6  Complex-3-Assembly-Factors       7 2.810338e-03 -0.7364204 -0.6735325
## 8  Complex-4-Assembly-Factors      23 7.371441e-07 -0.6348575 -0.5616581
##         p.young        p.old    s.dist         SD p.adjustMANOVA
## 3  5.793699e-04 7.455891e-04 1.3908696 0.01404895   2.329217e-03
## 7  2.448833e-06 6.500947e-06 1.3313603 0.02927058   1.248259e-05
## 1  4.414790e-27 7.427705e-26 1.3251481 0.01629801   5.682735e-27
## 5  5.966715e-07 2.502900e-06 1.3205814 0.03867073   4.070720e-06
## 9  3.424155e-10 6.823345e-10 1.3121411 0.01138070   2.481457e-09
## 10 6.095260e-03 4.890470e-03 1.3099247 0.01686078   1.550245e-02
## 2  1.286773e-07 2.727380e-07 1.1802511 0.01576455   9.884612e-07
## 4  5.279602e-03 1.262398e-02 1.0803134 0.06026073   1.885567e-02
## 6  7.401164e-04 2.028537e-03 0.9979785 0.04446845   3.512922e-03
## 8  1.353405e-07 3.113497e-06 0.8476461 0.05175981   1.842860e-06
unlink("Mst1TG_young_and_old_mitocomplex_mitch.html")
# top N gene heatmap
mitch_report(res, outfile = "Mst1TG_young_and_old_mitocomplex_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_mitocomplex_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str229334f36ae8.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
mytopsets <- head(res$enrichment_result,50)$set

i = 1
par(mar = c(10, 8, 8, 4) + 0.2)

for ( i in seq_along(mt) ) {
  g <- as.vector(unlist(mt[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME=names(mt)[i]
  heatmap.2( as.matrix(z), col=colfunc(25),scale="row",
   trace="none",margins = c(6,20), cexRow=.8, cexCol=.8)
  mtext(SETNAME)
}

# now 1D mitch for young and old to create beeswarm charts
yy2 <- yy[,1,drop=FALSE] 
res <- mitch_calc(yy2, mt, priority="effect",minsetsize=3)
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
head(res$enrichment_result,20)
##                           set setSize       pANOVA     s.dist p.adjustANOVA
## 3                   Complex-2       4 5.793699e-04 -0.9933773  8.276713e-04
## 7                   Complex-4       8 2.448833e-06 -0.9618838  4.081389e-06
## 5                   Complex-3       9 5.966715e-07 -0.9607360  1.193343e-06
## 1                   Complex-1      43 4.414790e-27 -0.9484747  4.414790e-26
## 9                   Complex-5      15 3.424155e-10 -0.9358364  1.712077e-09
## 10 Complex-5-Assembly-Factors       3 6.095260e-03 -0.9142575  6.095260e-03
## 2  Complex-1-Assembly-Factors      13 1.286773e-07 -0.8456363  3.383513e-07
## 4  Complex-2-Assembly-Factors       4 5.279602e-03 -0.8053184  5.866225e-03
## 6  Complex-3-Assembly-Factors       7 7.401164e-04 -0.7364204  9.251456e-04
## 8  Complex-4-Assembly-Factors      23 1.353405e-07 -0.6348575  3.383513e-07
unlink("Mst1TG_young_mitocomplex_mitch.html")
mitch_report(res, outfile = "Mst1TG_young_mitocomplex_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_mitocomplex_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## Contour plot does not apply to unidimensional analysis.
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str22937e586c7b.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
yy3 <- yy[,2,drop=FALSE]
res <- mitch_calc(yy3, mt, priority="effect",minsetsize=3)
## Note: Enrichments with large effect sizes may not be
##             statistically significant.
head(res$enrichment_result,20)
##                           set setSize       pANOVA     s.dist p.adjustANOVA
## 3                   Complex-2       4 7.455891e-04 -0.9735090  1.065127e-03
## 10 Complex-5-Assembly-Factors       3 4.890470e-03 -0.9381023  5.433856e-03
## 1                   Complex-1      43 7.427705e-26 -0.9254259  7.427705e-25
## 7                   Complex-4       8 6.500947e-06 -0.9204889  1.083491e-05
## 9                   Complex-5      15 6.823345e-10 -0.9197416  3.411672e-09
## 5                   Complex-3       9 2.502900e-06 -0.9060473  6.226995e-06
## 2  Complex-1-Assembly-Factors      13 2.727380e-07 -0.8233419  9.091267e-07
## 4  Complex-2-Assembly-Factors       4 1.262398e-02 -0.7200968  1.262398e-02
## 6  Complex-3-Assembly-Factors       7 2.028537e-03 -0.6735325  2.535671e-03
## 8  Complex-4-Assembly-Factors      23 3.113497e-06 -0.5616581  6.226995e-06
unlink("Mst1TG_old_mitocomplex_mitch.html")
mitch_report(res, outfile = "Mst1TG_old_mitocomplex_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_old_mitocomplex_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## Contour plot does not apply to unidimensional analysis.
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str229329eb6a54.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html

## [1] TRUE

Lipid custom gene set analysis

Biosynthesis and transport.

Downloaded from MGI:

lipid_biosynth <- c("9130409I23Rik", "A3galt2", "A4galt", "Abca2", "Abca3", "Abca8a", "Abca8b", "Abcd1", "Abcd2", "Abcd3", "Abcg1", "Abcg4", 
  "Abhd2", "Abhd3", "Abhd4", "Abhd5", "Abhd6", "Abhd8", "Acaca", "Acacb", "Acadl", "Acadvl", "Acat1", "Acbd3", "Acer1", "Acer2", "Acer3", 
  "Acly", "Acot7", "Acsbg1", "Acsbg2", "Acsbg3", "Acsf3", "Acsl1", "Acsl3", "Acsl4", "Acsl5", "Acsl6", "Acsm1", "Acsm2", "Acsm3", "Acsm4", 
  "Acsm5", "Acss1", "Acss2", "Adgrf5", "Adora2b", "Agk", "Agmo", "Agpat1", "Agpat2", "Agpat3", "Agpat4", "Agpat5", "Agps", "Agt", "Ajuba", 
  "Akr1c18", "Akr1c20", "Akr1c21", "Akr1c6", "Akr1d1", "Akt1", "Aldh1a1", "Aldh1a2", "Aldh1a3", "Aldh8a1", "Alox12", "Alox12b", "Alox12e", 
  "Alox15", "Alox5", "Alox8", "Aloxe3", "Amacr", "Ang", "Ang2", "Ang3", "Ang4", "Ang6", "Anxa1", "Apoa1", "Apoa2", "Apoa4", "Apoa5", "Apob", 
  "Apoc1", "Apoc2", "Apoc2l", "Apoc3", "Apoe", "Armc5", "Asah1", "Asah2", "Asxl3", "Atg14", "Atg7", "Atp1a1", "Avil", "Avp", "Avpr1a", "Awat2", 
  "B3galt1", "B3galt2", "B3galt4", "B3gnt5", "B4galnt1", "B4galt3", "B4galt4", "B4galt5", "B4galt6", "Baat", "Becn1", "Bmp2", "Bmp5", "Bmp6", 
  "Bmpr1b", "Bpnt1", "Bpnt2", "Brca1", "Bscl2", "C3", "Cacna1h", "Capn2", "Cbr4", "Ccdc3", "Ccn1", "Cd74", "Cdipt", "Cdk4", "Cds1", "Cds2", 
  "Ceacam1", "Ceacam2", "Cept1", "Cerkl", "Cers1", "Cers2", "Cers3", "Cers4", "Cers5", "Cers6", "Ces1a", "Ces1b", "Ces1c", "Ces1d", "Ces1e", 
  "Ces1f", "Ces1g", "Cftr", "Cga", "Ch25h", "Chka", "Chkb", "Chp1", "Chpt1", "Cish", "Clcn2", "Cln3", "Cmtm2a", "Cnep1r1", "Coq2", "Creb1", 
  "Crebl2", "Crh", "Crls1", "Crppa", "Ctdnep1", "Cwh43", "Cyb5r1", "Cyb5r2", "Cyb5r3", "Cyp11a1", "Cyp11b1", "Cyp11b2", "Cyp17a1", "Cyp19a1", 
  "Cyp1a1", "Cyp21a1", "Cyp27a1", "Cyp27b1", "Cyp2r1", "Cyp39a1", "Cyp4f39", "Cyp51", "Cyp7a1", "Cyp7b1", "Cyp8b1", "Dab2", "Daglb", "Dbi", 
  "Dctn6", "Ddx20", "Decr2", "Degs1", "Degs2", "Dgat1", "Dgat2", "Dgat2l6", "Dgka", "Dgkb", "Dgkd", "Dgke", "Dgkg", "Dgkh", "Dgki", "Dgkq", 
  "Dgkz", "Dhcr24", "Dhcr7", "Dhdds", "Dhh", "Dhrs11", "Dhrs7b", "Dhrs9", "Dkk3", "Dkkl1", "Dolk", "Dolpp1", "Dpm1", "Dpm2", "Dpm3", "Ebp", 
  "Edn1", "Edn2", "Efr3b", "Egr1", "Eif6", "Elovl1", "Elovl2", "Elovl3", "Elovl4", "Elovl5", "Elovl6", "Elovl7", "Enpp7", "Erbb4", "Erg28", 
  "Erlin1", "Erlin2", "Etnk1", "Etnk2", "Fa2h", "Fabp3", "Fabp5", "Fads1", "Fads2", "Fads2b", "Fads3", "Fads6", "Fam126a", "Fam126b", "Fam3a", 
  "Far1", "Fasn", "Fdft1", "Fdps", "Fdx1", "Fgf1", "Fgf15", "Fgf2", "Fgf7", "Fgfr4", "Fitm1", "Fitm2", "Fshb", "Fut4", "Fut9", "G6pd2", "G6pdx", 
  "Gal3st1", "Gal3st3", "Gba", "Gfi1", "Ggps1", "Gh", "Gip", "Gm12248", "Gm20671", "Gm28778", "Gm44502", "Gm6993", "Gm9745", "Gnpat", "Gpaa1", 
  "Gpam", "Gpat2", "Gpat3", "Gpat4", "Gper1", "Gpld1", "Gstm4", "Gstm7", "Gstp1", "Gstp2", "H2-Ke6", "H6pd", "Hacd1", "Hacd2", "Hacd3", "Hacd4", 
  "Hdhd5", "Hexb", "Hint2", "Hmgcr", "Hmgcs1", "Hmgcs2", "Hnf1a", "Hnf4a", "Hpgds", "Hrh1", "Hsd11b1", "Hsd17b1", "Hsd17b10", "Hsd17b11", 
  "Hsd17b12", "Hsd17b13", "Hsd17b2", "Hsd17b3", "Hsd17b7", "Hsd3b1", "Hsd3b2", "Hsd3b3", "Hsd3b4", "Hsd3b5", "Hsd3b6", "Hsd3b7", "Hsd3b9", 
  "Htr2a", "Htr2b", "Htr2c", "Idh1", "Idi1", "Idi2", "Ifng", "Igf1", "Igf1r", "Igf2", "Igfbp7", "Il1a", "Il1b", "Impa1", "Impa2", "Inpp1", 
  "Inpp4b", "Inppl1", "Insig1", "Insig2", "Ip6k1", "Ip6k2", "Ip6k3", "Isyna1", "Itpka", "Itpkb", "Itpkc", "Kdsr", "Lbr", "Lcat", "Lclat1", "Ldlr", 
  "Lep", "Lhcgr", "Lias", "Lipc", "Lipg", "Liph", "Lipi", "Lpcat1", "Lpcat2", "Lpcat2b", "Lpcat3", "Lpcat4", "Lpgat1", "Lpin1", "Lpin2", "Lpin3", 
  "Lpl", "Lss", "Ltc4s", "Malrd1", "Mapk9", "Mboat1", "Mboat2", "Mboat7", "Mcat", "Mecr", "Med1", "Mfsd2a", "Mgll", "Mid1ip1", "Mif", "Mlxipl", 
  "Mlycd", "Mogat1", "Mogat2", "Mppe1", "Msmo1", "Mtor", "Mup1", "Mvd", "Mvk", "Myo5a", "Ndufab1", "Nfkb1", "Npc1l1", "Nr0b1", "Nr1d1", "Nr1h2", 
  "Nr1h3", "Nr1h4", "Nr3c1", "Nsdhl", "Nus1", "Obp2a", "Olah", "Ormdl1", "Ormdl2", "Ormdl3", "Osbp", "Oxsm", "P2rx1", "P2rx7", "P3r3urf", "Pam", 
  "Pbx1", "Pck1", "Pck2", "Pcx", "Pcyt1a", "Pcyt1b", "Pcyt2", "Pde8b", "Pdgfa", "Pdgfb", "Pdk4", "Pdss1", "Pdss2", "Pecr", "Peds1", "Pemt", 
  "Pex2", "Pex5", "Pex7", "Pgap1", "Pgap2", "Pgap3", "Pgap4", "Pgs1", "Pi4k2a", "Pi4k2b", "Pi4ka", "Pi4kb", "Pibf1", "Piga", "Pigb", "Pigc", 
  "Pigf", "Pigg", "Pigh", "Pigk", "Pigl", "Pigm", "Pign", "Pigo", "Pigp", "Pigq", "Pigs", "Pigt", "Pigu", "Pigv", "Pigw", "Pigx", "Pigyl", "Pigz", 
  "Pik3c2a", "Pik3c2b", "Pik3c2g", "Pik3c3", "Pik3ca", "Pik3cb", "Pik3cd", "Pik3cg", "Pik3r1", "Pik3r2", "Pik3r3", "Pik3r4", "Pip4k2a", "Pip4k2b", 
  "Pip4k2c", "Pip5k1a", "Pip5k1b", "Pip5k1c", "Pip5kl1", "Pisd", "Pla2g10", "Pla2g15", "Pla2g1b", "Pla2g3", "Pla2g4a", "Pla2g4c", "Pla2g4f", 
  "Pla2g5", "Pla2g6", "Plaat3", "Plce1", "Plcg2", "Pld1", "Pld2", "Plin5", "Plp1", "Plpp1", "Plscr1", "Plscr3", "Pmvk", "Pnpla1", "Pnpla2", 
  "Pnpla3", "Pnpla8", "Por", "Ppara", "Ppard", "Ppargc1a", "Prkaa1", "Prkaa2", "Prkab1", "Prkab2", "Prkag1", "Prkag2", "Prkag3", "Prkcd", "Prmt3", 
  "Prox1", "Prpf19", "Prxl2b", "Ptdss1", "Ptdss2", "Ptgds", "Ptges", "Ptges2", "Ptges3", "Ptgis", "Ptgs1", "Ptgs2", "Ptpmt1", "Pyurf", "Qk", 
  "Rab38", "Rbp1", "Rdh1", "Rdh10", "Rdh16", "Rdh16f2", "Rdh19", "Rdh9", "Rest", "Rgn", "Rpe65", "Samd8", "Sc5d", "Scap", "Scarb1", "Sccpdh", 
  "Scd1", "Scd2", "Scd3", "Scd4", "Sco1", "Scp2", "Scp2d1", "Sdr42e1", "Sec14l2", "Selenoi", "Serac1", "Serinc1", "Serinc4", "Serinc5", 
  "Serpina12", "Sf1", "Sgms1", "Sgms2", "Sh3glb1", "Sh3yl1", "Sik1", "Sirt1", "Sirt3", "Sirt4", "Sla2", "Slc27a1", "Slc27a2", "Slc27a5", "Slc45a3", 
  "Smg1", "Smpd1", "Smpd2", "Smpd3", "Smpd4", "Smpd5", "Snai1", "Snai2", "Socs1", "Socs2", "Socs3", "Socs4", "Socs5", "Socs6", "Socs7", "Sod1", 
  "Sorbs1", "Sphk1", "Sphk2", "Sptlc1", "Sptlc2", "Sptlc3", "Sptssa", "Sptssb", "Sqle", "Srd5a1", "Srd5a2", "Srd5a3", "Srebf1", "Srebf2", 
  "St3gal1", "St3gal2", "St3gal3", "St3gal4", "St6galnac1", "St6galnac3", "St6galnac4", "St6galnac5", "St6galnac6", "St8sia2", "St8sia3", 
  "St8sia4", "St8sia5", "St8sia6", "Star", "Stard3", "Stard4", "Stk11", "Tafazzin", "Tamm41", "Tbxas1", "Tcf7l2", "Tecr", "Tecrl", "Thnsl2", 
  "Thrsp", "Tlcd3b", "Tm7sf2", "Tm9sf2", "Tmem150a", "Tmem38b", "Tnf", "Trex1", "Trib3", "Tspo", "Ttc7", "Ttc7b", "Ugcg", "Ugt8a", "Uvrag", 
  "Vac14", "Vapa", "Wdtc1", "Wnt4", "Zbtb20")

lipid_transport <-c("1700057G04Rik", "Abca1", "Abca12", "Abca13", "Abca14", "Abca15", "Abca16", "Abca17", "Abca2", "Abca3", "Abca4", "Abca5", 
  "Abca6", "Abca7", "Abca8a", "Abca8b", "Abca9", "Abcb11", "Abcb1a", "Abcb1b", "Abcb4", "Abcc1", "Abcc10", "Abcc2", "Abcc3", "Abcc4", "Abcd1", 
  "Abcd2", "Abcd3", "Abcd4", "Abcg1", "Abcg2", "Abcg4", "Abcg5", "Abcg8", "Acat2", "Ace", "Acsl1", "Acsl3", "Acsl4", "Acsl5", "Acsl6", "Adipoq", 
  "Agt", "Agtr1a", "Agtr2", "Akt1", "Akt2", "Ano3", "Ano4", "Ano6", "Ano7", "Ano9", "Anxa1", "Anxa2", "Apoa1", "Apoa2", "Apoa4", "Apoa5", "Apob", 
  "Apobr", "Apoc1", "Apoc2", "Apoc2l", "Apoc3", "Apoc4", "Apod", "Apoe", "Apof", "Apoh", "Apom", "Aqp8", "Aqp9", "Arl8b", "Arv1", "Atg2a", 
  "Atg2b", "Atg9a", "Atg9b", "Atp10a", "Atp10b", "Atp10d", "Atp11a", "Atp11b", "Atp11c", "Atp5j", "Atp8a1", "Atp8a2", "Atp8b1", "Atp8b2", 
  "Atp8b3", "Atp8b4", "Atp8b5", "Atp9a", "Atp9b", "Avpr1b", "Bdkrb2", "Bmp6", "C1qtnf1", "C2cd2l", "Cav1", "Cd36", "Ceacam1", "Ceacam2", "Cert1", 
  "Ces1a", "Ces1b", "Ces1c", "Ces1d", "Ces1e", "Ces1f", "Ces1g", "Cftr", "Cidec", "Cln3", "Commd1", "Cpt1b", "Cptp", "Crabp1", "Crabp2", "Crh", 
  "Crhr1", "Crot", "Cry1", "Cry2", "Cyp19a1", "Cyp2j5", "Cyp8b1", "Dab2", "Dbi", "Dennd5b", "Dgat1", "Drd2", "Drd3", "Drd4", "Ecrg4", "Edn1", 
  "Eepd1", "Egf", "Enpp7", "Eprs", "Erfe", "Esyt1", "Esyt2", "Esyt3", "Fabp1", "Fabp12", "Fabp2", "Fabp3", "Fabp4", "Fabp5", "Fabp6", "Fabp7", 
  "Fabp9", "Fasl", "Fis1", "Furin", "Fzd4", "Gal", "Galr1", "Gdf9", "Ghrl", "Gltp", "Gltpd2", "Gm2a", "Gm37389", "Gm5724", "Gm6614", "Got2", 
  "Gpihbp1", "Gps2", "Gramd1a", "Gramd1b", "Gramd1c", "Gulp1", "Hbp1", "Hdlbp", "Hnf1a", "Hrh2", "Igfbp3", "Il1a", "Il1b", "Inhba", "Irak1", 
  "Irs2", "Itgav", "Itgb3", "Kcnn4", "Kcnq1", "Kdm5b", "Kiss1r", "Lamtor1", "Lbp", "Lcat", "Ldlr", "Ldlrap1", "Lep", "Lhcgr", "Lima1", "Lipc", 
  "Lipg", "Lpcat3", "Lrat", "Lrp1", "Lrp10", "Lrp6", "Map2k6", "Mapk9", "Mexis", "Mfn2", "Mfsd2a", "Mfsd2b", "Mif", "Mip", "Msr1", "Mttp", "Naxe", 
  "Nfkbia", "Nkx3-1", "Nmb", "Nme4", "Nmur2", "Nos2", "Npc1", "Npc1l1", "Npc2", "Nr1h2", "Nr1h3", "Nr1h4", "Nrg1", "Ntsr1", "Nucb2", "Nus1", 
  "Oc90", "Osbp", "Osbp2", "Osbpl10", "Osbpl11", "Osbpl1a", "Osbpl2", "Osbpl3", "Osbpl5", "Osbpl6", "Osbpl8", "Osbpl9", "Oxt", "P2rx7", "P2ry2", 
  "Pcsk9", "Pctp", "Pdzd8", "Pip4k2a", "Pitpna", "Pitpnb", "Pitpnc1", "Pitpnm1", "Pla2g10", "Pla2g12a", "Pla2g12b", "Pla2g1b", "Pla2g2c", 
  "Pla2g2d", "Pla2g2e", "Pla2g2f", "Pla2g3", "Pla2g4a", "Pla2g4f", "Pla2g5", "Pla2g6", "Pla2r1", "Plekha3", "Plekha8", "Plin2", "Plppr4", 
  "Plscr1", "Plscr2", "Plscr3", "Plscr4", "Plscr5", "Pltp", "Pmp2", "Pnlip", "Pnpla8", "Pomc", "Pon1", "Pparg", "Prap1", "Prelid1", "Prelid2", 
  "Prelid3a", "Prelid3b", "Prkcd", "Proca1", "Psap", "Ptch1", "Ptges", "Ptgs2", "Ptpn11", "Rbp1", "Rbp2", "Rbp4", "Rbp7", "Relch", "Ren1", 
  "Repin1", "Retn", "Rft1", "Rps6kb1", "Runx1", "Sar1b", "Scarb1", "Scarb2", "Scp2", "Scp2d1", "Sec24a", "Selenom", "Serac1", "Sgpp1", "Shh", 
  "Sigmar1", "Sirt1", "Slc10a1", "Slc10a2", "Slc10a3", "Slc10a4", "Slc10a5", "Slc10a6", "Slc22a22", "Slc25a17", "Slc25a20", "Slc27a1", "Slc27a2", 
  "Slc27a3", "Slc27a4", "Slc27a5", "Slc27a6", "Slc2a1", "Slc4a1", "Slc51a", "Slc51b", "Slc5a8", "Slc66a2", "Slco1a1", "Slco1a4", "Slco1a5", 
  "Slco1a6", "Slco1b2", "Slco1c1", "Slco2a1", "Slco2b1", "Slco3a1", "Snord60", "Soat1", "Soat2", "Spg11", "Spns1", "Spns2", "Spns3", "Spp1", 
  "Spx", "Srebf2", "Sstr4", "Star", "Stard10", "Stard3", "Stard4", "Stard5", "Stard6", "Stoml1", "Stra6", "Stra6l", "Stx12", "Surf4", "Syk", 
  "Syt7", "Tac1", "Tex2", "Thbs1", "Tmem30a", "Tmem30b", "Tmem30c", "Tmem41b", "Tmf1", "Tnfaip8l3", "Tnfrsf11a", "Tnfsf11", "Tpcn2", "Trem2", 
  "Triap1", "Trpc5", "Tsku", "Tspo", "Tspo2", "Ttc39b", "Ttc39d", "Ttpa", "Ugcg", "Vamp7", "Vapa", "Vldlr", "Vmp1", "Vps4a", "Vps4b", "Vps51", 
  "Washc1", "Xkr4", "Xkr5", "Xkr6", "Xkr7", "Xkr8", "Xkr9", "Xrcc4", "Yjefn3", "Zdhhc8")

lipid_sets <- list("lipid_biosynth"=lipid_biosynth,"lipid_transport"=lipid_transport)

gsets <- lipid_sets
# mitch pathways of interest
yy <- mitch_import(x, DEtype="deseq2", geneTable=gt)
## Note: Mean no. genes in input = 17755
## Note: no. genes in output = 14877
## Note: estimated proportion of input genes in output = 0.838
res <- mitch_calc(yy, gsets, priority="significance")
## Note: When prioritising by significance (ie: small 
##             p-values), large effect sizes might be missed.
head(res$enrichment_result,20)
##               set setSize      pMANOVA     s.young       s.old    p.young
## 1  lipid_biosynth     508 0.0003049783 -0.06187615 -0.09977790 0.01759777
## 2 lipid_transport     277 0.2952926473  0.01995203 -0.01372534 0.56885805
##          p.old     s.dist         SD p.adjustMANOVA
## 1 0.0001288145 0.11740651 0.02680058   0.0006099566
## 2 0.6951110466 0.02421711 0.02381349   0.2952926473
unlink("Mst1TG_young_and_old_lipidpathway_mitch.html")
# top N gene heatmap
mitch_report(res, outfile = "Mst1TG_young_and_old_lipidpathway_mitch.html")
## Dataset saved as " /tmp/Rtmp0VANOs/Mst1TG_young_and_old_lipidpathway_mitch.rds ".
## 
## 
## processing file: mitch.Rmd
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |..                                                                    |   3%
##    inline R code fragments
## 
## 
  |                                                                            
  |....                                                                  |   6%
## label: checklibraries (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |......                                                                |   9%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........                                                              |  12%
## label: peek (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..........                                                            |  15%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............                                                          |  18%
## label: metrics (with options) 
## List of 1
##  $ echo: logi FALSE
## 
## 
  |                                                                            
  |..............                                                        |  21%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................                                                      |  24%
## label: scatterplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ message   : logi FALSE
##  $ warning   : logi FALSE
## 
  |                                                                            
  |...................                                                   |  26%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................                                                 |  29%
## label: contourplot (with options) 
## List of 5
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6.5
##  $ warning   : logi FALSE
##  $ message   : logi FALSE
## 
  |                                                                            
  |.......................                                               |  32%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.........................                                             |  35%
## label: input_geneset_metrics1 (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |...........................                                           |  38%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.............................                                         |  41%
## label: input_geneset_metrics2 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
## 
  |                                                                            
  |...............................                                       |  44%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.................................                                     |  47%
## label: input_geneset_metrics3 (with options) 
## List of 5
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ message   : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
## 
  |                                                                            
  |...................................                                   |  50%
##   ordinary text without R code
## 
## 
  |                                                                            
  |.....................................                                 |  53%
## label: echart1d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.......................................                               |  56%
## label: echart2d (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.........................................                             |  59%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...........................................                           |  62%
## label: heatmap (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 10
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.............................................                         |  65%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...............................................                       |  68%
## label: effectsize (with options) 
## List of 6
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 7
##  $ fig.width : num 7
##  $ fig.show  : chr "all"
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |.................................................                     |  71%
##   ordinary text without R code
## 
## 
  |                                                                            
  |...................................................                   |  74%
## label: results_table (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |......................................................                |  76%
##   ordinary text without R code
## 
## 
  |                                                                            
  |........................................................              |  79%
## label: results_table_complete (with options) 
## List of 2
##  $ results: chr "asis"
##  $ echo   : logi FALSE
## 
## 
  |                                                                            
  |..........................................................            |  82%
##   ordinary text without R code
## 
## 
  |                                                                            
  |............................................................          |  85%
## label: detailed_geneset_reports1d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 6
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
## 
  |                                                                            
  |..............................................................        |  88%
##   ordinary text without R code
## 
## 
  |                                                                            
  |................................................................      |  91%
## label: detailed_geneset_reports2d (with options) 
## List of 7
##  $ results   : chr "asis"
##  $ echo      : logi FALSE
##  $ fig.height: num 5
##  $ fig.width : num 6
##  $ out.width : chr "80%"
##  $ comment   : logi NA
##  $ message   : logi FALSE
## 
  |                                                                            
  |..................................................................    |  94%
##   ordinary text without R code
## 
## 
  |                                                                            
  |....................................................................  |  97%
## label: session_info (with options) 
## List of 3
##  $ include: logi TRUE
##  $ echo   : logi TRUE
##  $ results: chr "markup"
## 
## 
  |                                                                            
  |......................................................................| 100%
##   ordinary text without R code
## output file: /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md
## /home/mdz/anaconda3/bin/pandoc +RTS -K512m -RTS /mnt/bfx6/bfx/du_xiao/young_mst1tg/integrate/mitch.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/Rtmp0VANOs/mitch_report.html --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /usr/lib/R/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /usr/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable theme=bootstrap --include-in-header /tmp/Rtmp0VANOs/rmarkdown-str22933fb5c6e5.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
## 
## Output created: /tmp/Rtmp0VANOs/mitch_report.html
## [1] TRUE
# heatmaps of pathways of interest
# colour scheme
colfunc <- colorRampPalette(c("blue", "white", "red"))

topsets <- head(res$enrichment_result,50)$set
mytopsets <- gsets[which(names( gsets ) %in% topsets)]
yo <- young[,7:ncol(young)]
colnames(yo) <- paste("y",colnames(yo))
ol <- old[,7:ncol(old)]
colnames(ol) <- paste("o",colnames(ol))
mx <- merge(yo,ol,by=0)
rownames(mx) <- mx$Row.names
mx$Row.names = NULL

i = 1
par(mar = c(10, 8, 8, 4) + 0.2)
for ( i in seq_along(mytopsets) ) {
  g <- as.vector(unlist(mytopsets[i]))
  symbol <- sapply((strsplit(rownames(mx)," ")),"[[",2)
  z <- mx[which(symbol %in% g),]
  SETNAME=names(mytopsets[i])
  heatmap.2( as.matrix(z), col=colfunc(25),scale="row",
   trace="none",margins = c(6,20), cexRow=.4, cexCol=.8)
  mtext(SETNAME)
}

System information

sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.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       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] pkgload_1.2.1   GGally_2.1.2    beeswarm_0.4.0  gtools_3.9.2   
##  [5] echarts4r_0.4.1 mitch_1.4.0     gplots_3.1.1    reshape2_1.4.4 
##  [9] forcats_0.5.1   stringr_1.4.0   dplyr_1.0.7     purrr_0.3.4    
## [13] readr_2.0.0     tidyr_1.1.3     tibble_3.1.3    ggplot2_3.3.5  
## [17] tidyverse_1.3.1
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-7       fs_1.5.0           lubridate_1.7.10   RColorBrewer_1.1-2
##  [5] httr_1.4.2         rprojroot_2.0.2    tools_4.1.2        backports_1.2.1   
##  [9] bslib_0.2.5.1      utf8_1.2.2         R6_2.5.0           KernSmooth_2.23-20
## [13] DBI_1.1.1          colorspace_2.0-2   withr_2.4.2        tidyselect_1.1.1  
## [17] gridExtra_2.3      compiler_4.1.2     cli_3.0.1          rvest_1.0.0       
## [21] xml2_1.3.2         desc_1.3.0         labeling_0.4.2     sass_0.4.0        
## [25] caTools_1.18.2     scales_1.1.1       digest_0.6.27      rmarkdown_2.9     
## [29] pkgconfig_2.0.3    htmltools_0.5.1.1  dbplyr_2.1.1       fastmap_1.1.0     
## [33] highr_0.9          htmlwidgets_1.5.3  rlang_0.4.11       readxl_1.3.1      
## [37] rstudioapi_0.13    shiny_1.6.0        jquerylib_0.1.4    generics_0.1.0    
## [41] farver_2.1.0       jsonlite_1.7.2     magrittr_2.0.1     Rcpp_1.0.7        
## [45] munsell_0.5.0      fansi_0.5.0        lifecycle_1.0.0    stringi_1.7.3     
## [49] yaml_2.2.1         MASS_7.3-55        plyr_1.8.6         grid_4.1.2        
## [53] parallel_4.1.2     promises_1.2.0.1   crayon_1.4.1       haven_2.4.1       
## [57] hms_1.1.0          knitr_1.33         pillar_1.6.1       reprex_2.0.0      
## [61] glue_1.4.2         evaluate_0.14      modelr_0.1.8       vctrs_0.3.8       
## [65] tzdb_0.1.2         httpuv_1.6.1       cellranger_1.1.0   gtable_0.3.0      
## [69] reshape_0.8.8      assertthat_0.2.1   xfun_0.24          mime_0.11         
## [73] xtable_1.8-4       broom_0.7.8        later_1.2.0        ellipsis_0.3.2