Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Compound labels

Some labels name more than one cell type: doublets, such as AT2 cell-plasma cell doublet, or mixed populations, such as AT2 cell / plasma cell. Embedded as one string, such a label matches a single term that fits none of its cell types well. CyteOnto therefore splits these labels into their cell types, matches each part to a Cell Ontology term and scores the parts.

How labels are split

For each distinct label, the LLM decides whether it names one cell type or several and returns the parts. The prompt sets these rules:

AT2 cell-plasma cell doublet, for example, becomes the parts at2 cell and plasma cell. A label is compound only when the model returns two or more parts; if it returns one, or if the request fails after its retries, the label stays whole. The model’s answers are cached, but a failed request is not, so the next call with the run tries to split that label again; see Caching. With use_cache=False, a failed request keeps the cached split of the label, if there is one. The parts are described, embedded and matched like any other label.

How compound pairs are scored

A pair is compound when its author label or its algorithm label has more than one part. For m author parts and n algorithm parts, CyteOnto scores every author part against every algorithm part with the chosen metric, giving an m × n matrix S. A part that matched no term scores 0. compound_scoring reduces S to one score:

The scores below are illustrative part scores, not the output of a run. They show how the two methods treat the same matrix:

Author labelAlgorithm labelm × nSmaxhungarian_mean
AT2 cell-plasma cell doubletplasma cell2×1[[0.05], [0.92]]0.920.46
AT2 cell-plasma cell doubletAT2 cell / plasma cell2×2[[0.98, 0.06], [0.05, 0.97]]0.980.975
AT2 cell-plasma cell doubletAT2 cell / T cell2×2[[0.98, 0.05], [0.06, 0.08]]0.980.53
AT2 cell-plasma cell doubletT cell / B cell2×2[[0.06, 0.05], [0.08, 0.07]]0.080.065
AT2 cell / plasma cell / NK cellAT2 cell / T cell3×2[[0.98, 0.05], [0.06, 0.08], [0.05, 0.07]]0.980.3533

Choose the method by the question you ask:

df = await cyto.compare(
    author_labels=["AT2 cell-plasma cell doublet", "T cell"],
    algorithms={"method_a": ["Plasma cell", "T cell"]},
    run_id="doublets",
    compound_scoring="hungarian_mean",
)

In the hosted API, set the request field compoundScoring.

Compound rows in the results

Pairs in which both labels have one part are scored as usual, so a run can mix both kinds of rows. See Read the results.

Caching

The parts of each label are saved per run_id, in <user_dir>/decompositions/<run_id>/, and shared by the author labels and all algorithms of the run. clear_run() does not delete them; delete the folder to split the labels of the run again, or pass use_cache=False. See Caching and runs.