Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Score gene-set activity per cell

Summarize a gene program, such as a pathway, a cell state or a lineage signature, as one score per cell, and compare CyteArc’s two methods for scoring any RNA gene set, WAGGR and AUCell. The data are 3,948 human peripheral blood mononuclear cells (PBMCs) from a healthy donor in the 10x Genomics 5k PBMC dataset (tenx_5K_pbmc_rnaseq), scored for five-gene signatures of T cells, B cells and myeloid cells. Each signature scores highest in its own lineage, with median AUCell scores of 0.84 in T cells, 0.95 in B cells and 0.95 in CD14 monocytes. The B-cell signature also reaches a median AUCell score of 0.55 in CD14 monocytes, which express three of its five genes: the tetraspanin CD37 and the MHC class II antigen-presentation genes CD74 and HLA-DRA.

WAGGR, a weighted aggregate Mompel et al., 2022, averages the library-size-normalized expression of the signature genes, so its score grows with how strongly a cell expresses the program, on a scale set by the abundance of the signature genes rather than capped at 1. AUCell Aibar et al., 2017 ranks each cell’s genes by their counts and scores, from 0 to 1, how many signature genes rank near the top and how high, so the score stops rising once every signature gene ranks near the top. AUCell therefore separates the cells that express a program from those that do not, and WAGGR ranks the expressing cells by how strongly they express it: within the CD14 monocytes, the myeloid AUCell score spans a 1.13-fold range from its 5th to its 95th percentile, and the WAGGR score a 7.37-fold range.

Open the prepared analysis

DataStore has 3948 (5025) cells with 1 assays: RNA Cell metadata: 'I', 'ids', 'names', 'RNA_G2M_score', 'RNA_S_score', 'RNA_UMAP1', 'RNA_UMAP2', 'RNA_cell_cycle_phase', 'RNA_clusters', 'RNA_doublet_score', 'RNA_leiden_cluster', 'RNA_nCounts', 'RNA_nFeatures', 'RNA_paris_cluster', 'RNA_percentMito', 'RNA_percentRibo' RNA assay has 33538 features and following metadata: 'I', 'ids', 'names', 'dropOuts', 'feature_type', 'genome', 'nCells'

Started: 2026-11-18T00:15:59.712715Z | Wall time: 12.828 s

The store holds 5,025 cells, and its saved RNA analysis kept the 3,948 that passed quality control. ds.pipeline.open(label="rna") reopens that analysis as a pipeline run, the saved record of one call of the RNA recipe with its cells, settings and results.

Define the gene sets

Gene sets are commonly shared as Gene Matrix Transposed (GMT) files, with one set per line: its name, a description and its genes, separated by tabs. cytearc.read_gmt reads a GMT file into a table with one row per gene of each set, where source names the set and target the gene. The next cell writes the three signatures to a temporary GMT file and reads it back. For your own gene sets, pass the path of your GMT file to cytearc.read_gmt:

genes
source
T_cellCD3D, CD3E, TRAC, LTB, IL7R
B_cellMS4A1, CD79A, CD37, CD74, HLA-DRA
MyeloidLST1, S100A8, S100A9, CTSS, FCER1G

Started: 2026-11-18T00:16:12.546732Z | Wall time: 0.031 s

The T-cell signature holds CD3D and CD3E of the CD3 complex, the T-cell receptor gene TRAC, the lymphotoxin gene LTB and the interleukin-7 receptor gene IL7R. The B-cell signature holds MS4A1 (CD20), CD79A of the B-cell receptor complex, the tetraspanin CD37, and CD74 and HLA-DRA of MHC class II antigen presentation, a function that B cells share with monocytes and dendritic cells. The myeloid signature holds LST1, the calprotectin genes S100A8 and S100A9, the protease gene CTSS and the Fc receptor gene FCER1G.

Score each cell with WAGGR and AUCell

Both methods take the gene sets, the cells to score and the features that the signature genes are matched against. Indexing a run by an output name returns an ArtifactRef, a reference to that saved result: run["analysis_cell_selection"] refers to the frozen selection of the run’s 3,948 analyzed cells, which later edits of the cell table cannot change. ds.features.universe(from_assay="RNA") selects every RNA feature. WAGGR scales each cell’s raw counts to a fixed total, and AUCell ranks the genes within each cell, a ranking that such scaling would not change. AUCell counts only the top 5% of that ranking, so rank every feature: ranking a smaller set, such as the highly variable genes, changes which genes count as top-ranked.

Signature genes are matched to the names of the selected features without regard to case. A gene that matches no feature is dropped without a message, and a gene that matches several, such as a symbol shared by two feature IDs, is dropped with a warning. A signature left with fewer than tmin matched genes is not scored, so check how many genes each signature matched, as the table below does. The default, tmin=5, would drop a five-gene signature that misses one gene, so the next cell sets tmin=3. Each method saves its scores in the store as an artifact, a result kept with a record of the inputs and settings that produced it, and ds.scores.load reads them back:

3,948 cells scored. AUCell counts the top 1,677 of 33,538 ranked genes; WAGGR scales each cell's counts to a total of 1,000.
genes matchedWAGGR medianWAGGR maxAUCell medianAUCell max
T_cell50.562.550.680.93
B_cell50.177.280.310.98
Myeloid50.0525.160.080.99

Started: 2026-11-18T00:16:12.582068Z | Wall time: 19.362 s

All five genes of each signature matched. With all genes weighted equally, as here, a WAGGR score is the mean expression of the signature genes in counts per 1,000 counts of the cell: in the cell with the highest myeloid score, 25.16, the five myeloid genes average 25 counts per 1,000. An AUCell score adds a share for each signature gene that ranks among the cell’s top 1,677 genes: for a five-gene signature, about 0.2 for a gene at the top of the ranking, less for a gene further down, and nothing for a gene below rank 1,677. A score near 1, such as the maxima of 0.93 to 0.99, therefore needs all five genes near the top.

Map the scores on the UMAP

Name the broad cell type of each cluster as the PBMC analysis does from marker genes: CD14 monocytes for cluster 2, CD16 monocytes for the 25 cells of cluster 10, and pDC-like cells, which resemble plasmacytoid dendritic cells, for cluster 11. Save the names and the scores as columns of the cell table, and color the run’s UMAP, run["umap"], by them. The AUCell panels share one scale from 0 to 1, and each WAGGR panel has its own:

Eight UMAP panels of the 3,948 analyzed PBMCs in two rows. The first column shows the broad cell types, with a legend beside them, and below them the 12 Leiden clusters, labeled on the plot. T cells fill the left, with NK cells at their lower edge, B cells sit at the top and CD14 monocytes on the right, with the 25 CD16 monocytes of cluster 10 at their upper tip. The 15 pDC-like cells and 12 platelets form two small groups to the right of the B cells, above the monocytes. The other three columns show the T_cell, B_cell and Myeloid signature scores: AUCell in the top row on one scale from 0 to 1, and WAGGR in the bottom row, each on its own scale up to its maximum of 2.55, 7.28 and 25.16. Each signature is brightest over its own population. For their own signatures, AUCell is almost uniformly bright over the B cells and the CD14 monocytes while WAGGR varies within them, and the B_cell AUCell panel colors the monocytes in a middle shade.

Started: 2026-11-18T00:16:31.948992Z | Wall time: 4.273 s

Each signature is brightest over its own lineage: the T-cell signature over the T cells on the left, the B-cell signature over the B cells at the top, and the myeloid signature over the CD14 monocytes on the right. For their own signatures, the B cells and the CD14 monocytes are almost uniformly near the top of the AUCell scale, while their WAGGR scores vary from cell to cell, most visibly for the myeloid signature. The B-cell AUCell panel also colors the monocytes in a middle shade, which the WAGGR panel shows only faintly.

Compare the scores between cell types

Take the median of each score in each cell type:

cellsAUCellWAGGR
T_cellB_cellMyeloidT_cellB_cellMyeloid
T cells23850.840.210.010.760.120.03
NK cells3120.070.190.180.050.150.18
B cells4950.190.950.140.293.470.07
CD14 monocytes7040.000.550.950.001.065.85
CD16 monocytes250.050.550.760.040.991.93
pDC-like cells150.060.570.330.042.300.26
platelets120.000.000.140.000.000.09

Started: 2026-11-18T00:16:36.226335Z | Wall time: 0.029 s

Each signature has its highest median in its own population, by both methods. Elsewhere, the AUCell median of the T-cell signature stays at or below 0.19, and that of the myeloid signature at or below 0.33, except in the CD16 monocytes of cluster 10, at 0.76. The B-cell signature also scores in other populations: its AUCell median reaches 0.55 in both monocyte populations and 0.57 in the pDC-like cells, more than half of its 0.95 in B cells, while its WAGGR median in the two monocyte populations, 1.06 and 0.99, is under a third of the B cells’ 3.47. Compare the expression and detection of each B-cell gene in B cells, CD14 monocytes and pDC-like cells:

counts per 1,000fraction detected
groupB cellsCD14 monocytespDC-like cellsB cellsCD14 monocytespDC-like cells
MS4A11.110.010.010.990.030.07
CD79A1.680.010.041.000.030.33
CD372.680.580.611.000.971.00
CD747.242.547.901.000.991.00
HLA-DRA4.722.743.441.000.991.00

Started: 2026-11-18T00:16:36.258480Z | Wall time: 1.254 s

CD37, CD74 and HLA-DRA are detected in 97% to 100% of the CD14 monocytes and pDC-like cells, MS4A1 in only 3% and 7%, and CD79A in 3% and 33%. A cell with three of the five genes at the top of its ranking scores about three fifths of the AUCell maximum, and the medians of these populations are 0.55 and 0.57. WAGGR averages expression instead, so the two most abundant genes, CD74 and HLA-DRA, carry most of its score: 2.54 and 2.74 counts per 1,000 in the CD14 monocytes against 0.58 for CD37, and 7.24 and 4.72 in the B cells against 1.11 for MS4A1 and 1.68 for CD79A. The pDC-like cells express CD74 at 7.90 counts per 1,000, more than the B cells do, and reach a WAGGR median of 2.30, two thirds of the B cells’ 3.47. To mark B cells alone, build the signature from genes rarely detected outside B cells, such as MS4A1, which is detected in 99% of the B cells.

Compare WAGGR and AUCell cell by cell

Plot the two scores of each cell against each other, one panel per signature:

Three scatter plots of AUCell score, from 0 to 1, against WAGGR score in mean counts per 1,000, one for each signature, with one point per cell colored by cell type. In every panel AUCell rises steeply at low WAGGR scores and then levels off. In the T_cell panel, the T cells fall into horizontal bands up to about 0.9, and the B cells form a band near 0.19. In the B_cell panel, the B cells lie near 0.95 across WAGGR scores up to about 7, and the CD14 monocytes level off near 0.55. In the Myeloid panel, the CD14 monocytes lie near 0.95 across WAGGR scores up to about 25.

Started: 2026-11-18T00:16:37.517976Z | Wall time: 0.595 s

In each panel, AUCell rises steeply at low WAGGR scores and then levels off, because higher expression cannot lift a gene that already ranks near the top. The CD14 monocytes stay near the top of the AUCell axis for the myeloid signature across WAGGR scores up to 25, and level off near 0.55 for the B-cell signature. For the T-cell signature, the T cells fall into horizontal bands about 0.2 apart, because a cell’s AUCell score depends mostly on how many of the five genes rank near the top. Measure how widely each score spreads within the population its signature marks:

populationAUCell 5thAUCell 95thAUCell foldWAGGR 5thWAGGR 95thWAGGR fold
T_cellT cells0.520.911.750.401.343.34
B_cellB cells0.920.961.052.384.661.96
MyeloidCD14 monocytes0.860.971.131.9514.367.37

Started: 2026-11-18T00:16:38.117413Z | Wall time: 0.028 s

WAGGR scores spread more widely than AUCell scores in all three populations. The gap is largest in the CD14 monocytes, 1.13-fold for AUCell against 7.37-fold for WAGGR. The B cells have the narrowest AUCell spread, 1.05-fold between 0.92 and 0.96, and the T cells the widest, 1.75-fold between 0.52 and 0.91, because their scores span the bands of the scatter plot.

Use AUCell to call the cells that express a program, with a cutoff chosen for each signature: the median B-cell score of the CD14 monocytes, 0.55, is above the 5th percentile of the T-cell score in T cells, 0.52, so AUCell scores of different signatures do not compare directly. Use WAGGR to rank cells by how strongly they express a program, and compare WAGGR scores only within one signature: their maxima run from 2.55 for the T-cell signature to 25.16 for the myeloid signature.

Weight genes and transform expression in WAGGR

WAGGR reads an optional weight column of the gene-set table: a larger weight gives a gene more influence on the score, and a negative weight subtracts a gene, such as one that the program represses. Without the column, every gene has weight one. The default mode="wmean" divides the weighted sum by the sum of the absolute weights, so the score does not grow with the number of genes in a signature, and mode="wsum" returns the weighted sum. log_transform=True takes the logarithm of the scaled counts plus one before weighting, which reduces the pull of the most abundant genes, such as CD74 in the B-cell signature. WAGGR scores compare only between results with the same mode and transformation. AUCell ignores weights.

To score S-phase and G2/M gene sets and assign each cell a cell-cycle phase, continue with Score cell-cycle activity.

References
  1. Badia-i Mompel, P., Vélez Santiago, J., Braunger, J., Geiss, C., Dimitrov, D., Müller-Dott, S., Taus, P., Dugourd, A., Holland, C. H., Ramirez Flores, R. O., & Saez-Rodriguez, J. (2022). decoupleR: ensemble of computational methods to infer biological activities from omics data. Bioinformatics Advances, 2(1). 10.1093/bioadv/vbac016
  2. Aibar, S., González-Blas, C. B., Moerman, T., Huynh-Thu, V. A., Imrichova, H., Hulselmans, G., Rambow, F., Marine, J.-C., Geurts, P., Aerts, J., van den Oord, J., Atak, Z. K., Wouters, J., & Aerts, S. (2017). SCENIC: single-cell regulatory network inference and clustering. Nature Methods, 14(11), 1083–1086. 10.1038/nmeth.4463