Learn R Programming

enrichit (version 0.1.2)

gsea: Gene Set Enrichment Analysis (GSEA)

Description

Perform Gene Set Enrichment Analysis (GSEA) using a ranked gene list.

Usage

gsea(
  geneList,
  gene_sets,
  minGSSize = 10,
  maxGSSize = 500,
  nPerm = 1000,
  exponent = 1,
  method = "multilevel",
  adaptive = FALSE,
  minPerm = 101,
  maxPerm = 1e+05,
  pvalThreshold = 0.1,
  eps = 1e-10,
  sampleSize = 101,
  seed = FALSE,
  nPermSimple = 1000,
  scoreType = "std",
  verbose = TRUE
)

Value

A data.frame with columns:

  • ID: Gene set name

  • enrichmentScore: Enrichment Score

  • NES: Normalized Enrichment Score

  • pvalue: Empirical p-value from permutation test

  • setSize: Size of the gene set (number of genes found in geneList)

  • nPerm: (adaptive mode only) Actual number of permutations used

  • rank: Rank at which the maximum enrichment score is attained

  • leading_edge: Leading edge statistics (tags, list, signal)

  • core_enrichment: Genes in the leading edge, separated by '/'

Arguments

geneList

A named numeric vector of gene statistics (e.g., log fold change), ranked in descending order.

gene_sets

A named list of gene sets. Each element is a character vector of genes.

minGSSize

minimal size of each geneSet for analyzing

maxGSSize

maximal size of each geneSet for analyzing

nPerm

Number of permutations for p-value calculation (default: 1000).

exponent

Weighting exponent for enrichment score (default: 1.0).

method

Permutation method.

adaptive

Logical. Use adaptive permutation.

minPerm

Minimum permutations for adaptive mode.

maxPerm

Maximum permutations for adaptive mode.

pvalThreshold

P-value threshold for early stopping.

eps

Epsilon for multilevel methods (default: 1e-10). Sets the smallest p-value that can be estimated.

sampleSize

Sample size for multilevel methods (default: 101).

seed

Random seed for reproducibility (default: FALSE). If FALSE, a random seed is generated.

nPermSimple

Number of permutations for the simple method (default: 1000).

scoreType

Type of enrichment score calculation: "std", "pos", "neg" (default: "std").

verbose

Logical. Print progress messages.

Examples

Run this code
# Example data
stats <- rnorm(1000)
names(stats) <- paste0("Gene", 1:1000)
stats <- sort(stats, decreasing = TRUE)

gs1 <- paste0("Gene", 1:50)
gs2 <- paste0("Gene", 500:550)
gene_sets <- list(Pathway1 = gs1, Pathway2 = gs2)

# Use default fixed permutation method
result <- gsea(geneList=stats, gene_sets=gene_sets, nPerm=100)

# Use adaptive permutation for more accurate p-values
# \donttest{
result_adaptive <- gsea(geneList=stats, gene_sets=gene_sets, adaptive=TRUE)
# }

Run the code above in your browser using DataLab