Skip to content

Differentiation (stemFinder)

Score how differentiated each cell is with PyStemFinder. Use it to find the least differentiated cells in a dataset (a candidate root for pseudotime, or a stem or progenitor population) and to rank clusters by potency.

Where to find it

Analyze → Cells → Differentiation (stemFinder) → Open Differentiation tool…

How it works

stemFinder (Noller and Cahan 2024) rests on one observation: less differentiated cells vary more in their expression of cell cycle genes than their neighbors do. For each cell it measures that heterogeneity across the cell's k-nearest-neighbor neighborhood, using a set of marker genes (by default the S and G2M cell cycle genes).

Skopia prepares what PyStemFinder expects and hands it a throwaway AnnData holding only the marker genes:

  • Expression. Counts are normalized to 10,000 per cell over every gene and log1p-transformed; data already on a log scale is used as it is. The default gini method then binarizes each marker on scaled expression, splitting each gene at its own mean over the scored cells.
  • Neighborhood. The method prescribes k = √n, far larger than the 15 neighbors a clustering graph uses. By default Skopia builds an exact kNN graph with that k on a PCA embedding for this run and discards it afterward. PyStemFinder reads only which cells are neighbors, so this skips the connectivity computation sc.pp.neighbors would spend most of its time on.

On the same preprocessing, Skopia's scores equal a direct PyStemFinder run.

Run it

  1. Run PCA first (Analyze → Cells → PCA), unless you plan to use an existing graph.
  2. Optionally restrict the cells with the cell mask or a named subset. Everything is then computed on the active cells only (see Tips and pitfalls).
  3. Open Analyze → Cells → Differentiation (stemFinder) and click Open Differentiation tool….
  4. Tick the Metrics you want (below). stemFinder and diffOmeter are ticked by default.
  5. Under Markers, keep Cell cycle genes (S + G2M) or choose A gene set from the Genes panel. For the cell cycle list or the expressed-TF baseline, check Species: it is guessed from the gene names and genes are matched ignoring case.
  6. Under Neighbourhood, keep Build a kNN graph for this run (pick the PCA embedding, PCs and k) or choose Use an existing graph.
  7. Optionally set a Column suffix and a Summarize by column.
  8. Click Run. The job runs in the background and can be cancelled. When it finishes, the panel reports how many cells were scored with how many markers and the k used, lists warnings, offers a button per output column to color by it, and shows the group table if you asked for one. The embedding is colored by the first score.

Metrics

Metric Writes Direction What it measures
stemFinder stemfinder, stemfinder_raw stemfinder: lower = less differentiated (oriented like pseudotime). stemfinder_raw: higher = less differentiated. Cell cycle heterogeneity among each cell's neighbors. stemfinder is 1 − raw / max(raw).
diffOmeter diffometer Higher = less differentiated Mean Gini impurity of the binarized markers across the neighborhood.
Cell-cycle expression stemfinder_cc_mean Higher = more proliferative Baseline: mean log expression of the markers. Needs no neighborhood.
Expressed TFs stemfinder_n_TFs More TFs expressed Baseline: how many of the species' transcription factors each cell expresses.

The two baselines are the comparisons the stemFinder paper uses. They are not potency scores, and the Pseudotime (DPT) root picker leaves them out; it offers the most potent cell by a stemFinder score (lowest stemfinder, highest stemfinder_raw) or by diffometer (highest).

Parameters

Parameter Default What it does
Markers Cell cycle genes (S + G2M) Genes whose neighborhood heterogeneity is scored. Any Gene-panel set can stand in.
Species Guessed from gene names Selects the cell cycle and transcription factor lists (mouse, human, C. elegans).
Build a kNN graph for this run On when a PCA embedding exists Exact kNN on the chosen embedding. With a saved subset active, its own X_pca_<subset> is preselected.
PCs 32 Leading components used; blank uses all.
k √n of the scored cells Neighbors per cell (counting the cell itself, as scanpy does).
Use an existing graph Off Use a kNN graph already in the dataset (its distances).
Column suffix none (a saved subset's name when one is active) Appended to every output column, so runs on different cells do not overwrite each other: stemfinder_<suffix>.
Summarize by (none) A categorical column; the result lists each group's median score, least differentiated first.

Under Advanced:

Parameter Default What it does
stemFinder method gini (binarized) stdev and variance read log-normalized expression instead of binarizing.
Binarize scaled expression (above each gene's mean), at 0 The alternative binarizes log-normalized expression at the threshold you give.
diffOmeter weights equal presence weights each marker by the fraction of cells above threshold; mean expression needs log-normalized binarization, since scaled expression averages to about 0.
include the cell On Counts the cell itself in its own diffOmeter neighborhood.
Expression .X .X or a layer. The detected scale is shown in the option.

What it writes

Where What
obs['stemfinder'] Normalized stemFinder score, lower = less differentiated.
obs['stemfinder_raw'] Raw stemFinder score, higher = less differentiated.
obs['diffometer'] diffOmeter score, higher = less differentiated.
obs['stemfinder_cc_mean'] Mean cell cycle expression (if ticked).
obs['stemfinder_n_TFs'] Number of expressed transcription factors (if ticked).

Each name gains _<suffix> when a suffix is set. Cells outside the cell mask get no value (NaN). The kNN graph built for the run is not stored. The run is recorded in the analysis record, and the notebook export replays it.

Tips and pitfalls

The cell mask scopes everything

With a mask active, scaling, the neighborhood and k = √n all use the active cells only, and cells outside get no score. Without a suffix, a masked run overwrites the unsuffixed columns and empties them outside the mask; the dialog says so in amber. Give each subset its own suffix (a saved subset's name is filled in for you).

Markers that shaped the PCA

If some markers are highly variable genes, they helped build the PCA the neighborhood comes from, so cells with similar cell cycle states are already pulled together. The result warns with the count. Ideally the PCA's highly variable genes leave the cell cycle genes out.

Small neighborhoods

A cell with few neighbors looks homogeneous and so scores as more differentiated than it may be. When you use an existing graph and some cells have fewer than 5 neighbors among the scored cells, the result warns; cells with no neighbors get no score, where PyStemFinder alone would score them 0 ("fully differentiated"). Building a graph for the run gives every cell k − 1 neighbors.

Scaled input

A z-scored matrix cannot give log-normalized expression. On such input, stdev, variance, the cell-cycle mean, expressed TFs and binarizing on log-normalized values are refused; gini on scaled expression and diffOmeter still run. Pick a counts or log-normalized layer to use the rest.

Suffix names that read as another score

A suffix starting with raw, cc_mean or n_TFs would turn stemfinder into a name that reads as a different score (for example stemfinder_raw, which runs the opposite way). Such suffixes are refused.

Install

PyStemFinder is part of the default environment. An environment installed before it was added shows install instructions; run pixi install again.