| gsea | R Documentation |
Perform Gene Set Enrichment Analysis (GSEA) using a ranked gene list.
gsea(
geneList,
gene_sets,
weight = NULL,
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
)
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. |
weight |
A named numeric vector of weights for genes. The names should match the names of geneList. If provided, the geneList will be multiplied by the weight and resorted before GSEA (default: NULL). |
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). Set to a number to make
the result reproducible; set to TRUE to use a fixed default seed. If FALSE (default),
a seed is drawn from R's random number generator on each run, so results may vary
between runs. Note that the C++ engine uses its own RNG seeded with this value:
passing an explicit numeric seed (or calling |
nPermSimple |
Number of permutations for the simple method (default: 1000). |
scoreType |
Type of enrichment score calculation: "std", "pos", "neg" (default: "std").
Only honoured by |
verbose |
Logical. Print progress messages. |
A data.frame with columns:
ID: Gene set name
enrichmentScore: Enrichment Score
NES: Normalized Enrichment Score
pvalue: Empirical p-value from the permutation test. With the default
two-sided scoreType = "std", the denominator counts only
permutations on the same side of zero as the observed ES (fgsea
convention). The "pos"/"neg" score types are supported by
the multilevel engine; fixed and adaptive permutation paths currently use
the two-sided ES calculation. For fixed or adaptive permutation runs,
the smallest estimable p-value is determined by the number of same-side
null permutations, not by the total number of permutations.
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 '/'
# 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
result_adaptive <- gsea(geneList=stats, gene_sets=gene_sets, adaptive=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.