calcGseaStat {fgsea} | R Documentation

## Calculates GSEA statistics for a given query gene set

### Description

Takes O(k log k) time, where k is a size of 'selectedSize'.

### Usage

    calcGseaStat(
      stats,
      selectedStats,
      gseaParam = 1,
      returnAllExtremes = FALSE,
      returnLeadingEdge = FALSE,
      scoreType = c("std", "pos", "neg")
    )

### Arguments

`stats` | Named numeric vector with gene-level statistics sorted in decreasing order (order is not checked).
`selectedStats` | Indexes of selected genes in the 'stats' array.
`gseaParam` | GSEA weight parameter (0 is unweighted, suggested value is 1).
`returnAllExtremes` | If TRUE return not only the most extreme point, but all of them. Can be used for enrichment plot
`returnLeadingEdge` | If TRUE return also leading edge genes.
`scoreType` | This parameter defines the GSEA score type. Possible options are ("std", "pos", "neg")

### Value

Value of GSEA statistic if both returnAllExtremes and returnLeadingEdge are FALSE. Otherwise returns list with the folowing elements:

- res – value of GSEA statistic

- tops – vector of top peak values of cumulative enrichment statistic for each gene;

- bottoms – vector of bottom peak values of cumulative enrichment statistic for each gene;

- leadingGene – vector with indexes of leading edge genes that drive the enrichment, see http://software.broadinstitute.org/gsea/doc/GSEAUserGuideTEXT.htm#_Running_a_Leading.

### Examples

    data(exampleRanks)
    data(examplePathways)
    ranks <- sort(exampleRanks, decreasing=TRUE)
    es <- calcGseaStat(ranks, na.omit(match(examplePathways[[1]], names(ranks))))

[Package fgsea version 1.20.0 Index]