Python API

The guided object and the functions used by the CLI and Snakemake workflow.

Guided object

class cell_curator.CellCurator(*, adata=None, path=None, organism, tissue, run_id, cluster_key='canonical_cluster', markers=None, output_root='results/cell_curator', mode='evidence-only', scope_key=None, scope_name='', embedding_key='X_pca_harmony', layer='logcounts', counts_layer='counts', feature_id_column='gene_symbol', developmental_stage='', condition='', technology='dissociated', experimental_context='', composition_covariates=None, reviewer='', preauthorized=False, assumptions=(), hierarchy_levels=('L1',), writeback_prefix='cell_curator', overrides=None)[source]

A configured, hash-frozen annotation run.

Parameters mirror the questions the configuration actually asks. Anything not exposed here can still be set through overrides, which is deep-merged onto the template last and therefore wins.

Provide exactly one of adata or path.

Parameters:
  • adata (Any | None)

  • path (str | Path | None)

  • organism (str)

  • tissue (str)

  • run_id (str)

  • cluster_key (str)

  • markers (str | Path | Mapping[str, Any] | None)

  • output_root (str | Path)

  • mode (str)

  • scope_key (str | None)

  • scope_name (str)

  • embedding_key (str)

  • layer (str)

  • counts_layer (str)

  • feature_id_column (str)

  • developmental_stage (str)

  • condition (str)

  • technology (str)

  • experimental_context (str)

  • composition_covariates (Sequence[str] | None)

  • reviewer (str)

  • preauthorized (bool)

  • assumptions (Sequence[str])

  • hierarchy_levels (Sequence[str])

  • writeback_prefix (str)

  • overrides (Mapping[str, Any] | None)

DEFAULT_SCOPE_KEY = 'cell_curator_scope'
validate()[source]

Load and strictly validate the generated configuration.

Return type:

Any

property run_directory: Path

The immutable run root that every artifact is published under.

inspect()[source]

Report structure, keys, and representations without changing anything.

Return type:

dict[str, Any]

freeze()[source]

Create the hash-frozen working copy, membership artifacts, and QC.

Return type:

dict[str, Any]

scene()[source]

Persist Stage 1 context, compute detection, and the assumptions ledger.

Return type:

dict[str, Any]

plan()[source]

Persist Stage 2 vocabulary, evidence routes, and open assumptions.

Return type:

dict[str, Any]

prepare()[source]

Freeze the input, then run the scene and plan stages in order.

Evidence generation requires both stages, so this removes the one piece of ordering a caller would otherwise have to know. An interactive run (the default) still stops here until the context is confirmed and the assumptions gate is signed.

Return type:

dict[str, Any]

approve_assumptions(*, reviewer, scope='*', preauthorized=False)[source]

Sign the assumptions gate. Required before any biological label.

Parameters:
Return type:

dict[str, Any]

markers(**kwargs)[source]

Run the signed marker profile and configured cross-check surface.

Parameters:

kwargs (Any)

Return type:

Any

status()[source]

Return the current stage, blockers, and the next action to take.

Return type:

dict[str, Any]

validate_run()[source]

Check completeness, hashes, mapping conservation, and review state.

Return type:

dict[str, Any]

preview_writeback(*args, **kwargs)[source]

Return the source-preserving write-back diff without applying it.

Parameters:
Return type:

Any

write_back(*args, **kwargs)[source]

Apply an explicitly approved write-back to a new object by default.

Parameters:
Return type:

Any

freeze_review_packet()[source]

Freeze the immutable review packet directory for human sign-off.

Return type:

Path

annotate()[source]

Run every computational phase and freeze a review packet.

This is the whole pipeline: initialize, plan, audit, refine, evidence, decide, map, review, validate. It is idempotent, so calling it after the granular methods resumes rather than repeats. Labels still are not written back to any object — that stays behind write_back().

Return type:

Path

confirm_context(*, input_path, reviewer)[source]

Confirm or correct the biological context recorded in Stage 1.

Parameters:
Return type:

dict[str, Any]

list_assumptions()[source]

Return the living assumptions ledger.

Return type:

dict[str, Any]

add_assumption(*, statement, scope='global', material=True)[source]

Append one assumption to the living ledger.

Parameters:
Return type:

dict[str, Any]

list_capabilities()[source]

Return the assay-aware capability registry this configuration resolves to.

Return type:

list[Any]

validate_knowledge()[source]

Validate the configured knowledge providers and any ontology.

Return type:

dict[str, Any]

provision_ontology()[source]

Report the configured ontology provider’s provisioning status.

Return type:

dict[str, Any]

assemble_markers(**kwargs)[source]

Assemble and publish the signed marker vocabulary.

Parameters:

kwargs (Any)

Return type:

tuple[list[Any], Path]

build_evidence_cards()[source]

Scaffold one evidence card per proposed label.

Return type:

list[Path]

build_report(*, strict=False, level=None)[source]

Build the self-contained HTML report only.

Distinct from review_packet(), which also builds the evidence cards and critic packet that surround it.

Parameters:
Return type:

Path

check_report(*, level=None)[source]

Validate report completeness read-only, after approval.

Parameters:

level (str | None)

Return type:

dict[str, Any]

build_critic_packet()[source]

Build the platform-neutral critic packet for adversarial review.

Return type:

Path

import_critic_findings(input_path)[source]

Validate and atomically import structured critic findings.

Parameters:

input_path (str | Path)

Return type:

dict[str, Any]

import_critic_reconciliation(input_path)[source]

Validate and atomically import reviewer dispositions.

Parameters:

input_path (str | Path)

Return type:

dict[str, Any]

validate_critic_reconciliation()[source]

Enforce that every critic finding carries a reviewer disposition.

Return type:

dict[str, Any]

Configuration and record types

AnnotationDecision

BackendReceipt

BenchmarkArtifact

One checksum-pinned acquisition artifact in a benchmark recipe.

BenchmarkDatasetManifest

Versioned, neutral public or local benchmark acquisition contract.

BenchmarkResult

Capability

CapabilityLevel

CellCuratorConfig

EvidenceRecord

MappingRecord

MarkerProgram

RiskCoveragePoint

One operating point on the risk-coverage curve of a prediction table.

RunState

Functions

advisory_confidence

Combine four evidence dimensions into an explicitly uncalibrated score.

annotate

Run the configured pipeline; corpus runs execute the compiled Snakemake DAG.

annotation_progress

Return current stage, scope, blockers, progress, and next action.

apply_writeback

Apply an atomic write-back to a new object by default.

approve_annotation_assumptions

Record interactive or declared non-interactive assumption approval.

build_critic_packet

Build the platform-neutral critic packet for adversarial review.

build_evidence_cards

Scaffold one evidence card per proposed label.

build_html_report

Build the self-contained HTML review report.

build_marker_vocabulary

Assemble and publish the signed marker vocabulary for a configuration.

canonicalize_input

Create the hash-frozen working copy and canonical membership artifacts.

check_corpus_isolation

Refuse a corpus whose records were learned from the test split's donors.

check_review_report

Run strict read-only report validation after approval.

collect_annotation_level

Collect parent-scoped markers, classifier corroboration, and state evidence.

compare_annotation_corpora

Compare label definitions, source records, and mappings between revisions.

compute_input_qc

Compute or validate source-preserving QC on the canonical working copy.

configuration_schema

Return the machine-readable schema for configuration version 3.

confirm_annotation_context

Confirm or correct the scene context recorded in Stage 1.

corroborate_ontology_terms

Corroborate CL terms against an optional live service without depending on it.

detect_compute_environment

Detect CPU, RAM, Apple Silicon, CUDA, and scheduler state without mutation.

discover_celltypist_models

List locally cached CellTypist models without downloading anything.

evaluate_benchmark_predictions

Score a neutral-format prediction table against its recorded truth.

existing_prediction

Turn an existing per-cell prediction column into one auditable hypothesis.

export_benchmark_predictions

Write a completed run's labels as a neutral-format prediction table.

export_corpus_programs

Export reviewed, context-matched corpus definitions as signed programs.

fetch_azimuth_reference

Acquire a pinned curated-human reference bundle with a cache receipt.

fetch_census_reference

Acquire a bounded CELLxGENE Census slice with a versioned cache receipt.

fetch_scimilarity_model

Acquire a pinned SCimilarity model bundle with a cache receipt.

finalize_corpus_annotation

Validate hierarchy nesting and publish cell labels and the evidence report.

freeze_review_packet

Freeze the immutable review packet directory for human sign-off.

import_annotation_corpus

Import bounded normalized source records without approving their labels.

import_consensus_annotation_level

Write one level's decisions from the configured annotation-consensus run.

import_critic_findings

Validate and atomically import structured critic findings.

import_critic_reconciliation

Validate and atomically import reviewer dispositions for critic findings.

initialize_run

Initialize or resume an immutable annotation run.

inspect_input

Inspect an AnnData or MuData source without changing it.

list_annotation_assumptions

Return the living assumptions ledger for a configured run.

list_capabilities

Return the assay-aware capability registry a configuration resolves to.

load_annotation_corpus

Load and validate a pinned multi-source label corpus.

load_config

map_curated_human_reference

Map a query onto a curated human reference (Azimuth-style).

map_reference

Transfer labels from a labeled reference by nearest neighbours.

map_scarches

Map a query onto a trained reference model with scArches surgery.

map_scimilarity

Run a local SCimilarity model as one hypothesis.

plan_annotation

Persist Stage 2 vocabulary, evidence routes, and unresolved assumptions.

predict_celltypist

Run a locally cached CellTypist model as one hypothesis.

predict_popv

Run a local pretrained CPU popV subset with full method provenance.

prepare_annotation_scene

Persist Stage 1 inspection, context, compute, assumptions, and progress.

preview_writeback

Return a source-preserving write-back diff after computational checks.

propose_corpus_update

Record a proposed corpus change without changing the active snapshot.

provision_ontology

Report the configured ontology provider's provisioning status.

record_annotation_assumption

Append one assumption to the living ledger.

register_assay_representation

Return a validated config copy with one newly registered assay representation.

register_knowledge_provider

Return a validated config copy with one local or optional cached provider.

review_corpus_update

Record a review and publish a new immutable corpus revision.

route_annotation_crosscheck

Select one deterministic automated cross-check for a hierarchy scope.

run_annotation_classifier

Run one configured local classifier as an immutable evidence stage.

run_marker_tools

Run the complete signed marker profile and cross-check surface.

sweep_benchmark_risk_coverage

Report coverage, selective accuracy, and risk across a confidence grid.

train_scanvi_reference_model

Train a scANVI reference model from a labeled local reference object.

validate_critic_reconciliation

Enforce that every critic finding carries a reviewer disposition.

validate_dataset_manifest

Validate one public benchmark dataset manifest.

validate_hierarchy_nesting

Enforce one parent per label and optional one-cell-one-leaf membership.

validate_knowledge_providers

Validate configured local knowledge providers and any configured ontology.

validate_ontology_terms

Validate ontology accessions against a local ontology file.

validate_run

Validate completeness, hashes, mapping conservation, and review state.