Skip to content

Expression heatmaps and dot plots

The Expression tab draws genes against cells: a heatmap with genes (or gene-set scores) as rows and cells or bins of cells as columns, or a scanpy-style dot plot of genes against the groups of a category column. Use it to see where a program turns on along an ordering, or which markers separate your clusters.

Where to find it

The Expression tab above the plot, then Settings in its toolbar. The settings modal is called Expression Plot Settings. Plot… in Find Marker Genes (Analyze → Cells → DEG) and Show heatmap in the gene-clustering results open the tab already configured.

How it works

Both plots read the expression matrix the Embedding colors from: .X, or a normalized and log-transformed copy when Normalize + Log1p is on in the Display panel (see Display settings). Genes hidden by the active gene mask are left out, and the toolbar says how many were hidden.

The heatmap extracts the chosen genes for the chosen cells, orders the cells, optionally averages consecutive cells into bins, and then rescales each row to 0..1 across its columns. Rescaling each row means every gene uses the full color range, which shows where it peaks but not how strongly it is expressed compared with other rows.

The dot plot follows scanpy's dotplot (Wolf et al. 2018): one dot per gene and group, the dot's area is the fraction of the group's cells expressing the gene above a cutoff, and its color is the mean expression.

Both plots honor the cell mask. With a mask active, only cells inside it are drawn, the settings modal says so, and the toolbar adds cell mask (with the subset's name when the mask is a saved named subset). Changing the mask redraws the plot.

Choose the plot and its rows

  1. Open the Expression tab and click Settings.
  2. Under Plot, pick Heatmap or Dot plot. The dot plot needs at least one categorical .obs column.
  3. Under Rows, pick Gene sets or Top marker genes.
  4. Set the cell ordering (heatmap) or the grouping column (dot plot), as described below.
  5. Click Generate Heatmap or Generate Dot Plot.

Click a gene row (heatmap) or gene label (dot plot) to color the Embedding by that gene.

Gene sets and folders

The gene-set list shows the sets from the Genes panel that contain genes, nested under their folders. A folder has its own checkbox (shown as partly ticked when only some of its sets are picked), so one click lays out a whole pathway folder in the order its sets appear. All and None tick or clear every set.

Once you pick more than one set, a Row order list appears. Drag the sets into the order their row blocks should take; panel order puts them back in the Genes panel's order. When sets from several folders are mixed, each block is labeled with its folder and set name (for example "Wnt (canonical) · ligands"), so two sets with the same role name stay apart.

See Gene sets for building sets and folders.

Top marker genes

Top marker genes draws the top genes of each group from a stored marker run. The run is made once by Find Marker Genes (Differential expression and markers), which stores a ranking of the top 500 genes per group. Everything here is a selection from that stored ranking, so changing Top N or a filter never re-runs the test.

Setting Default What it does
Marker run the first stored run Which stored run to read. Find marker genes… opens the marker tool when none exists.
Top N per group 5 (heatmap.marker_top_n) Genes kept per group after the filters below.
Min % in group blank (no filter) Minimum fraction (0 to 1) of the group's cells expressing the gene.
Max % in others blank Maximum fraction (0 to 1) of the other cells expressing the gene.
Min log2 fold change blank Minimum log2 fold change.
Max adjusted p blank Maximum adjusted p-value.
Rank by Wilcoxon score Order within each group: Wilcoxon score (scanpy's order) or log2 fold change.
Show only none Keep only genes in a gene set (up and down genes together) or a boolean .var column, such as transcription factors.
Block order follows the cell groups Drag to set the order of the per-group marker blocks; follow cell groups returns to the default.
Also include gene sets none Gene sets drawn as extra row blocks after the marker blocks.

When the marker run was made on the same column the plot is grouped by, the marker blocks follow the plot's group order, so a reordered plot keeps its diagonal. Dragging the Block order list overrides that.

Show only cannot reach past the stored ranking

Show only filters the stored top 500 genes per group. A gene that was not among a group's strongest 500 markers cannot appear, even if it is in the annotation. A group whose annotated genes were not strong markers comes up short of Top N. The restriction is a snapshot: editing or deleting the set later does not change a plot already saved as a figure.

If no gene passes the filters, the tab says so; loosen the filters or raise Top N.

Heatmap settings

Cell ordering

Option What it does
None (original order) Cells in their .obs order. The tab's default (heatmap.cell_ordering: none).
Group by category Cells in blocks by a categorical column, in the column's category order.
By line position Cells ordered by where they project along a drawn line. Needs a line (see Lines and trajectories).
By distance from line Cells ordered by their distance from a drawn line.
Category, then position Category blocks, then position along the line inside each block.
By similarity (clustered) Average-linkage hierarchical clustering of the cells on the selected genes, columns in dendrogram leaf order.
Category, then similarity Category blocks, then similarity clustering inside each block.

Line orderings project the cells onto the line in the two embedding columns the line was drawn on.

Under the three category orderings, a Then by row lets you nest more columns inside the grouping column (Group by more than one column), and a Groups to show list appears with one checkbox per label. Only ticked groups' cells are drawn, in the order of the list. Drag labels to reorder the blocks; column order returns to the column's own order; all ticks every group; none clears them so you can tick a few. With nothing ticked the modal says "Tick at least one group." and Generate is disabled.

Method details: similarity ordering

Before clustering, each gene is scaled to its own range so that no single highly expressed gene dominates the distance. Clustering is average linkage on Euclidean distance (SciPy, Virtanen et al. 2020), and it runs before binning so each bin averages cells that resemble each other.

Average linkage needs the full pairwise distance matrix, so above 5,000 cells the cells are first collapsed to 500 k-means centroids (scikit-learn, Pedregosa et al. 2011), the centroids are clustered, and each centroid's cells are laid out along the axis toward the next centroid. The toolbar then shows cells clustered via centroids. On 60,000 cells and 30 genes this took about 4 seconds.

Gene ordering

Option What it does
By gene set / marker group Rows in the order the sets (or marker blocks) were given. Default.
By peak position Rows sorted by the column where each row's scaled profile peaks, which draws a diagonal along a trajectory.
By similarity (clustered) Average-linkage clustering of each gene's scaled profile, rows in dendrogram leaf order.

When rows are grouped by gene set, both reorderings stay inside each set: a gene moves within its block and never leaves it.

Aggregate rows: one scored row per set

Tick Show gene set aggregates (one scored row per set) to replace each set's gene rows with a single row: the set's score per cell. This score is the same score the Embedding shows when you color by the set, computed with the Display panel's gene-set scoring options and with per-gene statistics taken over every cell. The plotted cells are then picked out of that score.

Setting Default What it does
Scoring method from Display (shipped: Mean / per-gene norm) Mean / per-gene norm runs the pipeline below; UCell (rank AUC, directional) uses UCell (Andreatta and Carmona 2021) and reads a directional set's down genes.
Per-gene normalization from Display (shipped: Z-score (MAD, robust)) How each gene is scaled before the genes are combined.
Per-gene clip percentile 1.0 Only with Min-max [0, 1]: each gene is clipped at this percentile at both ends first.
Aggregation across genes from Display (shipped: Mean) Mean, Median, Sum or Max. Because each row is rescaled to 0..1 afterwards, Sum draws the same as Mean.

Use Display's settings copies the Display panel's current scoring options into the modal. See Display settings for what each option does.

Why aggregate rows follow Display

Before v0.6.0 an aggregate row was a plain mean of unscaled values, so one high-magnitude gene drowned the rest of the set, and the row disagreed with the Embedding colored by the same set. A heatmap figure saved before that change keeps the plain mean it was drawn with.

One value per cell group

Under an aggregate row, with a category cell ordering, One value per cell group (the mean of its cells' scores) collapses each group to one column: the mean of the group's per-cell set scores. Bins do not apply, and columns widen so the group names fit under them. Without a category ordering the checkbox is disabled.

With one column per group, a Colour scale choice appears:

Option What it shows
Each row 0..1 (default) Each set spans the full color range. Shows where a set peaks, but not how much it varies: with two groups every row is always 0 and 1.
Raw group means, one scale The group means themselves on one scale shared by every row, with the legend giving the range. Use this to compare sets, and to see that a flat set stays one color.

Rows are ordered on the scaled values either way, so switching the scale does not reorder the plot.

Cell bins

Cell Bins (default 300, heatmap.n_bins) averages consecutive cells, in the chosen order, into that many columns. 0 draws every cell. The category labels under the plot are mapped onto the bins. The setting is ignored under One value per cell group.

Dot plot settings

Setting Default What it does
Group by the marker run's column, else the first categorical column The column whose groups become the dot plot's groups. Picking a marker run sets it to the run's column.
Groups to show all Tick which groups enter the plot and drag them into order. Only ticked groups' cells are counted, so fractions and the cell count are those groups' own. all, none and column order work as in the heatmap.
Then by none More categorical columns to split each group by, nested in the order you click them (see Group by more than one column).
Group order as given as given (the list's order) or cluster groups.
Colour mean expression (all cells in group) Dot color: the mean over all the group's cells (scanpy's default), or mean in expressing cells.
Scale none per gene, 0..1 across groups rescales each gene's means across the groups.
Expressing above 0 A cell counts as expressing a gene when its value exceeds this.
Gene order as provided as provided or by peak group.
Colours viridis viridis, white – red or blue – white – red.
Background #16213e Plot background. Text, grid lines and legends switch to dark ink when the color is light, whichever of the two inks contrasts more (WCAG luminance).
Genes as rows off Off: groups as rows and genes as columns, scanpy's layout.

cluster groups orders the groups by average-linkage clustering of their mean-expression profiles, with each gene standardized across groups first so one highly expressed gene does not decide the order, and leaves in optimal leaf order (Bar-Joseph et al. 2001). Groups that express the same genes then sit side by side. With fewer than three groups the order stays as given. Dragging the groups switches Group order back to as given, since clustering would undo the drag.

The dot plot also has a color limit and a dot-size cap; these are set on the saved figure in the Figures tab (Colour limit, Largest dot at fraction).

Group by more than one column

Both plots can group the cells by several categorical columns at once, for example by cluster and then by sample, to see whether a pattern holds in every sample or is carried by one.

Under Group by (dot plot) or a category Cell ordering (heatmap), the Then by row lists the other categorical columns. Click one to nest it inside the grouping column; click a second to nest it inside the first. The line beside the title shows the order, such as cluster → sample → batch, and clicking a lit column removes it.

  • One group per combination that has cells. A cluster absent from a sample gets no empty column. The first column is outermost; each nested column follows its own category order.
  • Groups to show, the colors and marker blocks stay the first column's. Ticking and dragging groups acts on the first column, and the nested groups travel with it.
  • Labels are tiered. In the dot plot each row carries its innermost label, and the outer columns are bracketed to the left in the first column's colors. In the heatmap the innermost label is under each block and the outer ones are bracketed below; a full line separates the outer groups and a faint one the groups inside them. A column too narrow for a slanted label gets it upright, and one under 8 px gets none. Hovering a dot plot row gives its full name and cell count; the heatmap tooltip names the block under the pointer.
  • Dot plot cluster groups reorders the first column's groups by their mean profiles and keeps each one's nested groups together, in their own order.
  • Heatmap One value per cell group gives one column per combination.

Small combinations are noisy: a dot for 8 cells is drawn like a dot for 800. In the dot plot the cell count of each group is in its row's tooltip, and the fractions are of that group's own cells.

A saved figure records the nested columns with the grouping column. If one of them is later deleted or converted to numbers, the figure reports it as missing rather than drawing something else.

Save as figure

Save as figure in the toolbar keeps the current plot as a figure record and switches to the Figures tab. A heatmap becomes an expression_heatmap figure and a dot plot an expression_dotplot figure. The record stores what the tab drew: the gene sets (or the marker run and its selection), the grouping column and groups, the line, the cells (the active named subset by name, or the masked cells' indices), and the display options. From there you can tune the parameters with a live preview, export, and attach the figure to the analysis record.

The heatmap is drawn on a canvas, so its figure exports as PNG only. The dot plot is SVG and exports as SVG or PNG, painted on its Background color.

A saved figure reports a missing input instead of drawing other genes: a marker run that was deleted or re-run, a group label that was renamed away, or a deleted .var column used by Show only.

What it writes

The Expression tab itself writes nothing to the AnnData. Save as figure adds one entry to uns['skopia_figures']; see the Figures tab.

Tips and pitfalls

Defaults for a saved figure differ from the tab

A saved expression_heatmap figure defaults to 50 bins and a category cell ordering (figures.expression_heatmap in the config), while the tab defaults to 300 bins and no ordering (heatmap:). Both can be changed in Configure defaults.

Row scaling hides magnitude

Every heatmap row is rescaled to 0..1 unless you choose Raw group means, one scale. A gene that is barely expressed anywhere fills the color range as fully as a strongly expressed one does. Check magnitudes on the Embedding or in a dot plot before reading a heatmap row as "high".

Marker plots need three or more groups

Find Marker Genes compares each group with the rest, so a column with two groups goes to differential expression instead, and there is no marker run to plot.