Audit a single-cell handoff

Follow five synthetic observations from AnnData to R. Check typed metadata, every sparse count, and whether a consumer can safely attach metadata in row order.

Try the browser replay

Try the handoff in your browser

Compare each export with its source. Both preserve the same IDs and count totals. Then change how the original metadata attaches to the reordered matrix. The replay uses the archived synthetic example.

Read the four count changes and the metadata binding result in the worked example below.

Three exports, two checks

The source has three features and five observations. The Python writer creates a native AnnData object and a separate Matrix Market bundle. R builds typed candidates, reorders both axes, then writes each sparse bundle with observations in rows. Each metadata receipt records one expected observation reorder under the supplied policy.

Metadata drift

Donor codes become integers. At O-B, "001" becomes 1. The metadata check finds one type change and five value changes. Counts agree.

Count drift

Four counts change while the typed metadata, every row and column total, and the nonzero count agree.

Where four counts changed

The count receipt aligns values by feature and observation ID. Here, each gain is balanced by a loss in both directions. Every other count stays the same.

Changed block, before → after
FeatureO-BO-DRow total
0011 → 26 → 57 → 7
F-0015 → 42 → 37 → 7
Column total6 → 68 → 8

Same observations, different order

The matched export passes both comparisons above. If a downstream step attaches the original metadata by row position, all five rows attach to the wrong observations. The first metadata row describes O-B, while the first observation in the exported matrix is O-A.

With CellMeta Receipt v0.2.0, give check-axis the exact metadata and observation files that the downstream step will consume. Run these commands inside the extracted example folder.

cellmeta-receipt check-axis examples/baseline/metadata.json examples/matched/observations.tsv --binding keyed
cellmeta-receipt check-axis examples/baseline/metadata.json examples/matched/observations.tsv --binding positional

A join by literal ID is compatible and exits 0. Positional assignment exits 1 and shows the first mismatch. The command checks the declared binding and leaves both files as supplied.

Align the metadata before a positional step

If the workflow requires positional input and both files contain the same complete set of IDs, use CellMeta Receipt v0.3.0 to write a new snapshot in the matrix's observation order. Keep the original snapshot for provenance.

cellmeta-receipt align-axis examples/baseline/metadata.json examples/matched/observations.tsv --output aligned-metadata.json
cellmeta-receipt check-axis aligned-metadata.json examples/matched/observations.tsv --binding positional --counts-only

Both commands exit 0 for this example. The new snapshot carries the same typed values and category declarations, and the matrix stays intact. A roster mismatch stops alignment before writing any output.

Run both checks

Install CellMeta Receipt v0.2.0 from its wheel and put the Counts Matrix Receipt v0.2.0 executable on your path. After extracting the example, run these commands inside the single-cell-handoff folder.

cellmeta-receipt check examples/baseline/metadata.json examples/matched/metadata.json --policy examples/allow-row-reorder.json
counts-matrix-receipt compare --baseline examples/baseline/bundle.json --candidate examples/matched/bundle.json --format json

Repeat with metadata-drift and then counts-drift in place of matched. Exit 1 reports a comparison with findings. Exit 2 means invalid input or an execution error. A workflow that requires both to agree should proceed only when both commands exit 0.

Run the checks in CI

The workflow verifies the SHA-256 of CellMeta Receipt v0.2.0 and Counts Matrix Receipt v0.2.0 before running them. It requires the reviewed exit pairs (0, 0), (1, 0), and (0, 1), plus the expected keyed pass and positional failure.

A successful run on main saves eight reviewed synthetic JSON receipts. Pull requests run the checks without uploading receipts.

Gate a Snakemake handoff

Run the metadata and count checks on the same export pair, with an optional keyed or positional observation check. The starter saves valid receipts and check statuses before returning the combined exit code.

Audit these exports in Codex or Claude Code

The standalone skill checks typed metadata, labelled counts, and the observation binding separately. Use the synthetic example first, then pass it the files your own workflow consumes.

Run the Nextflow workflow

The Workflow RO-Crate bundles runnable source, setup commands, synthetic exports, and expected receipts. The workflow saves both check results before applying the gate. The matched export exits 0. Metadata drift and count drift each exit 1. A missing candidate matrix exits 2 and leaves the metadata receipt available.

All four cases passed end to end on hosted Linux x86-64 using Nextflow 26.10.7, Java 21.0.13.1+2, Python 3.12, CellMeta Receipt 0.2.0, and Counts Matrix Receipt 0.3.0. On native Windows with Python 3.14.0, Nextflow lint and the task replays passed. The full Nextflow session stopped before either task started with Unknown signal: HUP.

Inspect a captured comparison run

The Process Run RO-Crate contains the exact synthetic exports, both observed receipts, tool versions, UTC timings, and checksums. The metadata check exited 0 and the count check exited 1 after finding four changed coordinates. Both checks produced valid results.

Rebuild the fixture

The verified run used Python 3.14.0, AnnData 0.13.3.post0 and SciPy 1.17.1 to write the source. R 4.6.1, Matrix 1.7.5 and SummarizedExperiment 1.42.0 wrote the candidates. The scripts read each native object back, verify the count totals, and check that both metadata and sparse sidecars identify the same observations. A fresh replay reproduced all six CLI outcomes.