Skip to contents

Run preranked GSEA

Usage

run_gsea(
  differential,
  species = "auto",
  collection = "hallmark",
  subcollection = NULL,
  genesets = NULL,
  rank = "stat",
  min_size = 15L,
  max_size = 500L,
  eps = 0,
  seed = 42L
)

Arguments

differential

Differential-expression table or path.

species

auto, human, or mouse.

collection

MSigDB collection alias or raw collection code.

subcollection

Optional MSigDB subcollection.

genesets

Optional named gene-set list or GMT path.

rank

Column used as ranking statistic, default stat.

min_size

Minimum mapped gene-set size.

max_size

Maximum mapped gene-set size.

eps

Passed to fgseaMultilevel.

seed

Random seed for fgseaMultilevel, which estimates p-values by sampling. The same seed gives the same table.

Value

A data frame of GSEA results, sorted by padj and then by decreasing |NES|.

Details

Gene IDs are matched to gene sets by stable Ensembl gene ID. When several rows share a stable ID, the row with the largest absolute ranking statistic is kept.

Unsigned statistics, such as the stat column of an LRT table, are rejected because preranked GSEA needs a direction.

Examples

ids <- sprintf("ENSG%011d", 1:100)
de <- data.frame(ensembl_gene_id = ids, stat = seq(5, -5, length.out = 100))
sets <- list(UP = ids[1:20], DOWN = ids[81:100], MIXED = ids[seq(1, 100, 5)])
run_gsea(de, genesets = sets, min_size = 10, max_size = 50)
#>   pathway         pval         padj    log2err     ES        NES size
#> 1    DOWN 7.519604e-21 1.127941e-20 1.17789326 -1.000 -3.4539323   20
#> 2      UP 7.254206e-21 1.127941e-20 1.17789326  1.000  3.3871867   20
#> 3   MIXED 9.058824e-01 9.058824e-01 0.04929177  0.195  0.6605014   20
#>                                                                                                                                                                                                                                                                                                                       leadingEdge
#> 1 ENSG00000000100;ENSG00000000099;ENSG00000000098;ENSG00000000097;ENSG00000000096;ENSG00000000095;ENSG00000000094;ENSG00000000093;ENSG00000000092;ENSG00000000091;ENSG00000000090;ENSG00000000089;ENSG00000000088;ENSG00000000087;ENSG00000000086;ENSG00000000085;ENSG00000000084;ENSG00000000083;ENSG00000000082;ENSG00000000081
#> 2 ENSG00000000001;ENSG00000000002;ENSG00000000003;ENSG00000000004;ENSG00000000005;ENSG00000000006;ENSG00000000007;ENSG00000000008;ENSG00000000009;ENSG00000000010;ENSG00000000011;ENSG00000000012;ENSG00000000013;ENSG00000000014;ENSG00000000015;ENSG00000000016;ENSG00000000017;ENSG00000000018;ENSG00000000019;ENSG00000000020
#> 3                                                                                                                                                                                                                                                 ENSG00000000001;ENSG00000000006;ENSG00000000011;ENSG00000000016;ENSG00000000021
#>   collection subcollection db_version
#> 1     custom                       NA
#> 2     custom                       NA
#> 3     custom                       NA