squidpy.experimental.tl.assign_stitch_groups
- squidpy.experimental.tl.assign_stitch_groups(sdata, labels_key, qc_table_key=None, min_confidence=0.7, max_gap=3.0, max_group_size=4, stitch_params=None, inplace=True)[source]
Assign tile-cut cell pieces to stitch groups.
Reads
is_outlier=Truecells flagged bycalculate_tiling_qc(), pairs facing cut edges across tile boundaries, scores each pair via a transparent geometric composite, and assembles high-confidence pairs into stitch groups via union-find. This only annotates which pieces belong together – it does not modify the labels element. Materialising a stitched labels element is opt-in viamake_stitched_labels().The score per pair is the flat (unweighted) mean of five geometric features in [0, 1]:
iou(1-D extent overlap),endpoint_match(chord endpoints coincide),merge_compactness(4*pi*A / P^2of the closed union mask),merge_solidity(union area / convex hull area), andgap_proximity(seam gap relative to the morphological closing reach). No coefficients are fitted or shipped; the features are recorded in.uns["tiling_stitch"].- Parameters:
sdata (
SpatialData) –SpatialDatawith a labels element and a QC table fromcalculate_tiling_qc().labels_key (
str) – Key insdata.labels.qc_table_key (
str|None) – Key of the QC table. Defaults to"{labels_key}_qc".min_confidence (
float) – Threshold onstitch_confidence.0.7(default) is a starting point; raise it for stricter precision, lower for recall. Tune for your data – the score is heuristic, not a calibrated probability.max_gap (
float) – Maximum perpendicular distance (px) between facing cut edges for a pair to be considered a candidate. This is a search radius only; it does not scale the score.max_group_size (
int) – Cap on group size; oversized groups (likely false merges) collapse to singletons.stitch_params (
StitchParams|Mapping[str,Any] |None) – Advanced tuning knobs as aStitchParamsinstance or aMappingof its field names to values. SeeStitchParamsfor each field’s meaning and default.None(default) uses all defaults.inplace (
bool) – IfTrue, write back intosdata.tables[qc_table_key]. Otherwise return the modified AnnData.
- Return type:
- Returns:
The QC
AnnDatawith four new.obscolumns wheninplace=False, otherwiseNone.