Tests of pathway scores and activities

Contents

Tests of pathway scores and activities#

Pathway scores and the activities of regulators give every sample of a cell type one value per gene set or source, and differ between conditions as expression values do. limma() tests a contrast of a Design on them as GSVA’s and decoupler’s guides do with limma: a linear model of every set’s scores, moderated t-tests of the contrast and Benjamini-Hochberg adjusted p-values, with the design built for the cube matched to the scored samples by sample_id. It takes PathwayScores, Activities of samples, or an array of values from another platform.

Tests of per-sample scores with a design: limma on pathway scores and activities.

Pathway scores (gsva() and the others) and activities of regulators (ulm() and the others) give every sample of a cube’s group one value per gene set or source, which differ between conditions as expression values do. GSVA’s guide tests its scores with limma, as decoupler’s guides test activities: a linear model of every set’s scores on the design (lmFit), the contrast (contrasts.fit), moderated t-tests (eBayes, Smyth 2004) and a table of the results (topTable). limma() takes these steps in one call, with the Design built for the cube: its rows are matched to the scores by sample_id, so that the samples a score leaves out, such as those with too few cells, leave the fit too.

The fit:

The samples fitted are those of the scores that the design has, in the order of the scores. The design matrix is the design’s rows for them, so every column keeps its meaning; when those rows do not determine every column (the samples left out took a donor’s every sample, say), the fit keeps the columns that span them, as R’s qr() keeps them and limma_voom() fits a group, and the contrast is tested when it is estimable from these samples (see “The design of a group” in the description of limma_voom()). Missing scores (NaN) leave a set out of the fit of the samples they miss, as limma’s lmFit does.

References

Smyth GK (2004). Linear models and empirical Bayes methods for assessing differential expression in microarray experiments. Statistical Applications in Genetics and Molecular Biology 3, article 3. doi:10.2202/1544-6115.1027

Haenzelmann S, Castelo R, Guinney J (2013). GSVA: gene set variation analysis for microarray and RNA-seq data. BMC Bioinformatics 14, 7. doi:10.1186/1471-2105-14-7

Benjamini Y, Hochberg Y (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society B 57, 289-300. doi:10.1111/j.2517-6161.1995.tb02031.x

cytepool.limma(data, design, *, contrast=None, feature_ids=None, sample_ids=None, weights=None, trend=False, robust=False)#

Test a contrast of a design on scores of samples, by limma.

limma’s lmFit, contrasts.fit, eBayes and topTable(sort.by = "none") for one contrast: a linear model of the scores of every gene set, source or feature on the design, moderated t-tests of the contrast, and Benjamini-Hochberg adjusted p-values over them. The module description says which samples are fitted and how a design that its samples do not determine is fitted. Sort the table to read it, as limma(scores, design).sort("p_value").

Parameters:
  • data – PathwayScores, such as gsva() returns; Activities of samples, such as ulm() returns for a cube’s group; or an array of values, samples x features, NaN where missing, such as log-expression values of another platform.

  • design – A Design whose sample table has a sample_id column, such as the design built for the cube, with named contrasts; random effects are refused, as by limma_voom().

  • contrast – The name of one of the design’s contrasts; it may be left out when the design has one.

  • feature_ids – For an array, one id per column, as text; feature_0, feature_1, … by default.

  • sample_ids – For an array, one sample id per row, among the design’s; by default the rows are the design’s samples, in order.

  • weights – Weights of the fit, as lmFit takes them: one per sample, in the order of the rows of the scores, or one per sample and score; positive and finite. None weighs every value alike.

  • trend – Whether the prior variance of the moderation follows the mean of the scores (eBayes(trend = TRUE)), or one covariate value per gene set, source or feature, such as scores.n_genes, as GSVA’s guide passes the sizes of the sets.

  • robust – Whether to estimate the prior of the moderation robustly, as eBayes(robust = TRUE) does.

Returns:

A table with one row per gene set, source or feature, in the order of the data: gene_set, source or feature_id; estimate, the contrast of the scores (logFC); standard_error, its moderated standard error; average, the mean of the scores over the samples fitted (AveExpr); t; p_value; adjusted_p_value; and log_odds, the B-statistic (B).

Raises:
  • TypeError – If an argument has the wrong type, or is or holds a numpy masked array.

  • ValueError – If the activities are of statistics rather than samples, feature_ids or sample_ids is given with scores or activities, the design has random effects or no sample_id column, no sample of the data is in the design, the design leaves no residual degrees of freedom on its samples, the contrast is not estimable from them, or the design has several contrasts and none is named.

  • KeyError – If the design has no contrast of that name.

Used in: Pathway and regulator activity

Explained in: Choosing a method, Gene-set tests