Skip to main content

Hierarchical Gating

Top-down traversal through the marker hierarchy.

Full Algorithm Details

For complete gate checks and pseudocode, see Hierarchical Gating Algorithm.

Algorithm

  1. Find best passing ROOT (score > threshold)
  2. Descend: compare SIBLINGS at each level
  3. Stop when: leaf reached, no child passes, or ambiguous

Stop Reasons

ReasonDescriptionWhat to Do
leaf_reachedBest case - deepest level achievedNone needed
ambiguous_siblingsTop 2 scores too close to distinguishConsider Stage I refinement
no_child_passedAll children failed gate thresholdCheck marker coverage for children
no_root_passedNo root type fit the clusterCheck panel coverage, lower thresholds
ambiguous_rootTop 2 root scores too closeCheck root-level marker definitions

Scoring Formula

score = mean_enrichment + mean_positive + de_bonus - anti_penalty

Base Gating Parameters

Default thresholds vary by hierarchy depth to allow stricter gating at higher levels:

LevelDepthBase ThresholdAmbiguity GapDescription
0Root1.00.3Major lineages (Immune, Epithelial)
1Class0.80.25Cell classes (T cell, B cell)
2Subclass0.60.2Subtypes (CD4+, CD8+)
3+Leaf0.40.15Terminal states (Treg, Th17)

CLI

celltype-refinery annotate gate \
--input scored.h5ad \
--hierarchy markers.json \
--out output/gated.h5ad

Common Options

# Lower root threshold for permissive gating
celltype-refinery annotate gate \
--input scored.h5ad \
--hierarchy markers.json \
--root-threshold 0.8 \
--out output/gated.h5ad

# Tighten ambiguity gap
celltype-refinery annotate gate \
--input scored.h5ad \
--hierarchy markers.json \
--ambiguity-gap 0.4 \
--out output/gated.h5ad

See Also