Color cells¶
Coloring answers "where on this embedding is X?", where X is a cell annotation, one gene, a gene set, two genes or sets at once, or one column of a score matrix. One coloring is active at a time on a plot; highlight layers can be stacked on top of it without replacing it.
Where to find it
Cells panel → Categorical / Continuous → Color for .obs columns. Genes panel: click a gene to color by it, 🎨 on a gene-set row, Color → Bivariate Coloring, and the Gene-set scores pills in the Sets tab. How scores are computed is set in Display → Gene Set Aggregation.
While the Panels tab shows a figure
Every action on this page colors the active panel of the figure instead of the Embedding, which keeps its own coloring. See Panels.
By an .obs column¶
- In the Cells panel, open the Categorical or Continuous tab.
- Click Color on a column's row. Click it again to turn the coloring off.
Categorical columns use the colors stored in uns['<column>_colors'] when the dataset has them (scanpy's convention), so a file colored in scanpy or cellxgene looks the same here. A column without stored colors gets Skopia's palette: d3's category10 for the first 10 categories, then hues stepped around the color wheel by the golden angle, so a column with 30 clusters does not repeat colors. A legend appears at the bottom right of the plot.
Continuous columns are colored on the Continuous Color Scale chosen in Display, stretched from the column's minimum to its maximum. Cells with a missing value are drawn gray at half opacity.
Category names on the plot¶
On a categorical column, ⋯ → Show labels on plot writes each category's name at its cluster centroid and colors by that column, so the labels match the clusters. Labels never overlap: the largest clusters keep their centroid, smaller ones are moved to the nearest free spot with a thin leader line back to the centroid, and any that still cannot fit are hidden until you zoom in. The layout re-runs on every pan and zoom. Label Font Size in Display sets the base size (default 13 px). ⋯ → Hide labels on plot removes them.
By a gene¶
Search for a gene in the Genes panel, or open a gene set, and click the gene. The values come from the matrix chosen as Source in the View box (.X by default).
Two Display settings change what you see:
- Normalize + Log1p colors by scanpy's
normalize_totalfollowed bylog1p(Wolf et al. 2018), computed on a copy for display only. Leave it off when the Source is already log-normalized: applying it twice compresses the range and misrepresents the data. Expression scale detection tells you which scale the Source is on. - Color-ramp clip percentile sets the ends of the color ramp at the Nth and (100−N)th percentiles of the values, so a handful of extreme cells do not wash out everyone else.
Cells are drawn in order of value, so the highest-expressing cells sit on top of the rest.
By a gene set¶
Click 🎨 on a gene-set row in the Sets tab. Skopia turns the set into one score per cell with the pipeline chosen under Display → Gene Set Aggregation, which has two scoring methods.
Mean / per-gene norm (default)¶
Three steps, in this order:
- Per-gene normalization puts the genes on a common scale so one highly expressed gene does not dominate the set.
- Aggregation across genes combines the normalized genes into one value per cell.
- Color-ramp clip percentile sets the ramp's ends, as for a single gene.
| Per-gene normalization | What it does |
|---|---|
| None (no per-gene scaling) | Each gene's values as the Source holds them, so high-magnitude genes dominate. |
| Z-score (MAD, robust) (default) | Center on the median, scale by the median absolute deviation; falls back to the standard deviation when the MAD is 0. |
| Z-score (SD) | Center on the mean, scale by the standard deviation. |
| Min-max [0, 1] | Clip each gene at the Per-gene clip percentile (0 to 5%, default 1%), then rescale to [0, 1], so every gene counts equally. |
| Rank → [0, 1] | Replace each value with its average rank within the gene, divided by the number of cells. |
| Aggregation | What it does |
|---|---|
| Mean (default) | Average of the per-gene values. |
| Median | Middle value; less affected by one or two outlier genes. |
| Sum | Total; emphasizes broad expression. |
| Max | Highest gene per cell; emphasizes expression of any one gene in the set. |
The values read are the Source matrix, or its normalized log1p when Normalize + Log1p is on. A set with one gene is colored as that gene. For a directional set (↑ and ↓ genes), this method scores the ↑ genes only.
UCell (rank AUC, directional)¶
UCell (Andreatta and Carmona 2021) ranks the genes within each cell and scores the set by how high its genes rank, as an area under the rank curve. Because it works within each cell, it does not depend on normalization between cells. It uses a set's ↓ genes when it has them: the score rises with the ↑ genes and falls with the ↓ genes. In Display, UCell reads the counts layer when the dataset has one and .X otherwise, with ranks capped at 1,500.
This coloring is not stored. To write a UCell score into .obs, use the gene set's ⋯ → Score with UCell… (Gene sets).
Which score do other tools use?
The Display pipeline is shared: the 🎨 coloring, Select cells… from a gene-set row and Panels score a set the way Display says. Aggregate rows in an expression heatmap use the same pipeline with their own settings, which start from Display's. Two exceptions: highlight layers and bivariate coloring always use the Mean / per-gene norm pipeline, even when UCell is chosen.
Genes hidden by the gene mask are left out of a set's score.
Bivariate coloring¶
Bivariate coloring shows two genes or gene sets at once, so you can see where they overlap and where each is alone (for example Sox9 × Scx, or a cartilage set against a tendon set).
- In the Genes panel, open the Color tab and find Bivariate Coloring.
- For Axis 1 (→ Red) and Axis 2 (↑ Blue), choose Gene set or Gene, then pick the set or search for the gene.
- Click Apply Bivariate Coloring.
Each axis is scored with the Mean / per-gene norm pipeline from Display, clipped at the Color-ramp clip percentile, and rescaled to [0, 1]. The two values then pick a color from a 2D colormap: with the default Red / Blue / Yellow map, low on both is light gray, high on axis 1 alone is red, high on axis 2 alone is blue, and high on both is yellow. Two other maps are in Display → Bivariate Colormap.
Cells are drawn in order of the sum of the two values, high on top. The ↑ High on Top button in the bivariate legend reverses that, which helps when cells high in both hide the ones you want to see.
By a score matrix column¶
Some tools write a cells × features matrix to .obsm with named columns: PySingleCellNet's per-class scores (for example SCN_score), CNV scores per chromosome, gene-set score matrices. These are listed in the Genes panel's Sets tab under Gene-set scores, one group per matrix (◈ <obsm key>). Click a column's pill to color by it.
The same matrices appear in the Embedding picker, where the Axes pickers let you plot one column against another (for example two cell-type scores).
Clear a coloring¶
The bar at the top of the Genes panel names the current gene, set or bivariate pair and has a Clear button. For an .obs column, click its Color button again.
Related¶
- Display settings and highlights
- Gene sets and The Genes panel
- Expression scale detection
- Select, mask and delete: select cells by a threshold on a gene or set
- Cell typing (PySingleCellNet)