Author: S.M. Pagnotta - Dept. of Science and Technology, Università degli Studi del Sannio (Benevento, Italy)
Date: 2025-03-28

# massive GST (version 20250326)

#### S.M. Pagnotta - Dept. of Science and Technology, Università degli Studi del Sannio (Benevento, Italy)

#### 03/28/2025

This vignette shows how to use the massiveGST package.

# Installation

Get the stable release from CRAN

    install.packages("massiveGST")

On going bug correction and future improvements are in github.

    if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")
    BiocManager::install("stefanoMP/massiveGST")

# Setup

    suppressPackageStartupMessages(library(massiveGST, quietly = TRUE))

## getting gene-profile from a file

In any cases, the names of the list have to match the gene names in any of their coding (gene-symbol, entrez, ensembl, etc.). To explain some details of the functions, we assume that positive values of the gene-profile are up-regulated in the treatment group, while the negative ones are up-regulated in the control group. In other words, the positive genes are associated with the treatment group, while the others are associated with the control samples.

Here, we consider the working gene-profile from Frattini et al, 2018, stored as external data in the package.

    fname <- system.file("extdata", package="massiveGST")
    fname <- file.path(fname, "pre_ranked_list.txt")
    geneProfile <- get_geneProfile(fname)
    class(geneProfile)

    ## [1] "numeric"

    head(geneProfile)

    ##    WASF3     VAV3     PFKM     LGR6  SLC6A11 KIAA1147
    ## 4.819656 4.332110 4.244893 4.182461 4.088992 4.045543

    tail(geneProfile)

    ##      SLC47A2        STON1 DKFZp434K191      PLEKHO1        PDE6B       IFNGR2
    ##    -2.728522    -2.748892    -2.881312    -2.942627    -3.141299    -3.158738

## getting gene-sets from msigdbr

msigdbr package is an R distribution of the most recent release of the MSigDB collection of gene-sets. The function get_geneSets_from_msigdbr is a wrapper allowing the creation of a data structure for following gene-set enrichment analysis. Function parameters are those of the msigdbr function, except for ‘what’, allowing to choose the coding of the gene names.

This example extracts gene-sets where the gene-names are the gene symbols. Other possibilities have been specified in the ‘man’ fo the functions, and essentially they are the names of the columns of the data frame retrieved by the msigdbr function.

    fname <- system.file("extdata", package="massiveGST")
    fname <- file.path(fname, "h.all.v2024.1.Hs.symbols.gmt")
    geneSets <- get_geneSets_from_local_files(fname)
    class(geneSets)

    ## [1] "list"

    head(names(geneSets))

    ## [1] "HALLMARK_ADIPOGENESIS"        "HALLMARK_ALLOGRAFT_REJECTION"
    ## [3] "HALLMARK_ANDROGEN_RESPONSE"   "HALLMARK_ANGIOGENESIS"
    ## [5] "HALLMARK_APICAL_JUNCTION"     "HALLMARK_APICAL_SURFACE"

Optionally, the gene-sets collection can be stored in gmt formatted file

    fname <- file.path(tempdir(), "hallmarks.gmt")
    write_geneSets_to_gmt(geneSets, fileName = fname)

and retrieved with the code

    fname <- file.path(tempdir(), "hallmarks.gmt")
    tmp <- get_geneSets_from_local_files(fname)

    class(geneSets)

    ## [1] "list"

    head(names(geneSets))

    ## [1] "HALLMARK_ADIPOGENESIS"        "HALLMARK_ALLOGRAFT_REJECTION"
    ## [3] "HALLMARK_ANDROGEN_RESPONSE"   "HALLMARK_ANGIOGENESIS"
    ## [5] "HALLMARK_APICAL_JUNCTION"     "HALLMARK_APICAL_SURFACE"

# Running the analysis with alternative = “two.sided”

    system.time({ans <- massiveGST(geneProfile, geneSets, alternative = "two.sided")})

    ##    user  system elapsed
    ##   0.047   0.016   0.064

    class(ans)

    ## [1] "mGST"       "data.frame"

    ans[1:6,]

    ##                                    size actualSize       NES      odd logit2NES
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907051 2.233160 1.1590869
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5895587 1.436402 0.5224595
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946149 1.466790 0.5526627
    ## HALLMARK_MITOTIC_SPINDLE            199        187 0.5508146 1.226252 0.2942556
    ## HALLMARK_BILE_ACID_METABOLISM       112        112 0.5856305 1.413305 0.4990726
    ## HALLMARK_FATTY_ACID_METABOLISM      158        148 0.5649870 1.298782 0.3771593
    ##                                    abs_logit2NES      p.value     BH.value
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION     1.1590869 2.230464e-18 2.788080e-17
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY       0.5224595 3.129669e-05 1.564834e-04
    ## HALLMARK_ADIPOGENESIS                  0.5526627 1.514858e-05 8.415875e-05
    ## HALLMARK_MITOTIC_SPINDLE               0.2942556 1.664775e-02 4.380987e-02
    ## HALLMARK_BILE_ACID_METABOLISM          0.4990726 1.752278e-03 6.226110e-03
    ## HALLMARK_FATTY_ACID_METABOLISM         0.3771593 6.386537e-03 1.995793e-02
    ##                                         B.value relevance
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION 1.115232e-16      59.5
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY   1.564834e-03      59.0
    ## HALLMARK_ADIPOGENESIS              7.574288e-04      56.0
    ## HALLMARK_MITOTIC_SPINDLE           8.323875e-01      52.5
    ## HALLMARK_BILE_ACID_METABOLISM      8.761391e-02      48.0
    ## HALLMARK_FATTY_ACID_METABOLISM     3.193268e-01      48.0
    ##                                                                                                                        link
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_OXIDATIVE_PHOSPHORYLATION
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_EARLY
    ## HALLMARK_ADIPOGENESIS                           https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ADIPOGENESIS
    ## HALLMARK_MITOTIC_SPINDLE                     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MITOTIC_SPINDLE
    ## HALLMARK_BILE_ACID_METABOLISM           https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_BILE_ACID_METABOLISM
    ## HALLMARK_FATTY_ACID_METABOLISM         https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_FATTY_ACID_METABOLISM

The analysis result is essentially a data frame; the first class ‘mGST’ allows hooking other methods to handle the output.

The results can be saved in tab-separated value (tsv) format or an XLS format file.

    fname <- file.path(tempdir(), "massiveGST_results.tsv")
    save_as_tsv(ans, file_name = fname)

    fname <- file.path(tempdir(), "massiveGST_results.xls")
    save_as_xls(ans, file_name = fname)

## The summary method.

The summary function allows customizing the result of the analysis.

    summary(ans)[1:10,]

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_MITOTIC_SPINDLE            199        187 0.5508    0.2943 1.7e-02
    ## HALLMARK_BILE_ACID_METABOLISM       112        112 0.5856    0.4991 1.8e-03
    ## HALLMARK_FATTY_ACID_METABOLISM      158        148 0.5650    0.3772 6.4e-03
    ## HALLMARK_G2M_CHECKPOINT             200        178 0.5475    0.2748 2.9e-02
    ## HALLMARK_MTORC1_SIGNALING           200        187 0.5376    0.2172 7.7e-02
    ## HALLMARK_UV_RESPONSE_DN             144        132 0.5528    0.3059 3.6e-02
    ## HALLMARK_HEME_METABOLISM            200        180 0.5325    0.1877 1.3e-01
    ##                                    BH.value B.value relevance
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  2.8e-17 1.1e-16      59.5
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    1.6e-04 1.6e-03      59.0
    ## HALLMARK_ADIPOGENESIS               8.4e-05 7.6e-04      56.0
    ## HALLMARK_MITOTIC_SPINDLE            4.4e-02 8.3e-01      52.5
    ## HALLMARK_BILE_ACID_METABOLISM       6.2e-03 8.8e-02      48.0
    ## HALLMARK_FATTY_ACID_METABOLISM      2.0e-02 3.2e-01      48.0
    ## HALLMARK_G2M_CHECKPOINT             6.9e-02 1.0e+00      47.0
    ## HALLMARK_MTORC1_SIGNALING           1.6e-01 1.0e+00      46.5
    ## HALLMARK_UV_RESPONSE_DN             8.2e-02 1.0e+00      42.0
    ## HALLMARK_HEME_METABOLISM            2.5e-01 1.0e+00      41.0

With it:

- The ordering of the table can be chosen.

    summary(ans, order_by = "NES")[1:10,]

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ## HALLMARK_BILE_ACID_METABOLISM       112        112 0.5856    0.4991 1.8e-03
    ## HALLMARK_FATTY_ACID_METABOLISM      158        148 0.5650    0.3772 6.4e-03
    ## HALLMARK_NOTCH_SIGNALING             32         30 0.5572    0.3316 2.8e-01
    ## HALLMARK_UV_RESPONSE_DN             144        132 0.5528    0.3059 3.6e-02
    ## HALLMARK_MITOTIC_SPINDLE            199        187 0.5508    0.2943 1.7e-02
    ## HALLMARK_G2M_CHECKPOINT             200        178 0.5475    0.2748 2.9e-02
    ## HALLMARK_PROTEIN_SECRETION           96         93 0.5459    0.2656 1.3e-01
    ##                                    BH.value B.value
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  2.8e-17 1.1e-16
    ## HALLMARK_ADIPOGENESIS               8.4e-05 7.6e-04
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    1.6e-04 1.6e-03
    ## HALLMARK_BILE_ACID_METABOLISM       6.2e-03 8.8e-02
    ## HALLMARK_FATTY_ACID_METABOLISM      2.0e-02 3.2e-01
    ## HALLMARK_NOTCH_SIGNALING            4.2e-01 1.0e+00
    ## HALLMARK_UV_RESPONSE_DN             8.2e-02 1.0e+00
    ## HALLMARK_MITOTIC_SPINDLE            4.4e-02 8.3e-01
    ## HALLMARK_G2M_CHECKPOINT             6.9e-02 1.0e+00
    ## HALLMARK_PROTEIN_SECRETION          2.5e-01 1.0e+00

    summary(ans, order_by = "p.value")[1:10,]

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  200        186 0.2458   -1.6175 6.8e-33
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE   97         87 0.1688   -2.3000 1.3e-26
    ## HALLMARK_ALLOGRAFT_REJECTION        200        189 0.2816   -1.3512 4.4e-25
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_INFLAMMATORY_RESPONSE      200        192 0.3517   -0.8825 1.4e-12
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    200        185 0.3549   -0.8624 1.0e-11
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     87         83 0.3064   -1.1789 1.1e-09
    ## HALLMARK_COMPLEMENT                 200        190 0.3869   -0.6643 7.8e-08
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ##                                    BH.value B.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  3.4e-31 3.4e-31
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE  3.3e-25 6.6e-25
    ## HALLMARK_ALLOGRAFT_REJECTION        7.3e-24 2.2e-23
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  2.8e-17 1.1e-16
    ## HALLMARK_INFLAMMATORY_RESPONSE      1.4e-11 7.2e-11
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    8.5e-11 5.1e-10
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING    7.7e-09 5.4e-08
    ## HALLMARK_COMPLEMENT                 4.9e-07 3.9e-06
    ## HALLMARK_ADIPOGENESIS               8.4e-05 7.6e-04
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    1.6e-04 1.6e-03

    summary(ans, order_by = "bonferroni")[1:10,]

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  200        186 0.2458   -1.6175 6.8e-33
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE   97         87 0.1688   -2.3000 1.3e-26
    ## HALLMARK_ALLOGRAFT_REJECTION        200        189 0.2816   -1.3512 4.4e-25
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_INFLAMMATORY_RESPONSE      200        192 0.3517   -0.8825 1.4e-12
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    200        185 0.3549   -0.8624 1.0e-11
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     87         83 0.3064   -1.1789 1.1e-09
    ## HALLMARK_COMPLEMENT                 200        190 0.3869   -0.6643 7.8e-08
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ##                                    BH.value B.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  3.4e-31 3.4e-31
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE  3.3e-25 6.6e-25
    ## HALLMARK_ALLOGRAFT_REJECTION        7.3e-24 2.2e-23
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  2.8e-17 1.1e-16
    ## HALLMARK_INFLAMMATORY_RESPONSE      1.4e-11 7.2e-11
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    8.5e-11 5.1e-10
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING    7.7e-09 5.4e-08
    ## HALLMARK_COMPLEMENT                 4.9e-07 3.9e-06
    ## HALLMARK_ADIPOGENESIS               8.4e-05 7.6e-04
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    1.6e-04 1.6e-03

- Some columns can be removed.

    (tmp <- summary(ans, order_by = "p.value", cols_to_remove = c("BH.value", "B.value"))[1:10,])

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  200        186 0.2458   -1.6175 6.8e-33
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE   97         87 0.1688   -2.3000 1.3e-26
    ## HALLMARK_ALLOGRAFT_REJECTION        200        189 0.2816   -1.3512 4.4e-25
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_INFLAMMATORY_RESPONSE      200        192 0.3517   -0.8825 1.4e-12
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    200        185 0.3549   -0.8624 1.0e-11
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     87         83 0.3064   -1.1789 1.1e-09
    ## HALLMARK_COMPLEMENT                 200        190 0.3869   -0.6643 7.8e-08
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ##                                                                                                                        link
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_GAMMA_RESPONSE
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_ALPHA_RESPONSE
    ## HALLMARK_ALLOGRAFT_REJECTION             https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ALLOGRAFT_REJECTION
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_OXIDATIVE_PHOSPHORYLATION
    ## HALLMARK_INFLAMMATORY_RESPONSE         https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INFLAMMATORY_RESPONSE
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_TNFA_SIGNALING_VIA_NFKB
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL6_JAK_STAT3_SIGNALING
    ## HALLMARK_COMPLEMENT                               https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_COMPLEMENT
    ## HALLMARK_ADIPOGENESIS                           https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ADIPOGENESIS
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_EARLY

- The formattable package can be invoked to get a more readable table.

    summary(ans, as.formattable = TRUE)

| size | actualSize | NES | logit2NES | p.value | BH.value | B.value | relevance
--- | --- | --- | --- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 200 | 177 | 0.6907 | 1.1591 | 2.2e-18 | 2.8e-17 | 1.1e-16 | 59.5
HALLMARK_ESTROGEN_RESPONSE_EARLY | 200 | 182 | 0.5896 | 0.5225 | 3.1e-05 | 1.6e-04 | 1.6e-03 | 59.0
HALLMARK_ADIPOGENESIS | 200 | 176 | 0.5946 | 0.5527 | 1.5e-05 | 8.4e-05 | 7.6e-04 | 56.0
HALLMARK_MITOTIC_SPINDLE | 199 | 187 | 0.5508 | 0.2943 | 1.7e-02 | 4.4e-02 | 8.3e-01 | 52.5
HALLMARK_BILE_ACID_METABOLISM | 112 | 112 | 0.5856 | 0.4991 | 1.8e-03 | 6.2e-03 | 8.8e-02 | 48.0
HALLMARK_FATTY_ACID_METABOLISM | 158 | 148 | 0.5650 | 0.3772 | 6.4e-03 | 2.0e-02 | 3.2e-01 | 48.0
HALLMARK_G2M_CHECKPOINT | 200 | 178 | 0.5475 | 0.2748 | 2.9e-02 | 6.9e-02 | 1.0e+00 | 47.0
HALLMARK_MTORC1_SIGNALING | 200 | 187 | 0.5376 | 0.2172 | 7.7e-02 | 1.6e-01 | 1.0e+00 | 46.5
HALLMARK_UV_RESPONSE_DN | 144 | 132 | 0.5528 | 0.3059 | 3.6e-02 | 8.2e-02 | 1.0e+00 | 42.0
HALLMARK_HEME_METABOLISM | 200 | 180 | 0.5325 | 0.1877 | 1.3e-01 | 2.5e-01 | 1.0e+00 | 41.0
HALLMARK_PROTEIN_SECRETION | 96 | 93 | 0.5459 | 0.2656 | 1.3e-01 | 2.5e-01 | 1.0e+00 | 32.0
HALLMARK_MYC_TARGETS_V1 | 200 | 177 | 0.5202 | 0.1165 | 3.5e-01 | 4.8e-01 | 1.0e+00 | 31.5
HALLMARK_NOTCH_SIGNALING | 32 | 30 | 0.5572 | 0.3316 | 2.8e-01 | 4.2e-01 | 1.0e+00 | 29.0
HALLMARK_ESTROGEN_RESPONSE_LATE | 200 | 191 | 0.5057 | 0.0326 | 7.9e-01 | 8.2e-01 | 1.0e+00 | 28.0
HALLMARK_UNFOLDED_PROTEIN_RESPONSE | 113 | 101 | 0.5285 | 0.1647 | 3.2e-01 | 4.7e-01 | 1.0e+00 | 27.0
HALLMARK_E2F_TARGETS | 200 | 171 | 0.5113 | 0.0651 | 6.1e-01 | 6.8e-01 | 1.0e+00 | 22.0
HALLMARK_PEROXISOME | 104 | 100 | 0.5181 | 0.1047 | 5.3e-01 | 6.0e-01 | 1.0e+00 | 20.0
HALLMARK_WNT_BETA_CATENIN_SIGNALING | 42 | 41 | 0.5308 | 0.1782 | 4.9e-01 | 5.9e-01 | 1.0e+00 | 20.0
HALLMARK_ANGIOGENESIS | 36 | 36 | 0.5321 | 0.1856 | 5.0e-01 | 5.9e-01 | 1.0e+00 | 19.0
HALLMARK_ANDROGEN_RESPONSE | 101 | 91 | 0.5133 | 0.0765 | 6.6e-01 | 7.2e-01 | 1.0e+00 | 14.0
HALLMARK_PI3K_AKT_MTOR_SIGNALING | 105 | 99 | 0.5016 | 0.0090 | 9.6e-01 | 9.8e-01 | 1.0e+00 | 11.0
HALLMARK_CHOLESTEROL_HOMEOSTASIS | 74 | 70 | 0.5008 | 0.0049 | 9.8e-01 | 9.8e-01 | 1.0e+00 | 6.0
HALLMARK_HEDGEHOG_SIGNALING | 36 | 35 | 0.4661 | -0.1958 | 4.9e-01 | 5.9e-01 | 1.0e+00 | -11.0
HALLMARK_MYC_TARGETS_V2 | 58 | 49 | 0.4716 | -0.1639 | 4.9e-01 | 5.9e-01 | 1.0e+00 | -12.0
HALLMARK_APICAL_SURFACE | 44 | 41 | 0.4641 | -0.2073 | 4.3e-01 | 5.5e-01 | 1.0e+00 | -16.0
HALLMARK_PANCREAS_BETA_CELLS | 40 | 40 | 0.4560 | -0.2544 | 3.4e-01 | 4.8e-01 | 1.0e+00 | -21.0
HALLMARK_KRAS_SIGNALING_DN | 200 | 181 | 0.4795 | -0.1181 | 3.4e-01 | 4.8e-01 | 1.0e+00 | -24.5
HALLMARK_XENOBIOTIC_METABOLISM | 200 | 189 | 0.4930 | -0.0405 | 7.4e-01 | 7.9e-01 | 1.0e+00 | -25.5
HALLMARK_REACTIVE_OXYGEN_SPECIES_PATHWAY | 49 | 44 | 0.4501 | -0.2888 | 2.5e-01 | 4.1e-01 | 1.0e+00 | -28.0
HALLMARK_APICAL_JUNCTION | 200 | 185 | 0.4760 | -0.1387 | 2.6e-01 | 4.1e-01 | 1.0e+00 | -30.0
HALLMARK_TGF_BETA_SIGNALING | 54 | 52 | 0.4511 | -0.2829 | 2.2e-01 | 3.7e-01 | 1.0e+00 | -30.0
HALLMARK_DNA_REPAIR | 150 | 134 | 0.4646 | -0.2048 | 1.6e-01 | 2.8e-01 | 1.0e+00 | -31.0
HALLMARK_SPERMATOGENESIS | 135 | 122 | 0.4610 | -0.2258 | 1.4e-01 | 2.5e-01 | 1.0e+00 | -32.0
HALLMARK_P53_PATHWAY | 200 | 181 | 0.4716 | -0.1640 | 1.9e-01 | 3.2e-01 | 1.0e+00 | -32.5
HALLMARK_MYOGENESIS | 200 | 194 | 0.4830 | -0.0984 | 4.1e-01 | 5.4e-01 | 1.0e+00 | -35.0
HALLMARK_UV_RESPONSE_UP | 158 | 148 | 0.4567 | -0.2504 | 6.9e-02 | 1.5e-01 | 1.0e+00 | -37.0
HALLMARK_KRAS_SIGNALING_UP | 200 | 185 | 0.4523 | -0.2764 | 2.5e-02 | 6.3e-02 | 1.0e+00 | -46.0
HALLMARK_COAGULATION | 138 | 132 | 0.4100 | -0.5250 | 3.6e-04 | 1.4e-03 | 1.8e-02 | -50.0
HALLMARK_APOPTOSIS | 161 | 157 | 0.4170 | -0.4835 | 3.3e-04 | 1.4e-03 | 1.7e-02 | -52.0
HALLMARK_GLYCOLYSIS | 200 | 187 | 0.4489 | -0.2961 | 1.6e-02 | 4.4e-02 | 8.0e-01 | -54.0
HALLMARK_IL2_STAT5_SIGNALING | 199 | 179 | 0.4159 | -0.4902 | 1.0e-04 | 4.8e-04 | 5.2e-03 | -55.0
HALLMARK_IL6_JAK_STAT3_SIGNALING | 87 | 83 | 0.3064 | -1.1789 | 1.1e-09 | 7.7e-09 | 5.4e-08 | -55.0
HALLMARK_HYPOXIA | 200 | 186 | 0.4338 | -0.3842 | 1.9e-03 | 6.2e-03 | 9.3e-02 | -56.5
HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION | 200 | 191 | 0.4449 | -0.3191 | 8.7e-03 | 2.6e-02 | 4.4e-01 | -60.0
HALLMARK_INTERFERON_ALPHA_RESPONSE | 97 | 87 | 0.1688 | -2.3000 | 1.3e-26 | 3.3e-25 | 6.6e-25 | -63.0
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 200 | 185 | 0.3549 | -0.8624 | 1.0e-11 | 8.5e-11 | 5.1e-10 | -65.0
HALLMARK_COMPLEMENT | 200 | 190 | 0.3869 | -0.6643 | 7.8e-08 | 4.9e-07 | 3.9e-06 | -69.0
HALLMARK_INTERFERON_GAMMA_RESPONSE | 200 | 186 | 0.2458 | -1.6175 | 6.8e-33 | 3.4e-31 | 3.4e-31 | -74.5
HALLMARK_INFLAMMATORY_RESPONSE | 200 | 192 | 0.3517 | -0.8825 | 1.4e-12 | 1.4e-11 | 7.2e-11 | -76.0
HALLMARK_ALLOGRAFT_REJECTION | 200 | 189 | 0.2816 | -1.3512 | 4.4e-25 | 7.3e-24 | 2.2e-23 | -76.5

    summary(ans, order_by = "p.value", cols_to_remove = c("BH.value", "B.value"), as.formattable = TRUE)

| size | actualSize | NES | logit2NES | p.value | link
--- | --- | --- | --- | --- | --- | ---
HALLMARK_INTERFERON_GAMMA_RESPONSE | 200 | 186 | 0.2458 | -1.6175 | 6.8e-33 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_GAMMA_RESPONSE
HALLMARK_INTERFERON_ALPHA_RESPONSE | 97 | 87 | 0.1688 | -2.3000 | 1.3e-26 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_ALPHA_RESPONSE
HALLMARK_ALLOGRAFT_REJECTION | 200 | 189 | 0.2816 | -1.3512 | 4.4e-25 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ALLOGRAFT_REJECTION
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 200 | 177 | 0.6907 | 1.1591 | 2.2e-18 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_OXIDATIVE_PHOSPHORYLATION
HALLMARK_INFLAMMATORY_RESPONSE | 200 | 192 | 0.3517 | -0.8825 | 1.4e-12 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INFLAMMATORY_RESPONSE
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 200 | 185 | 0.3549 | -0.8624 | 1.0e-11 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_TNFA_SIGNALING_VIA_NFKB
HALLMARK_IL6_JAK_STAT3_SIGNALING | 87 | 83 | 0.3064 | -1.1789 | 1.1e-09 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL6_JAK_STAT3_SIGNALING
HALLMARK_COMPLEMENT | 200 | 190 | 0.3869 | -0.6643 | 7.8e-08 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_COMPLEMENT
HALLMARK_ADIPOGENESIS | 200 | 176 | 0.5946 | 0.5527 | 1.5e-05 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ADIPOGENESIS
HALLMARK_ESTROGEN_RESPONSE_EARLY | 200 | 182 | 0.5896 | 0.5225 | 3.1e-05 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_EARLY
HALLMARK_IL2_STAT5_SIGNALING | 199 | 179 | 0.4159 | -0.4902 | 1.0e-04 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL2_STAT5_SIGNALING
HALLMARK_APOPTOSIS | 161 | 157 | 0.4170 | -0.4835 | 3.3e-04 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_APOPTOSIS
HALLMARK_COAGULATION | 138 | 132 | 0.4100 | -0.5250 | 3.6e-04 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_COAGULATION
HALLMARK_BILE_ACID_METABOLISM | 112 | 112 | 0.5856 | 0.4991 | 1.8e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_BILE_ACID_METABOLISM
HALLMARK_HYPOXIA | 200 | 186 | 0.4338 | -0.3842 | 1.9e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_HYPOXIA
HALLMARK_FATTY_ACID_METABOLISM | 158 | 148 | 0.5650 | 0.3772 | 6.4e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_FATTY_ACID_METABOLISM
HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION | 200 | 191 | 0.4449 | -0.3191 | 8.7e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION
HALLMARK_GLYCOLYSIS | 200 | 187 | 0.4489 | -0.2961 | 1.6e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_GLYCOLYSIS
HALLMARK_MITOTIC_SPINDLE | 199 | 187 | 0.5508 | 0.2943 | 1.7e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MITOTIC_SPINDLE
HALLMARK_KRAS_SIGNALING_UP | 200 | 185 | 0.4523 | -0.2764 | 2.5e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_KRAS_SIGNALING_UP
HALLMARK_G2M_CHECKPOINT | 200 | 178 | 0.5475 | 0.2748 | 2.9e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_G2M_CHECKPOINT
HALLMARK_UV_RESPONSE_DN | 144 | 132 | 0.5528 | 0.3059 | 3.6e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_UV_RESPONSE_DN
HALLMARK_UV_RESPONSE_UP | 158 | 148 | 0.4567 | -0.2504 | 6.9e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_UV_RESPONSE_UP
HALLMARK_MTORC1_SIGNALING | 200 | 187 | 0.5376 | 0.2172 | 7.7e-02 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MTORC1_SIGNALING
HALLMARK_PROTEIN_SECRETION | 96 | 93 | 0.5459 | 0.2656 | 1.3e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_PROTEIN_SECRETION
HALLMARK_HEME_METABOLISM | 200 | 180 | 0.5325 | 0.1877 | 1.3e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_HEME_METABOLISM
HALLMARK_SPERMATOGENESIS | 135 | 122 | 0.4610 | -0.2258 | 1.4e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_SPERMATOGENESIS
HALLMARK_DNA_REPAIR | 150 | 134 | 0.4646 | -0.2048 | 1.6e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_DNA_REPAIR
HALLMARK_P53_PATHWAY | 200 | 181 | 0.4716 | -0.1640 | 1.9e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_P53_PATHWAY
HALLMARK_TGF_BETA_SIGNALING | 54 | 52 | 0.4511 | -0.2829 | 2.2e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_TGF_BETA_SIGNALING
HALLMARK_REACTIVE_OXYGEN_SPECIES_PATHWAY | 49 | 44 | 0.4501 | -0.2888 | 2.5e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_REACTIVE_OXYGEN_SPECIES_PATHWAY
HALLMARK_APICAL_JUNCTION | 200 | 185 | 0.4760 | -0.1387 | 2.6e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_APICAL_JUNCTION
HALLMARK_NOTCH_SIGNALING | 32 | 30 | 0.5572 | 0.3316 | 2.8e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_NOTCH_SIGNALING
HALLMARK_UNFOLDED_PROTEIN_RESPONSE | 113 | 101 | 0.5285 | 0.1647 | 3.2e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_UNFOLDED_PROTEIN_RESPONSE
HALLMARK_PANCREAS_BETA_CELLS | 40 | 40 | 0.4560 | -0.2544 | 3.4e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_PANCREAS_BETA_CELLS
HALLMARK_KRAS_SIGNALING_DN | 200 | 181 | 0.4795 | -0.1181 | 3.4e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_KRAS_SIGNALING_DN
HALLMARK_MYC_TARGETS_V1 | 200 | 177 | 0.5202 | 0.1165 | 3.5e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MYC_TARGETS_V1
HALLMARK_MYOGENESIS | 200 | 194 | 0.4830 | -0.0984 | 4.1e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MYOGENESIS
HALLMARK_APICAL_SURFACE | 44 | 41 | 0.4641 | -0.2073 | 4.3e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_APICAL_SURFACE
HALLMARK_HEDGEHOG_SIGNALING | 36 | 35 | 0.4661 | -0.1958 | 4.9e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_HEDGEHOG_SIGNALING
HALLMARK_MYC_TARGETS_V2 | 58 | 49 | 0.4716 | -0.1639 | 4.9e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_MYC_TARGETS_V2
HALLMARK_WNT_BETA_CATENIN_SIGNALING | 42 | 41 | 0.5308 | 0.1782 | 4.9e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_WNT_BETA_CATENIN_SIGNALING
HALLMARK_ANGIOGENESIS | 36 | 36 | 0.5321 | 0.1856 | 5.0e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ANGIOGENESIS
HALLMARK_PEROXISOME | 104 | 100 | 0.5181 | 0.1047 | 5.3e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_PEROXISOME
HALLMARK_E2F_TARGETS | 200 | 171 | 0.5113 | 0.0651 | 6.1e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_E2F_TARGETS
HALLMARK_ANDROGEN_RESPONSE | 101 | 91 | 0.5133 | 0.0765 | 6.6e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ANDROGEN_RESPONSE
HALLMARK_XENOBIOTIC_METABOLISM | 200 | 189 | 0.4930 | -0.0405 | 7.4e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_XENOBIOTIC_METABOLISM
HALLMARK_ESTROGEN_RESPONSE_LATE | 200 | 191 | 0.5057 | 0.0326 | 7.9e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_LATE
HALLMARK_PI3K_AKT_MTOR_SIGNALING | 105 | 99 | 0.5016 | 0.0090 | 9.6e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_PI3K_AKT_MTOR_SIGNALING
HALLMARK_CHOLESTEROL_HOMEOSTASIS | 74 | 70 | 0.5008 | 0.0049 | 9.8e-01 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_CHOLESTEROL_HOMEOSTASIS

The value of the summary method is invisible, but it is a data frame.

    tmp

    ##                                    size actualSize    NES logit2NES p.value
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE  200        186 0.2458   -1.6175 6.8e-33
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE   97         87 0.1688   -2.3000 1.3e-26
    ## HALLMARK_ALLOGRAFT_REJECTION        200        189 0.2816   -1.3512 4.4e-25
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION  200        177 0.6907    1.1591 2.2e-18
    ## HALLMARK_INFLAMMATORY_RESPONSE      200        192 0.3517   -0.8825 1.4e-12
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB    200        185 0.3549   -0.8624 1.0e-11
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     87         83 0.3064   -1.1789 1.1e-09
    ## HALLMARK_COMPLEMENT                 200        190 0.3869   -0.6643 7.8e-08
    ## HALLMARK_ADIPOGENESIS               200        176 0.5946    0.5527 1.5e-05
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY    200        182 0.5896    0.5225 3.1e-05
    ##                                                                                                                        link
    ## HALLMARK_INTERFERON_GAMMA_RESPONSE https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_GAMMA_RESPONSE
    ## HALLMARK_INTERFERON_ALPHA_RESPONSE https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_ALPHA_RESPONSE
    ## HALLMARK_ALLOGRAFT_REJECTION             https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ALLOGRAFT_REJECTION
    ## HALLMARK_OXIDATIVE_PHOSPHORYLATION https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_OXIDATIVE_PHOSPHORYLATION
    ## HALLMARK_INFLAMMATORY_RESPONSE         https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INFLAMMATORY_RESPONSE
    ## HALLMARK_TNFA_SIGNALING_VIA_NFKB     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_TNFA_SIGNALING_VIA_NFKB
    ## HALLMARK_IL6_JAK_STAT3_SIGNALING     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL6_JAK_STAT3_SIGNALING
    ## HALLMARK_COMPLEMENT                               https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_COMPLEMENT
    ## HALLMARK_ADIPOGENESIS                           https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ADIPOGENESIS
    ## HALLMARK_ESTROGEN_RESPONSE_EARLY     https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_EARLY

## Trimming the table fo results

Three functions allow to remove rows from the results table as need. The output of these function can be formatted with the summary method.

The first function removes the non significant gene-sets. By default, a 5% level of significance is applied to BH.values (Benijamini and Hockberg adjustment of the p.values)

    summary(cut_by_significance(ans), as.formattable = TRUE)

| size | actualSize | NES | logit2NES | p.value | BH.value | B.value | relevance
--- | --- | --- | --- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 200 | 177 | 0.6907 | 1.1591 | 2.2e-18 | 2.8e-17 | 1.1e-16 | 59.5
HALLMARK_ESTROGEN_RESPONSE_EARLY | 200 | 182 | 0.5896 | 0.5225 | 3.1e-05 | 1.6e-04 | 1.6e-03 | 59.0
HALLMARK_ADIPOGENESIS | 200 | 176 | 0.5946 | 0.5527 | 1.5e-05 | 8.4e-05 | 7.6e-04 | 56.0
HALLMARK_MITOTIC_SPINDLE | 199 | 187 | 0.5508 | 0.2943 | 1.7e-02 | 4.4e-02 | 8.3e-01 | 52.5
HALLMARK_BILE_ACID_METABOLISM | 112 | 112 | 0.5856 | 0.4991 | 1.8e-03 | 6.2e-03 | 8.8e-02 | 48.0
HALLMARK_FATTY_ACID_METABOLISM | 158 | 148 | 0.5650 | 0.3772 | 6.4e-03 | 2.0e-02 | 3.2e-01 | 48.0
HALLMARK_COAGULATION | 138 | 132 | 0.4100 | -0.5250 | 3.6e-04 | 1.4e-03 | 1.8e-02 | -50.0
HALLMARK_APOPTOSIS | 161 | 157 | 0.4170 | -0.4835 | 3.3e-04 | 1.4e-03 | 1.7e-02 | -52.0
HALLMARK_GLYCOLYSIS | 200 | 187 | 0.4489 | -0.2961 | 1.6e-02 | 4.4e-02 | 8.0e-01 | -54.0
HALLMARK_IL2_STAT5_SIGNALING | 199 | 179 | 0.4159 | -0.4902 | 1.0e-04 | 4.8e-04 | 5.2e-03 | -55.0
HALLMARK_IL6_JAK_STAT3_SIGNALING | 87 | 83 | 0.3064 | -1.1789 | 1.1e-09 | 7.7e-09 | 5.4e-08 | -55.0
HALLMARK_HYPOXIA | 200 | 186 | 0.4338 | -0.3842 | 1.9e-03 | 6.2e-03 | 9.3e-02 | -56.5
HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION | 200 | 191 | 0.4449 | -0.3191 | 8.7e-03 | 2.6e-02 | 4.4e-01 | -60.0
HALLMARK_INTERFERON_ALPHA_RESPONSE | 97 | 87 | 0.1688 | -2.3000 | 1.3e-26 | 3.3e-25 | 6.6e-25 | -63.0
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 200 | 185 | 0.3549 | -0.8624 | 1.0e-11 | 8.5e-11 | 5.1e-10 | -65.0
HALLMARK_COMPLEMENT | 200 | 190 | 0.3869 | -0.6643 | 7.8e-08 | 4.9e-07 | 3.9e-06 | -69.0
HALLMARK_INTERFERON_GAMMA_RESPONSE | 200 | 186 | 0.2458 | -1.6175 | 6.8e-33 | 3.4e-31 | 3.4e-31 | -74.5
HALLMARK_INFLAMMATORY_RESPONSE | 200 | 192 | 0.3517 | -0.8825 | 1.4e-12 | 1.4e-11 | 7.2e-11 | -76.0
HALLMARK_ALLOGRAFT_REJECTION | 200 | 189 | 0.2816 | -1.3512 | 4.4e-25 | 7.3e-24 | 2.2e-23 | -76.5

As a toy example, …

    summary(cut_by_significance(ans, level_of_significance = 0.01, where = "bonferroni"),
            cols_to_remove = c("BH.value", "NES", "size"),
            order_by = "logit2NES",
            as.formattable = TRUE)

| actualSize | logit2NES | p.value | B.value | link
--- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 177 | 1.1591 | 2.2e-18 | 1.1e-16 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_OXIDATIVE_PHOSPHORYLATION
HALLMARK_ADIPOGENESIS | 176 | 0.5527 | 1.5e-05 | 7.6e-04 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ADIPOGENESIS
HALLMARK_ESTROGEN_RESPONSE_EARLY | 182 | 0.5225 | 3.1e-05 | 1.6e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ESTROGEN_RESPONSE_EARLY
HALLMARK_IL2_STAT5_SIGNALING | 179 | -0.4902 | 1.0e-04 | 5.2e-03 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL2_STAT5_SIGNALING
HALLMARK_COMPLEMENT | 190 | -0.6643 | 7.8e-08 | 3.9e-06 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_COMPLEMENT
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 185 | -0.8624 | 1.0e-11 | 5.1e-10 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_TNFA_SIGNALING_VIA_NFKB
HALLMARK_INFLAMMATORY_RESPONSE | 192 | -0.8825 | 1.4e-12 | 7.2e-11 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INFLAMMATORY_RESPONSE
HALLMARK_IL6_JAK_STAT3_SIGNALING | 83 | -1.1789 | 1.1e-09 | 5.4e-08 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_IL6_JAK_STAT3_SIGNALING
HALLMARK_ALLOGRAFT_REJECTION | 189 | -1.3512 | 4.4e-25 | 2.2e-23 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_ALLOGRAFT_REJECTION
HALLMARK_INTERFERON_GAMMA_RESPONSE | 186 | -1.6175 | 6.8e-33 | 3.4e-31 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_GAMMA_RESPONSE
HALLMARK_INTERFERON_ALPHA_RESPONSE | 87 | -2.3000 | 1.3e-26 | 6.6e-25 | https://www.gsea-msigdb.org/gsea/msigdb/human/geneset/HALLMARK_INTERFERON_ALPHA_RESPONSE

The functions cut_by_NES and cut_by_logit2NES remove the rows having a NES/logit2NES below a given threshold. They are equivalent, in fact

\[logit2NES = \log_2 \frac{NES}{1-NES},\] and back \[NES = \frac{2^{logit2NES}}{1+2^{logit2NES}}.\]

The advantage of representing the Normalized Enrichment Score (\(NES\)) as \(logit2NES\) is that this last is a signed value: positive means association with the genes of the treatment group, while a negative value signals the association with the control samples. The default thresholds are set to 0.6 and 0.58 for \(NES\) and \(logit2NES\). These values say that the probability of association of the gene-set with the treatment group is 1.5 higher than the case of association with the control group.

Trimming the table of results according to the \(NES\)/\(logit2NES\) means giving much more attention to the descriptive interpretation of the NES as a measure of strongness of association. Given a gene-set, the \(NES\) is the percentile rank associated with the gene-set, seen as a single value (the average of the ranks), in the universe of the genes outside the gene-set.

    tmp <- cut_by_significance(ans)
    summary(cut_by_logit2NES(tmp), as.formattable = TRUE, order_by = "NES")

| size | actualSize | NES | logit2NES | p.value | BH.value | B.value
--- | --- | --- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 200 | 177 | 0.6907 | 1.1591 | 2.2e-18 | 2.8e-17 | 1.1e-16
HALLMARK_COMPLEMENT | 200 | 190 | 0.3869 | -0.6643 | 7.8e-08 | 4.9e-07 | 3.9e-06
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 200 | 185 | 0.3549 | -0.8624 | 1.0e-11 | 8.5e-11 | 5.1e-10
HALLMARK_INFLAMMATORY_RESPONSE | 200 | 192 | 0.3517 | -0.8825 | 1.4e-12 | 1.4e-11 | 7.2e-11
HALLMARK_IL6_JAK_STAT3_SIGNALING | 87 | 83 | 0.3064 | -1.1789 | 1.1e-09 | 7.7e-09 | 5.4e-08
HALLMARK_ALLOGRAFT_REJECTION | 200 | 189 | 0.2816 | -1.3512 | 4.4e-25 | 7.3e-24 | 2.2e-23
HALLMARK_INTERFERON_GAMMA_RESPONSE | 200 | 186 | 0.2458 | -1.6175 | 6.8e-33 | 3.4e-31 | 3.4e-31
HALLMARK_INTERFERON_ALPHA_RESPONSE | 97 | 87 | 0.1688 | -2.3000 | 1.3e-26 | 3.3e-25 | 6.6e-25

    summary(cut_by_NES(tmp), as.formattable = TRUE, order_by = "NES")

| size | actualSize | NES | logit2NES | p.value | BH.value | B.value
--- | --- | --- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | 200 | 177 | 0.6907 | 1.1591 | 2.2e-18 | 2.8e-17 | 1.1e-16
HALLMARK_COMPLEMENT | 200 | 190 | 0.3869 | -0.6643 | 7.8e-08 | 4.9e-07 | 3.9e-06
HALLMARK_TNFA_SIGNALING_VIA_NFKB | 200 | 185 | 0.3549 | -0.8624 | 1.0e-11 | 8.5e-11 | 5.1e-10
HALLMARK_INFLAMMATORY_RESPONSE | 200 | 192 | 0.3517 | -0.8825 | 1.4e-12 | 1.4e-11 | 7.2e-11
HALLMARK_IL6_JAK_STAT3_SIGNALING | 87 | 83 | 0.3064 | -1.1789 | 1.1e-09 | 7.7e-09 | 5.4e-08
HALLMARK_ALLOGRAFT_REJECTION | 200 | 189 | 0.2816 | -1.3512 | 4.4e-25 | 7.3e-24 | 2.2e-23
HALLMARK_INTERFERON_GAMMA_RESPONSE | 200 | 186 | 0.2458 | -1.6175 | 6.8e-33 | 3.4e-31 | 3.4e-31
HALLMARK_INTERFERON_ALPHA_RESPONSE | 97 | 87 | 0.1688 | -2.3000 | 1.3e-26 | 3.3e-25 | 6.6e-25

## Plotting the analysis

The results can be displayed two-way: a bar plot and a network graph. The corresponding functions provide a graphical rendering of the table in input in both cases. Then, eventually, the table has to be trimmed according to significance or NES.

    plot(ans)

A meaningful display follows.

    plot(cut_by_significance(ans), top = 30)

Here, the maximum number of bars has been restricted to 30.

The horizontal axis (signed-NES) is a linear transformation of the NES: \[signed\mbox-NES = 2\cdot NES - 1\] necessary to a) signal the direction of the association, and b) to bound the bars between -1.0 and 1.0

The network plot needs to specify ‘as.network = TRUE’ and provide the gene-sets collection.

    plot(cut_by_significance(ans), gene_sets = geneSets, as.network = TRUE)

The similarity \(S(A, B)\) between two gene-sets \(A\) and \(B\) comes from the convex combination \[S(A,B)= \epsilon \cdot \delta_1(A, B)+ (1-\epsilon)\cdot \delta_0(A, B),\] with \(0\leq \epsilon \leq 1\), and \(\delta_0\) is the Jaccard similarity, while \(\delta_1\) is the overlap index. \(logit2NES\) controls the color of the balls: red for those with positive values (associated with the treatment), green otherwise. \(actualSize\) controls the dimension of the balls.

# Over-representation (Fisher’s exact) test

Since version 1.2, a new function has been add to implement the overepresentation test (Fisher’s exact text) that is integrated with both the tabular and graphical function of this package.

Getting the gene sets and the gene-profile

    #geneSets <- get_geneSets_from_msigdbr(category = "C5", subcategory = "CC", what = "gene_symbol")

    #fname <- system.file("extdata", package="massiveGST")
    #fname <- file.path(fname, "pre_ranked_list.txt")
    #geneProfile <- get_geneProfile(fname)

To mimic a set of significant genes coming from a differential expression procedure, we get the first 500 genes in the pre-ranked list,

    geneList <- names(head(geneProfile, 500))

and run the enrichment analysis

    ans <- massiveORT(geneList, geneSets)

    ## greater

The function massiveORT essentially is a wrapper to the function fisher.test in charge to 1) arrange the input to feed fisher.test in sequence for each gene set, 2) arrange the output in a data frame compatible with the other function of the package, and 3) compute the universe of genes for the analysis.

By default, the universe of genes necessary to the Fisher’s test is computed as the collection of genes included at lest once in any gene-set. The function allows to consider a different universe. Se help file.

The tabular result comes from

    summary(cut_by_significance(ans), as.formattable = TRUE)

| collection | universe size | geneList size | geneSet size | geneList in geneSet | odds_ratio | log2 odds_ratio | p.value | BH.value | B.value | relevance
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
HALLMARK_OXIDATIVE_PHOSPHORYLATION | /tmp/RtmptH2F6x/Rinstde3cb6705351a/massiveGST/extdata/h.all.v2024.1.Hs.symbols.gmt | 4384 | 154 | 200 | 28 | 5.2390 | 2.3893 | 1.3e-10 | 6.5e-09 | 6.5e-09 | 44
HALLMARK_BILE_ACID_METABOLISM | /tmp/RtmptH2F6x/Rinstde3cb6705351a/massiveGST/extdata/h.all.v2024.1.Hs.symbols.gmt | 4384 | 154 | 112 | 12 | 3.4884 | 1.8026 | 4.9e-04 | 1.2e-02 | 2.4e-02 | 34

The graphical output is from

    plot(cut_by_significance(ans))

and

    plot(ans, gene_sets = geneSets, as.network = TRUE)

# Session info

    sessionInfo()

    ## R version 4.4.3 (2025-02-28)
    ## Platform: x86_64-pc-linux-gnu
    ## Running under: Linux Mint 20.3
    ##
    ## 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=C
    ##  [5] LC_MONETARY=it_IT.UTF-8    LC_MESSAGES=en_US.UTF-8
    ##  [7] LC_PAPER=it_IT.UTF-8       LC_NAME=C
    ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    ## [11] LC_MEASUREMENT=it_IT.UTF-8 LC_IDENTIFICATION=C
    ##
    ## time zone: Europe/Rome
    ## tzcode source: system (glibc)
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] massiveGST_1.2.4  visNetwork_2.1.2  igraph_2.1.4      WriteXLS_6.7.0
    ## [5] formattable_0.2.1
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] digest_0.6.37     R6_2.6.1          fastmap_1.2.0     xfun_0.50
    ##  [5] magrittr_2.0.3    cachem_1.1.0      knitr_1.49        pkgconfig_2.0.3
    ##  [9] htmltools_0.5.8.1 rmarkdown_2.29    lifecycle_1.0.4   cli_3.6.4
    ## [13] sass_0.4.9        jquerylib_0.1.4   compiler_4.4.3    rstudioapi_0.17.1
    ## [17] tools_4.4.3       evaluate_1.0.3    bslib_0.9.0       yaml_2.3.10
    ## [21] htmlwidgets_1.6.4 rlang_1.1.5       jsonlite_1.8.9