Analyze a gene set¶
A gene set's ⋯ menu holds tools that look inside one set: does it split into co-expressed groups, how do its genes relate by expression and annotation, is it one expression pattern or several, and what cell states does it define?
Where to find it
Genes panel → Sets → a set's ⋯: Cluster genes…, Map genes…, Decompose into programs…, Cluster cells on this set…, Select cells…, Enrichment (overlap)….
The gene map is also at Genes panel → ⋯ → Gene map… for any gene subset.
| Tool | Question it answers | Output |
|---|---|---|
| Cluster genes | Which genes in this set are co-expressed with each other? | Gene sets, one per cluster |
| Gene map | How do these genes relate by expression, shared annotation, interaction and GO meaning? | A 2-D gene layout, modules, a similarity heatmap |
| Decompose into programs | Is this set one expression pattern or several? | Per-cell program scores, one gene set per program |
| Cluster cells on this set | What states do the cells take with respect to these genes? | A clustering and UMAP of the cells |
| Select cells | Which cells express this set above a threshold? | A selection or a label column |
| Enrichment | Which annotated sets does this list overlap? | An enrichment table |
Cluster genes¶
Splits a set of at least four genes into groups with similar expression patterns across cells. Each run adds a folder to Gene Clusters, named after the source set, holding one set per cluster. Running again with other settings adds another folder, so runs sit side by side.
Methods¶
Auto: co-expression modules (recommended) finds the number of modules itself, in the spirit of WGCNA (Langfelder and Horvath 2008):
- Genes with no variance are set aside.
- Genes whose best partner correlates below Min co-expression to join a module co-express with nothing and go to an unassigned group, so isolated genes do not distort the cut.
- The remaining genes are clustered by average linkage on 1 − correlation, and the number of clusters (2 to 20) is the one with the best silhouette width (Rousseeuw 1987).
- Refinement: a module whose first principal component (its eigengene) explains less of its variance than Split sensitivity (purity) is split in two; modules whose eigengenes correlate at or above Merge similarity are merged; modules smaller than Min genes per module join unassigned.
A report after the run says how many modules were found, the largest correlation between any two modules, and how many genes were left unassigned and why.
Hierarchical (Ward linkage) (Ward 1963) on correlation distance, cut at Number of clusters (K).
K-means on the genes' expression vectors, with Number of clusters (K). It can return fewer than K groups if a cluster empties.
DBSCAN (density-based) (Ester et al. 1996) on correlation distance. Two genes are neighbors when 1 − Pearson correlation is at most Neighbor radius (eps), that is, when they correlate at least 1 − eps. The number of clusters comes from the data; genes that reach no dense region form a trailing noise set.
Parameters¶
| Parameter | Default | What it does |
|---|---|---|
| Method | Auto | See above. |
| Source matrix | .X |
A smoothed layer (from Preprocess → Smooth) clusters on denoised expression, which helps on sparse spot data. |
| Similarity metric (Auto) | Biweight midcorrelation | Biweight midcorrelation (robust, default), Pearson or Spearman (rank). Biweight midcorrelation down-weights outlier cells. |
| Min co-expression to join a module (Auto) | 0.2 | Genes whose best partner correlates below this are unassigned. |
| Min genes per module (Auto) | 5 | Smaller modules are pruned to unassigned. |
| Merge similarity (Auto) | 0.8 | Merge modules whose eigengenes correlate at least this much. |
| Split sensitivity (purity) (Auto) | 0.5 | Split a module whose eigengene explains less than this share of its variance. |
| Number of clusters (K) (Hierarchical, K-means) | 3 | |
| Neighbor radius (eps) (DBSCAN) | 0.3 | Lower is stricter. |
| Min samples (DBSCAN) | 3 | Genes, including the gene itself, within eps needed to start a cluster. |
| Cell context | All cells | All cells, Current selection, or Annotation category (pick a categorical .obs column and its values). Correlations are computed over these cells only. |
| Restrict to active gene mask | off | Enabled only while a gene mask is active; shows how many of the set's genes pass. When ticked, only those genes are clustered. |
Expression is normalized (normalize_total + log1p) before clustering, as elsewhere in the gene tools.
When the run finishes, Show heatmap opens the Expression tab with one row band per cluster, restricted to the cells the clustering used; the toolbar says so, and Heatmap Settings can drop the restriction. See Expression heatmaps and dot plots.
Cluster genes writes nothing to the dataset; its results are gene sets.
Gene map¶
Places genes as points: genes close together are similar. Similarity can combine up to four channels, each with its own weight, so you can ask whether genes that are co-expressed also share annotation or interact.
- Open a set's
⋯→ Map genes… (3+ genes), or Genes panel →⋯→ Gene map… and choose a gene subset. - Switch channels on and set their weights:
- Expression: correlation across cells (bicor (robust), Pearson or Spearman), mapped to (r + 1) / 2 so anti-correlated genes sit far apart. Choose a source matrix (a smoothed layer makes sparse-count correlations usable) and optionally restrict it to the current lasso selection.
- Annotation: cosine similarity of which sets each gene belongs to, over the cached libraries you tick (GO, Reactome, the matrisome categories, cell-type markers). Fetch libraries in the Gene set library first. A gene no ticked library mentions is similar only to itself; the summary counts such genes.
- STRING: the combined score of each STRING edge among the genes (Szklarczyk et al. 2023), queried live; zero where there is no edge. Set species and minimum score.
- GO semantic: information-content-weighted similarity over the Gene Ontology (SimGIC, Pesquita et al. 2008): the summed information content of the GO terms two genes share, over that of all their terms. Sharing chondrocyte differentiation counts for much more than sharing biological process, which the annotation channel cannot tell apart. Choose biological process, molecular function or cellular component. Needs GO annotations fetched in the library.
- Set Neighbours, Resolution and Layout, and click Build map.
The combined similarity is the weighted mean of the channels switched on. Leiden (Traag et al. 2019) on its kNN graph gives modules, and UMAP (McInnes et al. 2018) on the distance 1 − similarity gives the layout (classical MDS for very small sets, or when chosen).
| Parameter | Default | What it does |
|---|---|---|
| Expression on, weight | on, 1.0 | |
| Expression metric | bicor | Biweight midcorrelation, which down-weights outlier cells. |
| Annotation on, weight | on, 1.0 | |
| STRING on, weight | off, 0.5 | Minimum combined score 400 (0 to 1000). |
| GO semantic on, weight | off, 1.0 | Aspect: biological process. |
| Neighbours | 15 | kNN graph for Leiden. |
| Resolution | 1.0 | Leiden resolution; higher gives more modules. |
| Layout | UMAP | UMAP or MDS. |
| Key | the set's name (gene_map from the panel menu) |
Name of the stored map. |
A map holds up to 3,000 genes.
Views¶
| View | What you can do |
|---|---|
| map | Hover a point for the gene, its module and how many sets annotate it. Drag a lasso around genes and Save as gene set (to Manual). |
| similarity | The full similarity matrix as a heatmap in dendrogram order, modules boxed on the diagonal. Hover for any pair's value. |
| modules | Each module's genes. Save one, or Save all modules as gene sets (to Gene Clusters). |
Adjust & re-run returns to the settings.
| Where | What |
|---|---|
uns['skopia_gene_maps'][key] |
The genes, coordinates, modules, parameters and the similarity matrix (float32). |
Tip
On the E11.5 hindlimb, the 160-gene NABA core matrisome set with expression (40%), two annotation libraries (40%) and STRING (20%) gave four modules of 63, 58, 20 and 19 genes. Weights are relative: what matters is their ratio.
Decompose into programs¶
Genes that share a name need not share an expression pattern. The collagens, for example, are fibrillar, basement-membrane and cartilage programs under one label, and a single mean or UCell score flattens them into one number. This tool first tells you how many patterns the set holds, then splits it into that many programs.
How it works¶
When the dialog opens it computes the eigen-spectrum of the set's gene-gene correlation matrix over the chosen cells and compares each eigenvalue with the largest one independent genes would produce by chance, the Marchenko-Pastur edge (1 + √(g/n))², for g genes and n cells (Marchenko and Pastur 1967). Teal bars stand above that noise floor (the dashed line); the number of them is the suggested number of programs.
The common rule "keep eigenvalues above 1" fails at single-cell sparsity: every pairwise correlation is tiny (mean |r| 0.009 for the collagens across 24,000 hindlimb cells), and dozens of noise eigenvalues sit slightly above 1. Against the noise edge, the same data gives two collagen patterns: fibrillar (Col1a1, Col1a2, Col3a1, Col5a1, Col5a2) and basement membrane (Col4a1, Col4a2, Col15a1, Col18a1).
Then PCA or NMF on the cells × set-genes matrix produces the programs:
- PCA (on per-gene z-scores) programs are signed, with each sign fixed so the program's leading gene loads positively. A gene joins a program when its loading is at least Loading cut times the program's largest absolute loading; positive loaders become the program's up genes and negative loaders its down genes, the format UCell scores directionally.
- NMF programs are additive and non-negative, computed as in the NMF Programs tool.
Run it¶
- Open a set's
⋯→ Decompose into programs… (3+ genes) and read the spectrum. - Pick Method, Programs (k) (prefilled with the suggestion), Source matrix and Cells.
- Click Run. The results list each program's genes, with Color to color cells by its score, View PC1 × PC2 (named after the first two programs) to plot cells by their first two program scores, and Save programs as gene sets.
| Parameter | Default | What it does |
|---|---|---|
| Method | PCA | PCA or NMF. |
| Programs (k) | the suggested count | Clamped to what the set allows. |
| Loading cut (PCA) | 0.2 | Fraction of the top absolute loading a gene needs to join a program. |
| Key | the set's name | Name of the score matrix. |
| Source matrix | .X |
Pick a smoothed layer on sparse spot data, where raw correlations are all small. |
| Cells | All cells | All cells, Current selection, or Annotation category. Cells outside score NaN. |
| Where | What |
|---|---|
obsm[key] |
Cells × programs scores (NaN outside the chosen cells), registered in uns['skopia_score_matrices'] so each program is a color pill and the matrix can be viewed as an embedding. |
varm['<key>_loadings'] |
All genes × programs, zero outside the set. |
uns['skopia_gene_set_decomposition'][key] |
The program gene lists, variance or factor weights, and the set's coherence. |
Save programs as gene sets files one set per program under Gene Clusters; PCA programs keep their down lists.
Cluster cells on a set¶
The reverse question: which states do the cells take with respect to one gene set? The tool runs PCA, a neighbor graph, Leiden and optionally UMAP on the cells × set-genes matrix, the same chain as PCA, neighbors, UMAP, Leiden but restricted to these genes. Genes are z-scored first (scale genes) so a highly expressed member does not dominate the first PC by magnitude alone. PCs and neighbors are clamped to what the set allows.
- Open a set's
⋯→ Cluster cells on this set…. - Set Key (prefilled from the set name), PCs, Neighbours, Resolution and Cells.
- Click Run. The results offer Color by clusters and Show UMAP.
| Parameter | Default | What it does |
|---|---|---|
| Key | the set's name | Suffix for every key written. |
| PCs | 20 | Clamped to the number of genes minus one. |
| Neighbours | 15 | |
| Resolution | 0.3 | Leiden resolution. Start low: on 24,000 hindlimb cells, 33 collagen genes at 1.0 gave 100 clusters. |
| compute a UMAP of this clustering | on | |
| scale genes | on | z-score each gene before PCA. |
| Cells | All cells | All cells, Current selection, or Annotation category. |
Everything goes under suffixed keys, so the dataset's own X_pca, neighbor graph and leiden are never touched:
| Where | What |
|---|---|
obsm['X_pca_<key>'] |
PCA of the set's genes. |
obsp['<key>_connectivities'], obsp['<key>_distances'], uns['<key>'] |
The neighbor graph, registered as scanpy registers one, so the Leiden and UMAP graph pickers offer it for re-clustering at another resolution. |
obs['leiden_<key>'] |
Clusters; cells outside the chosen scope are unassigned. |
obsm['X_umap_<key>'] |
UMAP of the clustering, if computed. |
uns['skopia_gene_set_clusterings'][key] |
Parameters and cluster sizes. |
Select cells¶
⋯ → Select cells… thresholds cells on the set's score (or, on a gene row, the gene's expression) with a live histogram, then updates the selection or writes a high/low label column that can go straight into Diff Exp. See Select, mask and delete.
Enrichment¶
⋯ → Enrichment (overlap)… opens the Enrichment tool with this set as the query list, tested against cached libraries. See Enrichment (ORA and GSEA).
Related¶
- Gene sets: scoring a set with the mean pipeline or UCell
- Gene programs and modules: the same questions across all genes rather than one set
- Gene set library and bundles: the libraries the gene map's annotation and GO channels read
- Named subsets and the subset tree: clustering a population of cells rather than a set of genes