Skip to main content
v2026.11,986 entries · CC-BY 4.0

GSVA: Gene Set Variation Analysis in R (Bioconductor)

How to run GSVA (gene set variation analysis) in R: install, gsvaParam and gsva calls, kcdf choice, output and common errors.

Written and maintained by CASRAI Editorial Board

Published

On this page

GSVA (gene set variation analysis) is a Bioconductor package for R that converts a gene-by-sample expression matrix into a gene-set-by-sample matrix of enrichment scores, one score per pathway per sample. The Bioconductor vignette describes the result as an estimate of pathway activity, which you can then feed into differential expression, classification, survival analysis, clustering or correlation analysis at the pathway level. This guide covers the current object-based interface (GSVA 2.6.15 on Bioconductor 3.23, as read on 2026-11-12): install, a complete first run, the kcdf setting that depends on your data type, how to read the output, and the errors that most often stop a first run.

What GSVA is used for in research

GSVA is a non-parametric, unsupervised method. Its authors (Hänzelmann, Castelo and Guinney, BMC Bioinformatics 14:7, 2013) describe it as estimating variation of gene set enrichment across the samples of an expression dataset without using sample class labels, which is what makes it a change of coordinate system, from genes to gene sets. Scoring uses a Kolmogorov-Smirnov-like rank statistic computed sample by sample, and the paper presents it for both microarray and RNA-seq data.

The practical consequence is that every sample gets its own pathway score. That differs from a classical enrichment test, which compares two groups and returns one result per gene set. If you only need a ranked-list test between two conditions, the GSEA guide is the better starting point; if you want to compare several enrichment and activity-inference methods side by side, see the decoupleR guide. GSVA output is also a natural input to integrative work across data layers, as discussed in the multi-omics guide.

Example from the package vignette: molecular signature identification

The vignette replicates the glioblastoma multiforme subtype analysis of Verhaak et al. (2010) using the example dataset gbm_VerhaakEtAl (173 samples) shipped in the GSVAdata package. Four gene-set signatures specific to brain cell types (astrocytes, oligodendrocytes, neurons and cultured astroglial cells, from Cahoy et al. 2008) are scored with GSVA without telling the method which subtype each sample belongs to; the subtype labels are used afterwards only to inspect the result.

Example from the package vignette: microarray versus RNA-seq agreement

Using lymphoblastoid cell line data profiled by both technologies on the same individuals, the vignette computes GSVA scores for 835 gene sets (canonical KEGG, REACTOME and BIOCARTA sets from MSigDB C2 v3.0 plus two sex-specific sets). For the male-specific (MSY) and X-inactivation-escape (XiE) gene sets, microarray and RNA-seq scores correlate at Spearman ρ = 0.80 and ρ = 0.79 respectively, and male and female samples score higher on their own gene set. This is the vignette’s own illustration that pathway-level scores can agree across platforms about as well as gene-level values do.

Install GSVA from the official source

GSVA is distributed through Bioconductor, not CRAN. The package page lists version 2.6.15 in the Bioconductor 3.23 release under the Artistic-2.0 license, requiring R 4.0.0 or later. Install with BiocManager and then load the package:

if (!require("BiocManager", quietly = TRUE))    install.packages("BiocManager")BiocManager::install("GSVA")library(GSVA)

The package is by Robert Castelo (author and maintainer) and Justin Guinney. To cite it, the Bioconductor page gives: Castelo R, Guinney J. GSVA: Gene Set Variation Analysis for Microarray and RNA-Seq Data, R package version 2.6.15, doi:10.18129/B9.bioc.GSVA. If you use one of the other methods in the package (PLAGE, z-score, ssGSEA), the vignette asks you to cite the corresponding original article as well.

Step-by-step: compute GSVA scores

The current interface is two calls: build a parameter object, then pass it to gsva(). The vignette’s quick start uses simulated Gaussian data so you can confirm your installation before using real data.

  1. Prepare the expression data. Use a normalized expression matrix with genes in rows and samples in columns. The vignette also accepts an ExpressionSet (Biobase) or a SummarizedExperiment.
  2. Prepare the gene sets. Use either a named list in which each element is a vector of gene identifiers, or a GeneSetCollection from the GSEABase package. For MSigDB or other GMT files, readGMT() accepts a file name or URL.
  3. Make the identifiers match. With a plain matrix and a plain list, you are responsible for using the same identifier type (for example, both gene symbols or both Entrez IDs). With the specialized containers and the right metadata, gsva() maps identifiers itself.
  4. Build the parameter object. gsvaPar <- gsvaParam(X, gs), where X is the matrix and gs the gene sets. Add minSize and maxSize if you want to restrict set sizes; the vignette’s real-data example uses minSize=5, maxSize=500.
  5. Run it. gsva.es <- gsva(gsvaPar, verbose=FALSE). Other arguments to gsva() are verbose for progress reporting and BPPPARAM for parallel computation through BiocParallel.
  6. Check the result. dim(gsva.es) returns the number of gene sets and samples. In the vignette’s toy example, 10,000 genes, 30 samples and 100 gene sets give 100 30.

The vignette’s complete toy example is:

p <- 10000n <- 30X <- matrix(rnorm(p*n), nrow=p,            dimnames=list(paste0("g", 1:p), paste0("s", 1:n)))gs <- as.list(sample(10:100, size=100, replace=TRUE))gs <- lapply(gs, function(n, p)                   paste0("g", sample(1:p, size=n, replace=FALSE)), p)names(gs) <- paste0("gs", 1:length(gs))gsvaPar <- gsvaParam(X, gs)gsva.es <- gsva(gsvaPar, verbose=FALSE)dim(gsva.es)

Reading gene sets from a GMT file

A GMT file stores one gene set per tab-separated line: a unique identifier, a description, then one or more gene identifiers. Because lines have different lengths, it is not a rectangular table and cannot be read with read.table() or read.csv(). The vignette reads an MSigDB collection directly from its URL:

library(GSEABase)library(GSVA)URL <- "https://data.broadinstitute.org/gsea-msigdb/msigdb/release/2024.1.Hs/c7.immunesigdb.v2024.1.Hs.symbols.gmt"c7.genesets <- readGMT(URL)

readGMT() returns a GeneSetCollection by default (use valueType="list" for a plain list) and tries to detect the identifier type. You can set it yourself with the geneIdType argument or with gsvaAnnotation(c7.genesets) <- SymbolIdentifier("org.Hs.eg.db").

Match the kernel setting to your data type

The first step of the GSVA algorithm puts genes with different dynamic ranges on a common scale by estimating the expression distribution across samples. The kcdf argument of gsvaParam() controls how that estimate is made. The vignette lists these values:

kcdf value What the vignette says it is suitable for
"auto" (default) GSVA decides the estimation method automatically.
"Gaussian" Continuous expression data, such as microarray fluorescent units on a logarithmic scale and RNA-seq log-CPM, log-RPKM or log-TPM values.
"Poisson" Integer counts, such as those derived from RNA-seq alignments.
"none" Direct estimation of the empirical CDF without a kernel function. Under "auto" this is used from a sample size set by kcdfNoneMinSampleSize (default 200).

For RNA-seq integer counts, the vignette states that setting kcdf="Poisson" is the only change needed. If your RNA-seq values are already continuous (log-CPM, log-RPKM, log-TPM), leave the Gaussian default in place. Other tunable gsvaParam() arguments, with the vignette’s defaults, are tau (1, the exponent that weights the tail of the random walk), maxDiff (TRUE), absRanking (FALSE, used only when maxDiff=TRUE) and sparse (TRUE, relevant only for sparse-matrix input). The vignette states that the defaults suit most analyses of normalized continuous expression values.

What maxDiff changes

With maxDiff=TRUE, the score is the magnitude difference between the largest positive and largest negative random-walk deviations, which gives larger scores to gene sets whose genes move concordantly in one direction. With maxDiff=FALSE, the score is the maximum distance of the walk from zero; the vignette notes this produces a bimodal score distribution and can give large scores to sets that are not concordantly activated.

Output and how to read it

gsva() returns a matrix with one row per gene set and one column per sample. Each cell is the enrichment score of that gene set in that sample. In the toy example the first entries range from about −0.30 to 0.25. The vignette does not state a fixed numeric range for GSVA scores, so avoid thresholds such as “above 0.5 means active”; compare scores across samples for the same gene set rather than reading a single value in isolation. Per the original paper, the scores describe sample-wise variation of gene set enrichment across the dataset.

Because the result is an ordinary matrix, the vignette’s suggested next step is to treat gene sets as the new features: test them for differential activity between groups, cluster samples on them, or correlate them with other molecular layers such as microRNA expression, copy-number or SNP data. If your samples show batch structure, address it before scoring; the sva package guide covers surrogate variable analysis. For looking up individual genes inside a leading pathway, the NCBI Gene guide is a convenient companion.

Scores from other methods in the package

The scale depends on the method. The vignette notes that the ssGSEA implementation divides pathway scores by the range of calculated values by default (switchable with ssgsea.norm), and that the sign of PLAGE singular vectors is arbitrary because of how SVD is calculated. Do not compare scores from different methods on one axis.

Troubleshooting

gsva() stops with an error about no genes or no gene sets

Before computing, gsva() applies three filters in order: it discards genes with constant expression, discards gene-set members that do not map to a gene in the expression matrix, and discards gene sets outside the minimum and maximum size (defaults: one and no limit). If either genes or gene sets are exhausted, it raises an error. The vignette names the most common cause: the identifiers in the matrix and the gene sets are from different nomenclatures (for example Ensembl versus Entrez, or symbols versus IDs) and could not be mapped, because plain matrix or list inputs were used or the container metadata needed for mapping is missing. Convert one side so both use the same identifier type, or supply an ExpressionSet/SummarizedExperiment and a GeneSetCollection with the annotation metadata set.

GMT file reports duplicated gene set names

The GMT specification does not allow duplicate set names. GSEABase’s getGmt() fails with “each setName must be distinct”, and qusage’s read.gmt() silently keeps duplicates in a list. GSVA’s readGMT() warns and keeps only the first occurrence by default; the deduplUse argument offers other policies (see ?readGMT).

Counts give odd results with the default settings

If you pass raw integer RNA-seq counts, set kcdf="Poisson" as above. If you pass log-scale values, keep the Gaussian default.

Old code with a different call fails

The current vignette documents the parameter-object interface (gsvaParam(), plageParam(), zscoreParam(), ssgseaParam(), then gsva()). Tutorials written against earlier releases may call gsva() directly with a method name; rewrite those calls to the pattern in the step-by-step section and check the argument names in the help page for the constructor you use.

Other methods and alternatives

All four single-sample methods in the vignette are in the same package, so you can switch methods by changing only the parameter constructor. The data table below compares them; for approaches outside GSVA, use the on-site guides linked in the notes.

Option Where to get it Note
ssGSEA ssgseaParam() in GSVA Non-parametric, per-sample score from the difference in empirical CDFs of expression ranks inside and outside the set (Barbie et al. 2009).
PLAGE plageParam() in GSVA Standardizes profiles, then runs an SVD per gene set and returns the first right-singular vector coefficients (Tomfohr et al. 2005).
Combined z-score zscoreParam() in GSVA Standardizes profiles, then sums the standardized values of a set and divides by √k (Lee et al. 2008).
Classical GSEA See the GSEA guide Group-comparison enrichment test rather than a per-sample score.
Multi-method framework See the decoupleR guide Places GSVA alongside other enrichment and activity methods.

Frequently asked questions

What does GSVA stand for and what does it output?

GSVA stands for gene set variation analysis. It outputs a gene-set-by-sample matrix of enrichment scores computed from a gene-by-sample expression matrix.

Is GSVA a Python or an R tool?

The implementation documented here is the R package on Bioconductor. This guide does not cover other language ports.

Which input formats does GSVA accept?

Expression data may be a matrix, an ExpressionSet or a SummarizedExperiment; gene sets may be a named list or a GeneSetCollection.

Does GSVA need sample groups?

No. The method is unsupervised and works independently of class labels; groups come in only when you analyse the resulting scores.

Can I run GSVA on RNA-seq counts?

Yes. Use gsvaParam(..., kcdf="Poisson") for integer counts, or keep the Gaussian default for log-CPM, log-RPKM or log-TPM values.

Can I run it in parallel?

The gsva() function takes a BPPPARAM argument that uses the BiocParallel package.

Sources

Data: Single-sample gene set scoring methods in the Bioconductor GSVA package

Compares the four single-sample pathway-scoring methods implemented in the GSVA R package (gsva, ssGSEA, PLAGE, z-score): parameter constructor, original reference and how each score is built, compiled from the package vignette and package page.

Period covered: 2026.

Single-sample gene set scoring methods in the Bioconductor GSVA package
MethodParameter constructorOriginal referenceHow the score is builtScale or sign note
gsva (package default)gsvaParam()Hänzelmann, Castelo and Guinney 2013Non-parametric; empirical CDFs of expression ranks inside and outside the set after a kernel-based expression statistic puts genes on a common scaleDefault enrichment score is the magnitude difference between the largest positive and negative random-walk deviations (maxDiff=TRUE); no fixed numeric range stated
ssGSEAssgseaParam()Barbie et al. 2009Non-parametric; normalized difference in empirical CDFs of expression ranks inside and outside the setScores divided by the range of calculated values by default; switch off with ssgsea.norm
PLAGEplageParam()Tomfohr, Lu and Kepler 2005Standardizes profiles over samples, then SVD per gene set; coefficients of the first right-singular vectorSign of singular vectors is arbitrary
z-scorezscoreParam()Lee et al. 2008Standardizes profiles over samples; combined Z = sum of standardized values divided by square root of set size kNot stated

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · full access

Ask about GSVA: Gene Set Variation Analysis in R (Bioconductor)

Full access: large monthly usage, up to 10 source passages behind each answer, and MCP and API access for Claude Code, Codex and other CLIs. Cancel any time.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →