The tests of Gene-set tests and Over-representation and
GSEA ask one question of one contrast. A pathway score
instead turns the expression of a set’s genes in each sample into one number, so that
pathways can be compared across samples, drawn as a heatmap, correlated with other
measurements and tested with any design Hänzelmann et al., 2013. By default gsva
computes the scores by gene set variation analysis, and ssgsea,
combined_z_scores and plage compute the other three methods of the GSVA
package. Pathway and regulator activity scores
published data with GSVA and tests the scores.
The values scored¶
Each method scores a samples x genes matrix of expression values, or a cell type of a
cube. A cell type gives its samples with enough cells (min_cells, 10 by default, as for
limma_voom; Samples with few cells or counts) and its
genes that pass edgeR’s filter (Filtering by expression), as
log-CPM values (log-CPM) or, with values="counts", as counts: the values
that GSVA’s guide scores. NaN marks a missing value.
Sets with fewer than min_size or more than max_size genes among those scored are left
out. The result, a PathwayScores, holds the scores of the samples by sets, with the
table of the samples and the genes that each set used, and PathwayScores.table
lists the scores one per row; plot_pathway_scores draws them as a heatmap, with
the samples grouped by a variable.
GSVA¶
GSVA first puts each gene on a common scale. A kernel estimate of the gene’s distribution over the samples gives each value the probability that the gene’s value is no higher,
for gene in sample , with a bandwidth of one quarter of gene ’s standard deviation, for continuous values such as log-CPM. For counts the kernel is the Poisson probability with mean , and without a kernel is the share of the samples whose value is at most . Each sample ranks its genes by and gives the gene of rank the weight , so that the genes at both ends of the ranking weigh most. A walk down the ranking rises at the genes of a set and falls at the others, as in gene set enrichment analysis, and the score is the walk’s largest deviation above zero minus its largest deviation below: high for a set whose genes are higher than usual in the sample, low for one whose genes are lower, and between -1 and 1.
ssGSEA¶
Single-sample GSEA ranks the genes of each sample by their values and sums the same walk over all genes rather than taking its extreme, with the genes of the set weighted by their ranks to the power Barbie et al., 2009. By default the scores are then scaled by their range over every set and sample, as Barbie et al. (2009) scaled them, so that a score depends on the other sets and samples scored with it.
Combined z-scores¶
Each gene is standardized across the samples, and a set scores the sum of its genes’ z-scores over : a standard normal score if its genes are independent and standard normal Lee et al., 2008.
PLAGE¶
PLAGE standardizes the genes of a set and scores the samples by the first right singular vector of their genes x samples matrix: the samples’ coordinates on the direction along which the set’s genes vary most together Tomfohr et al., 2005. Across the samples, a set’s scores have mean zero and length one. The vector could as well point the other way; CytePool points it where the scores rise with the set’s mean standardized expression.
How the scores differ¶
ssGSEA ranks the values themselves, so that a set of highly expressed genes scores high in every sample. GSVA first sets each gene against its own distribution across the samples, so that a set scores high where its genes are higher than usual, compared with the other genes of the sample. Combined z-scores and PLAGE also set each gene against itself across the samples, but do not compare it with other genes: combined z-scores add the genes of a set alike, and PLAGE follows the pattern along which they vary most together. GSVA and ssGSEA thus ask how a set ranks within a sample, and combined z-scores and PLAGE how a sample stands among the others.
Testing scores with a design¶
The scores of a set differ between conditions as the expression of a gene does, so they
are tested as genes are, with limma’s linear models, contrasts, moderated t-tests and
adjusted p-values, as GSVA’s guide does Hänzelmann et al., 2013Smyth, 2004. limma
takes these steps in one call, with the Design built for the cube. It fits the
samples that have scores, so a sample that the scores leave out, such as one with too few
cells, is not fitted either, and a design that the remaining samples no longer determine
is fitted as limma_voom fits a cell type (Designs that cannot answer the
question). GSVA’s guide notes that the scores of larger sets vary
less, and lets the prior variance of the moderation follow the set sizes:
limma(scores, design, trend=scores.n_genes) does the same. The activities of the next
chapter are tested alike.
Defaults and choices¶
The method.
gsvaby default, which compares a set’s genes with the other genes of a sample after setting each gene against its own distribution;ssgseacompares the values themselves;combined_z_scoresandplagefollow each set across the samples without comparing it with other genes (How the scores differ).The kernel.
kernel="auto", GSVA’s default, chooses the Poisson kernel when the values are stored as integers, such as counts, the Gaussian kernel for other values, and no kernel from 200 samples on (min_samples_without_kernel);"gaussian","poisson"and"none"choose one.The score of GSVA.
score_type="difference", GSVA’s default, subtracts the walk’s largest deviation below zero from its largest above, so that a set scores high where its genes are high and low where they are low;"kuiper"adds the two, to score a set whose genes sit at both ends of the ranking, and"max_deviation"takes the larger of them, with its sign.The weights of the ranks.
exponentis GSVA’s tau, 1, and ssGSEA’s alpha, 1/4.ssGSEA’s normalization.
normalize=Truescales the scores by their range;normalize=Falsekeeps each score independent of the others.The values of a cube. log-CPM values by default, and
values="counts"for GSVA’s Poisson kernel;min_cellsandexpression_filterchoose the samples and genes (The values scored).Set sizes. Every size by default, as in GSVA;
min_sizeandmax_sizelimit them.Tests.
limmawith the cube’s design,trend=scores.n_genesto let the prior follow the set sizes, androbust=Truefor a robust prior.
Limits and differences¶
The cost of GSVA. GSVA estimates each gene’s distribution from every pair of its samples, so its time grows with the square of the number of samples, and the Poisson kernel costs more than the Gaussian (Timings).
PLAGE’s sign. CytePool’s scores rise with the set’s mean standardized expression. GSVA keeps the sign that its singular value decomposition happens to return, which varies with the linear algebra library, so the two agree up to sign. For a set of one gene, GSVA scores 1 in every sample and CytePool the gene’s standardized values, over their length.
Missing values.
gsvaworks on the observed values, as GSVA does withuse = "na.rm", but a sample’s walk falls only at its observed genes outside the set and so ends at zero, where GSVA’s also counts the missing genes and ends above zero. GSVA’s default,use = "everything", gives scores without meaning, and GSVA stops on a sample without any value, which here gets no scores. ssGSEA and combined z-scores treat missing values as GSVA does, and PLAGE refuses them, as GSVA does; each function’s documentation says how.Inputs on which GSVA stops. In ssGSEA, a set of every gene gets no score, and the other scores are normalized as usual. Values stored as integers, from 200 samples on, are scored without a kernel by
kernel="auto", as GSVA’s documentation says; GSVA 2.0.0 stops on both. The Poisson kernel refuses values that are not counts, where GSVA stops on negative values and scores fractional ones.Ranks decided by the last bit. Genes whose kernel estimates are equal in exact arithmetic, such as genes with the same low counts in different samples, are ordered by the last bit of the normal and Poisson probabilities, which CytePool computes accurately but not always to the same bit as R. Such genes can take each other’s ranks, and the scores of their sets then differ slightly from GSVA’s.
Exact standard errors. CytePool’s
limmacomputes the standard errors of contrasts exactly; they differ from those of limma’scontrasts.fitonly with missing scores, or weights that differ between scores (Contrasts).
Checks and further reading¶
The four methods and their heatmap are compared with GSVA 2.0.0, run as a separate
program on the same data: exact (1e-10), PLAGE up to sign
(Validation). limma has no section of its own:
tests/test_score_tests.py checks that its results are those of
fit_linear_model, contrasts_fit and moderated_statistics, which are
compared with limma 3.62.1 (Validation and
Validation).
Further reading:
Hänzelmann et al. (2013) introduced GSVA, which scores gene sets in every sample of microarray and RNA-seq data.
Barbie et al. (2009) introduced single-sample GSEA, in a screen of the genes that cancers with KRAS mutations depend on.
Lee et al. (2008) scored a pathway’s activity in each sample by the combined z-scores of its genes, and chose for each pathway the genes that best tell the conditions apart.
Tomfohr et al. (2005) scored pathways in each sample by the singular value decomposition of their genes’ expression.
Activities from networks, the next chapter, scores regulators and pathways rather than gene sets.
- Hänzelmann, S., Castelo, R., & Guinney, J. (2013). GSVA: gene set variation analysis for microarray and RNA-Seq data. BMC Bioinformatics, 14(1), 7. 10.1186/1471-2105-14-7
- Barbie, D. A., Tamayo, P., Boehm, J. S., Kim, S. Y., Moody, S. E., Dunn, I. F., Schinzel, A. C., Sandy, P., Meylan, E., Scholl, C., Fröhling, S., Chan, E. M., Sos, M. L., Michel, K., Mermel, C., Silver, S. J., Weir, B. A., Reiling, J. H., Sheng, Q., … Hahn, W. C. (2009). Systematic RNA interference reveals that oncogenic KRAS-driven cancers require TBK1. Nature, 462(7269), 108–112. 10.1038/nature08460
- Lee, E., Chuang, H.-Y., Kim, J.-W., Ideker, T., & Lee, D. (2008). Inferring pathway activity toward precise disease classification. PLoS Computational Biology, 4(11), e1000217. 10.1371/journal.pcbi.1000217
- Tomfohr, J., Lu, J., & Kepler, T. B. (2005). Pathway level analysis of gene expression using singular value decomposition. BMC Bioinformatics, 6(1), 225. 10.1186/1471-2105-6-225
- Smyth, G. K. (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. Statistical Applications in Genetics and Molecular Biology, 3(1), Article 3. 10.2202/1544-6115.1027