Skip to main content

zmip — zoom-in pipeline

The round after msp: take msp's annotated.h5ad, split it into lineages, re-embed each lineage on its own, and let a per-lineage agent refine the annotation, clean noise and hand misassigned cells to the lineage they belong to. Same pattern as osp/msp — fixed computation, narrow agent decisions validated by the host, one self-contained report per lineage plus a global one.

msp annotated.h5ad ──▶ plan ──▶ per lineage: re-embed → foreign scores → agent ──▶ merge
                       (agent)                  (msp.integrate_adata)      (agent)     annotated_zmip.h5ad

Install

pip install msp-sc                                        # msp on PyPI (import name `msp`)
pip install zmip                                          # needs claude-agent-sdk + Claude Code CLI credentials

Usage

python -m zmip msp_out/annotated.h5ad --outdir zmip_out --model claude-sonnet-5 [--min-cells 800]
python -m zmip.report zmip_out          # rebuild the global report only

Re-running resumes: the plan is reused, lineages whose contract files (annotation_proposal.json, annotated.h5ad, report.html) exist are skipped; --force redoes everything. Integration knobs (--resolutions, --n-top-genes, --n-pcs, --n-neighbors, --harmony KEY=VALUE) are the same as msp's and apply to every per-lineage re-embedding.

Steps

1. plan (zmip.plan)

Host writes the evidence: cells/samples per coarse label, a kNN cross-connectivity matrix between coarse labels (share of each label's graph edges landing on every other label), PAGA on the same graph, and the coarse-label UMAP. The agent must read the UMAP and pools coarse labels that form one connected island into one lineage — even across cell types when data quality fuses them (T/B/myeloid as one immune island) — and keeps separate islands separate even when related; states (proliferating, stressed) go with the island they sit in. Host rules: every coarse label assigned exactly once; zoom only for lineages with at least --min-cells (default 800 — below that leiden cannot resolve stable substates); archived to zmip_plan.json. One lineage or none above the threshold → nothing is zoomed and the msp labels pass through.

2. per lineage (zmip.foreign, msp.integrate_adata, zmip.annotate)

  • Subset → msp.integrate_adata: HVG/PCA/harmony/leiden(0.3/1.0/2.0)/UMAP recomputed on the lineage alone, with every msp artifact (QC tables, cell-level outliers, standissect fragments, DEG at r1.0/r2.0, preannotation_removal.csv) in <lineage>/.
  • Foreign-lineage scores: lineage-level markers (wilcoxon on the whole dataset at the plan's lineage level, specific genes only) → sc.tl.score_genes for every other lineage → obs["foreign_<lineage>"], per-cluster summaries and UMAPs. Evidence only: close lineages share programs, so the agent decides between doublet, ambient, misassignment and genuine biology.
  • Agent on msp_leiden_r2.0 of the subset, one Claude Code Task per cluster, tools cluster_context / check_genes / check_deg / check_stability / subcluster (reclustering allowed). Per cluster: distinctness → identity → foreign signal → merge, and one action: keep (coarse label within the lineage), remove (with reason), or reassign to another lineage's coarse label (relabel only — the cells are not re-embedded there this round). Host validation as in msp.annotate plus the reassign rules. Removal is real: subset pre-annotation filtering ∪ agent-removed clusters.
  • Outputs: annotation_proposal.json, annotation_removed.csv, annotation_reassigned.csv, annotated.h5ad, report.html (msp's report with the lineage's Cell Type Annotation section).

3. merge (zmip.merge, zmip.report)

Fold every lineage back into the global object. annotated_zmip.h5ad keeps the survivors with zmip_lineage, zmip_cluster (<lineage>:<id>), zmip_ann_coarse, zmip_ann_fine, zmip_reassigned_from; msp_ann_* stay for the audit trail. No global re-embedding here (next round's job): the global figures use msp's UMAP. Archives zmip_removed.csv (every removed cell with lineage, cluster, sources) and zmip_reassigned.csv. report.html: plan · lineages (linked per-lineage reports) · final annotation · removed & reassigned.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zmip-0.1.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zmip-0.1.0-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file zmip-0.1.0.tar.gz.

File metadata

  • Download URL: zmip-0.1.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for zmip-0.1.0.tar.gz
Algorithm Hash digest
SHA256 23f3e73a5bd16e9aa3dbd8d8f3aca13e94a8775a9d9ad4b60ae3866b6b999695
MD5 42ffb5fb5b271be5325758a7c561d8ff
BLAKE2b-256 59252721efc3628e5ade280176b9270362e76dad65a8fef9ba960af0a2f8c0fd

See more details on using hashes here.

File details

Details for the file zmip-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: zmip-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for zmip-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8fd6227b740da76ce3e6fd9785e3c15b81ed1ccd72d52c967ecf0cc4d602970
MD5 593505589b9591cc1246abab5eb7e989
BLAKE2b-256 734606402882da1f1bc81788ca8c145667b119336e5e2de2bcb697557a5c89d1

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page