What a paper needs
A claim bound to a number, and a bundle that reproduces it. This page is rendered from a real run on every docs build — every value below was computed by the engine, not typed out. The notebook itself is ordinary Python you can download and run.
marimo edit examples/notebooks/08_what_a_paper_needs.py # as a notebook
python examples/notebooks/08_what_a_paper_needs.py # or as a plain scriptimport atexit
import json
import pathlib
import shutil
import tempfile
import marimo as mo
import ligase as lg
work = pathlib.Path(tempfile.mkdtemp(prefix='ligase-paper-'))
atexit.register(shutil.rmtree, work, ignore_errors=True)
cache = work / 'cache'
def shown(text):
"""Reports name the files they read; the page must not name ours."""
for form in {str(work), str(work.resolve())}:
text = text.replace(form, 'work')
return text8 — What a paper needs
The last mile of an analysis is a sentence. “The top candidate’s score is such-and-such.” It goes into a manuscript by hand, and the pipeline behind it goes on changing. Months later the sentence and the number disagree, and nothing marks the place.
This notebook takes a result as far as a paper could carry it. It rebuilds a small version of the target-discovery pipeline from from a graph to a shortlist, binds a sentence to a number in the result, writes the methods paragraph the run supports, shows a claim the run does not support, and writes a bundle that can be replayed to check that the results come out the same.
ensembl = [f'ENSG{10000 + 137 * i:011d}' for i in range(12)]
symbols = [f'GENE{i:02d}' for i in range(12)]
edges = []
for _i in range(36):
_from = _i % 12
_a, _b = (ensembl[_from], ensembl[(_from + 1 + _i * 5 % 11) % 12])
edges.append({'source': _a, 'target': _b, 'type': 'interacts_with', 'sources': ['open-targets'], 'score': round(0.1 + _i * 3719 % 8900 / 10000, 4)})
(work / 'targets.json').write_text(json.dumps({'nodes': [{'id': e, 'type': 'gene', 'sources': ['open-targets']} for e in ensembl], 'edges': edges}), encoding='utf-8')
(work / 'ensembl_to_hgnc.tsv').write_text('id\tsymbol\n' + ''.join((f'{e}\t{s}\n' for e, s in zip(ensembl, symbols, strict=True))), encoding='utf-8')
_degs = [f'GENE{5 * i % 12:02d}' for i in range(8)]
_degs_file = (work / 'degs.tsv').write_text('id\tscore\n' + ''.join((f'{s}\t{8 - i}\n' for i, s in enumerate(_degs))), encoding='utf-8')graph = lg.knowledge_graph(str(work / 'targets.json'), organism='Homo sapiens', identifier_namespace='Ensembl gene', subject='target discovery', release='demo 1')
degs = lg.ranked_list(str(work / 'degs.tsv'), organism='Homo sapiens', identifier_namespace='HGNC symbol')
mapping = lg.entity_set(str(work / 'ensembl_to_hgnc.tsv'), organism='Homo sapiens', identifier_namespace='Ensembl gene')
@lg.step
def score(graph: lg.KnowledgeGraph) -> lg.RankedList:
"""Rank nodes by the summed score of the edges they sit on."""
import json
def produce(out: pathlib.Path) -> None:
totals = {}
for edge in json.loads(pathlib.Path(graph.file).read_text())['edges']:
for end in (edge['source'], edge['target']):
totals[end] = totals.get(end, 0.0) + edge['score']
ranked = sorted(totals.items(), key=lambda item: (-item[1], item[0]))
rows = [f'{node}\t{total:.4f}' for node, total in ranked]
out.write_text('id\tscore\n' + '\n'.join(rows) + '\n')
return lg.write(produce)
@lg.step
def shortlist(ranking: lg.RankedList, degs: lg.RankedList) -> lg.RankedList:
"""The genes both rankings name, in the graph ranking's order."""
def produce(out: pathlib.Path) -> None:
def rows(ranked):
lines = pathlib.Path(ranked.file).read_text().splitlines()[1:]
return [line.split('\t') for line in lines]
wanted = {row[0] for row in rows(degs)}
kept = [row for row in rows(ranking) if row[0] in wanted]
out.write_text('id\tscore\n' + ''.join((f'{gene}\t{s}\n' for gene, s in kept)))
return lg.write(produce)
output = shortlist(lg.map_ranked_identifiers(score(graph), mapping, column='symbol', to='HGNC symbol', id_column='id', table_id_column='id'), degs)
pipeline = lg.Pipeline(output)
problems = pipeline.errors()
report = pipeline.run(cache=cache)
print('run:', report.summary)
_written = pathlib.Path(next((s for s in report.steps if s.step == 'shortlist')).output)
rows = [line.split('\t') for line in _written.read_text().splitlines()]
print('the shortlist, as the step wrote it:')
print('\n'.join((' ' + '\t'.join(row) for row in rows[:4])))A result
The pipeline has 3 steps, score,
map_ranked_identifiers and shortlist, and errors() found
0 problems. The run said 3 steps: 3 ran.
shortlist wrote 8 genes, best first, each with the
summed edge score the graph gave it. The first row of data is
GENE10, at 3.6159. That number is what a
manuscript would quote, rounded, and the rest of this page is about
the distance between a sentence that says it and a pipeline that can
prove it.
published = round(float(rows[1][1]), 2)
claim = lg.Claim(text=f"The top candidate's summed edge score is {published}.", step='shortlist', value=published, at=lg.cell(column='score', row=0), tolerance=0.005)
try:
lg.Claim(text=claim.text, step='shortlist', value=published, at=lg.cell(column='score', row=0))
no_tolerance = 'accepted'
except ValueError as refusal:
no_tolerance = str(refusal)
print('the same claim with no tolerance:', no_tolerance)
bound = lg.Pipeline(output, claims=[claim]).methods(cache=cache)
check = bound.claims[0]
print('verdict:', check.verdict)
print('accounted for:', bound.accounted_for)
print('summary:', bound.summary)A sentence bound to a cell
lg.Claim takes the sentence as the paper words it, the step it
comes from, and the cell of that step’s output the number lives in.
This one points at the score column of row 0, which is
GENE10, with value=3.62 and
tolerance=0.005.
The tolerance is the part to read. The step wrote 3.6159, and the paper prints 3.62. Those are not equal byte for byte. For the purposes of the sentence they are equal, because the sentence rounds to two decimals and the difference is 0.0041, inside 0.005. A tolerance states how much precision the sentence claims. The claim written without one is in the printed lines at the end of this page, with the engine’s own words, because a default would invent a precision nobody stated.
The engine read the cell and compared. The verdict is verified, the write-up is accounted for: True, and the claim rests on 1 computation.
The methods paragraph
Methods.text, whole, as the engine wrote it:
Analyses were run with Ligase 0.4.0+56.g4ddca71 on linux-x86_64.
`score` ran on one input, by a function in the pipeline itself.
`map_ranked_identifiers` ran on one input with ligase 0.4.0+56.g4ddca71, by
a function in the pipeline itself, with column = 'symbol', to = 'HGNC
symbol', id_column = 'id' and table_id_column = 'id'.
`shortlist` ran on one input, by a function in the pipeline itself.
References
Njeri K. Ligase: dimension-checked, reproducible computational biology
pipelines (version 0.4.0+56.g4ddca71).
https://github.com/Neoforge-Labs/ligase
Claims
"The top candidate's summed edge score is 3.62." rests on `shortlist`, whose
output gives score = 3.6159 at row 0, within the 0.005 this claim
allows, canonical 815ef02951e7, recorded 22 November 2026 on
linux-x86_64.Its first line, included. That line names the Ligase version and the platform the results were produced on, and the claim at the end carries the date it was recorded. This page is rebuilt on whichever machine builds it, and these lines say which. A methods section records the machine that did the work, so they are left as the engine wrote them.
The record names 1 tool, ligase, and the reference list holds 1 citation. The engine also reports tools it has no citation for, and reports 0 here.
A number the run does not support
The same claim, with the number changed to 4.12, in a
pipeline of its own over the same shortlist. The step still wrote
3.6159. methods() put 1 claim in
unbacked, with the verdict contradicted, and the
write-up is accounted for: False. The good
pipeline above says True.
accounted_for is a plain boolean, and a gate that asserts it
failed here. The engine disagreed with the sentence before any
reviewer read it.
A bundle
methods(bundle=...) wrote 13 files and
accounts for 3 steps and 0 gaps.
This is what a reviewer receives, every path relative to the
bundle’s root:
METHODS.md
README.md
claims.tsv
commands.tsv
environment.tsv
inputs.tsv
notes.tsv
references.tsv
remotes.tsv
results.tsv
steps/map_ranked_identifiers.py
steps/score.py
steps/shortlist.pyReplay
methods(verify=...) takes the bundle and checks it against what
this machine produces, here against an empty cache of its own. It
said 3 results: 3 identical. Reproduced:
True. The worst thing it found is the
verdict identical.
Of the 3 results, 3 have the canonical hash the bundle recorded and 3 also have the same cache key.
What it printed
run: 3 steps: 3 ran.
the shortlist, as the step wrote it:
id score
GENE10 3.6159
GENE01 3.4596
GENE11 3.1056
the same claim with no tolerance: the claim "The top candidate's summed edge score is 3.62." names a cell of the output and no `tolerance=`. State the precision the paper states: a claim to three decimals is `tolerance=5e-4`, and defaulting it would invent a precision nobody wrote
verdict: verified
accounted for: True
summary: 3 steps, all accounted for. 1 claim, all bound.
tools: [('ligase', 'ligase 0.4.0+56.g4ddca71')]
citations: ['Njeri K. Ligase: dimension-checked, reproducible computational biology pipelines (version 0.4.0+56.g4ddca71). https://github.com/Neoforge-Labs/ligase']
uncited: []
verdict: contradicted
the run recorded: 3.6159
accounted for: False
summary: 3 steps, all accounted for. 1 claim: 0 bound, 1 not.
an `assert methods.accounted_for` gate: failed
verification: 3 results: 3 identical.
verdict: identical
reproduced: True
results: [('score', 'identical', True), ('map_ranked_identifiers', 'identical', True), ('shortlist', 'identical', True)]