docs: rename project to obiskim and expand documentation

Rename the project from "obikmer" to "obiskim" across all documentation, user guides, and developer notes. Add extensive new theoretical and implementation documentation covering chance sharing, sibling partition unification, pair-coverage sampling, MPHF batch queries, merge scaling, and hot resume/memoization. Update navigation structures to reflect these new topics and the new project name.

- Rename "obikmer" to "obiskim" in all HTML titles, headers, navigation labels, and code examples across `DevDoc/` and `doc/` directories.
- Add new navigation links for "Chance sharing across genomes", "Sibling partition unification", "Pair-coverage-biased family sampling", "MPHF batch queries", "Merge mmap audit", "Merge scaling", and "Hot resume and memoization" throughout the documentation site.
- Move `DevDoc/architecture/numa_worker_pools/index.html` to `DevDoc/architecture/hot_resume_memoization/index.html` and update content to focus on hot resume and memoization strategies.
- Move `DevDoc/implementation/evidence_elimination/index.html` to `DevDoc/implementation/merge_mmap_audit/index.html` and update content to detail merge mmap audit findings and plans.
- Move `DevDoc/implementation/superkmer.refs/index.html` to `DevDoc/implementation/merge_scaling/index.html` and update content to discuss merge scaling costs and dependencies.
- Move `DevDoc/theory/indexing/index.html` to `DevDoc/theory/chance_sharing/index.html` and rewrite content to discuss chance sharing across genomes and null models.
- Move `DevDoc/theory/minimizer/index.html` to `DevDoc/theory/sibling_partition_unification/index.html` and update content to discuss sibling partition unification and Can3 masked canonical form.
- Add new `DevDoc/implementation/mphf_batch_queries/index.html` documenting MPHF batch query performance and inventory.
- Add new `DevDoc/theory/pair_coverage_sampling/index.html` documenting pair-coverage-biased family sampling theory and diagnostics.
- Update `DevDoc/architecture/query/index.html` to describe `by_partition` using `Vec<PartitionKmers>` instead of `HashMap` for reduced memory usage.
- Update `DevDoc/implementation/merge/index.html` to describe bootstrap output logic selecting base source by largest `unitigs.bin` size and using `MatrixBuilder::resume`.
- Update `DevDoc/implementation/unitig_evidence/index.html` to change `MAX_KMERS_PER_CHUNK` from 256 to 128 and update rank field documentation.
- Update `DevDoc/implementation/obipipeline/index.html` to reflect that `obiskim` uses `make_pipe!` and `.apply()` instead of `make_pipeline!` / `WorkerPool`.
- Update `DevDoc/implementation/filtering/index.html` to change `FilterArgs` inheritance to `obiskim::cmd::predicate::FilterArgs`.
- Update `DevDoc/implementation/partition_layer_cache/index.html` to reflect new crate dependency structure requiring external reachability for algorithm implementation traits.
- Update `doc/formats/index_layout/index.html` to describe new directory structure for index files including `part_NNNNN/index/layer_X/` and updated merging/packing logic.
- Update `doc/formats/vcf/index.html` to use `obiskim` prefixes for contigs and update VCF header source.
- Update `doc/usage/estimate/index.html` to add "Comparing an index with random sharing" section and clarify `--index` and `--presence-threshold` options.
- Update `doc/usage/phylo/index.html` to clarify that running `obiskim phylo` twice draws independent samples and update `--sibling-annex` behavior.
- Update `doc/usage/select/index.html` to clarify that `select` always writes to a new output directory and explains hard-linking mechanism.
- Add new BibTeX entries for Karlin et al. and Bennett et al. in `doc/references.bib`.
- Delete `scripts/smoke_test_index2.sh` which contained end-to-end smoke tests for `obikmer2 index` and `obikmer query`.
- Update `src/Cargo.lock` to bump "obiskim" package dependency from 1.4.8 to 1.4.9.
This commit is contained in:
Eric Coissac committed 2026-12-02 16:12:54 +01:00
1 parent 917cb26186
commit f1b4b4ebda
102 files changed
+27255 -1226

No files matched your search

+330 -35
View File
@@ -9,10 +9,10 @@
<link rel="prev" href="../indexing/">
<link rel="prev" href="../chance_sharing/">
<link rel="next" href="../../implementation/superkmer/">
<link rel="next" href="../sibling_partition_unification/">
@@ -23,7 +23,7 @@
<title>Central-position SNP distance (discussion) - obikmer</title>
<title>Central-position SNP distance (discussion) - obiskim</title>
@@ -80,7 +80,7 @@
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../.." title="obikmer" class="md-header__button md-logo" aria-label="obikmer" data-md-component="logo">
<a href="../.." title="obiskim" class="md-header__button md-logo" aria-label="obiskim" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
@@ -94,7 +94,7 @@
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
obikmer
obiskim
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
@@ -138,13 +138,13 @@
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../.." title="obikmer" class="md-nav__button md-logo" aria-label="obikmer" data-md-component="logo">
<a href="../.." title="obiskim" class="md-nav__button md-logo" aria-label="obiskim" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
</a>
obikmer
obiskim
</label>
<ul class="md-nav__list" data-md-scrollfix>
@@ -396,6 +396,34 @@
<li class="md-nav__item">
<a href="../chance_sharing/" class="md-nav__link">
<span class="md-ellipsis">
Chance sharing across genomes (discussion)
</span>
</a>
</li>
@@ -791,10 +819,10 @@
</li>
<li class="md-nav__item">
<a href="#step-4-surfacing-obikindex-obikmer-cli" class="md-nav__link">
<a href="#step-4-surfacing-obikindex-obiskim-cli" class="md-nav__link">
<span class="md-ellipsis">
Step 4 — surfacing (obikindex + obikmer CLI)
Step 4 — surfacing (obikindex + obiskim CLI)
</span>
</a>
@@ -1009,6 +1037,17 @@
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#vcf-export-of-the-pseudo-alignment" class="md-nav__link">
<span class="md-ellipsis">
VCF export of the pseudo-alignment
</span>
</a>
</li>
<li class="md-nav__item">
@@ -1031,6 +1070,62 @@
<li class="md-nav__item">
<a href="../sibling_partition_unification/" class="md-nav__link">
<span class="md-ellipsis">
Sibling partition unification (discussion)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../pair_coverage_sampling/" class="md-nav__link">
<span class="md-ellipsis">
Pair-coverage-biased family sampling (discussion)
</span>
</a>
</li>
</ul>
</nav>
@@ -1287,6 +1382,34 @@
<li class="md-nav__item">
<a href="../../implementation/mphf_batch_queries/" class="md-nav__link">
<span class="md-ellipsis">
MPHF batch queries (inventory)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../implementation/unitig_evidence/" class="md-nav__link">
@@ -1483,6 +1606,62 @@
<li class="md-nav__item">
<a href="../../implementation/merge_mmap_audit/" class="md-nav__link">
<span class="md-ellipsis">
Merge mmap audit (2026-11)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../implementation/merge_scaling/" class="md-nav__link">
<span class="md-ellipsis">
Merge scaling (open)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../implementation/filtering/" class="md-nav__link">
@@ -1761,6 +1940,34 @@
<li class="md-nav__item">
<a href="../../architecture/hot_resume_memoization/" class="md-nav__link">
<span class="md-ellipsis">
Hot resume and memoization
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../architecture/numa_worker_pools/" class="md-nav__link">
@@ -2177,10 +2384,10 @@
</li>
<li class="md-nav__item">
<a href="#step-4-surfacing-obikindex-obikmer-cli" class="md-nav__link">
<a href="#step-4-surfacing-obikindex-obiskim-cli" class="md-nav__link">
<span class="md-ellipsis">
Step 4 — surfacing (obikindex + obikmer CLI)
Step 4 — surfacing (obikindex + obiskim CLI)
</span>
</a>
@@ -2395,6 +2602,17 @@
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#vcf-export-of-the-pseudo-alignment" class="md-nav__link">
<span class="md-ellipsis">
VCF export of the pseudo-alignment
</span>
</a>
</li>
<li class="md-nav__item">
@@ -2603,7 +2821,7 @@ implication is that columns should be allowed partial coverage (&gt;=2 resolved
genomes, not unanimous) rather than requiring every genome to be net
single-copy at that locus.</p>
<h2 id="context-detectability-and-a-3-way-ordinal-distance-per-pair">Context, detectability, and a 3-way ordinal distance per pair</h2>
<p>Empirical follow-up to the pseudo-alignment idea above: <code>obikmer phylo
<p>Empirical follow-up to the pseudo-alignment idea above: <code>obiskim phylo
--snp</code> was run on a real 20-genome benchmark index and the resulting FASTA
fed to <code>raxml-ng</code>. Two problems surfaced, both traced back to conflating
distinct notions under one symbol.</p>
@@ -2937,7 +3155,7 @@ before testing it.</p>
informative across domains with this character type. Exploratory only —
run entirely outside the repo (<code>/tmp/tnt_run</code>, TNT installed locally under
<code>TNT/</code>), no new Rust code. Kept here as the record of what was learned.</p>
<p><strong>Pipeline.</strong> <code>obikmer phylo --snp</code> emits one IUPAC-coded pseudo-alignment
<p><strong>Pipeline.</strong> <code>obiskim phylo --snp</code> emits one IUPAC-coded pseudo-alignment
row per genome (<code>snp_pseudo_alignment</code>, one column per family with
<code>family_size() &gt;= 2</code>). A small external Python script decodes IUPAC back to
the 16-state bitmask, applies the set-edit-distance formula above, and
@@ -3001,14 +3219,14 @@ simply does not survive domain-level divergence. Cross-domain placement
would need conserved-marker characters (rRNA, ribosomal proteins), not this
estimator.</p>
<h3 id="native-sankoff-tnt-phyg-export-2026-08-12-superseding-the-external-scripts-above">Native <code>--sankoff --tnt</code>/<code>--phyg</code> export (2026-08-12), superseding the external scripts above</h3>
<p>The ad hoc Python glue from the previous section is superseded: <code>obikmer
<p>The ad hoc Python glue from the previous section is superseded: <code>obiskim
distance --sankoff</code> now calibrates the matrix natively (<code>p_hat</code>, 6-category
substitution costs, <code>c_ctx</code> weighted by <code>mean_sub_cost</code> — see the worked
example above) and <code>--tnt</code>/<code>--phyg</code> each write a ready-to-run script from
it, no external script needed. <code>∅</code> is an ordinary 16th state throughout
(never <code>-</code>), specifically to avoid gap-semantics confusion in downstream
tools — see "A concrete Sankoff cost matrix" above for why.</p>
<p><strong>TNT (<code>--tnt</code>).</strong> <code>write_sankoff_tnt</code> (<code>obikmer/src/cmd/phylo/mod.rs</code>)
<p><strong>TNT (<code>--tnt</code>).</strong> <code>write_sankoff_tnt</code> (<code>obiskim/src/cmd/phylo/mod.rs</code>)
recodes to TNT's own <code>0-9A-F</code> xread alphabet (its default reader rejects
the wider IUPAC set otherwise), scales and rounds costs to integers
(<code>smatrix</code>/<code>cost</code> reject decimals), then re-runs integer Floyd-Warshall on
@@ -3133,7 +3351,7 @@ from the alignment") does <strong>not</strong> work as a shortcut for this — f
custom-file morphology model, <code>readParameters</code> always requires the file's
own frequency line unconditionally; omitting it and passing <code>+F</code> instead
just fails (<code>ERROR: State frequencies could not be read</code>). <code>π</code> has to be
computed by <code>obikmer</code> and written into the file, not left to IQ-TREE.</p>
computed by <code>obiskim</code> and written into the file, not left to IQ-TREE.</p>
<p>Net effect: no free-rate ML estimation needed for this piece at all (the
mistaken assumption that motivated most of this discussion — that
building an asymmetric <code>Q</code> a priori would require solving a linear system
@@ -3203,11 +3421,11 @@ with no error to catch it. <strong>Checked against the real biological alignment
symbol <code>N</code> (IUPAC "all four bases ambiguous," state index 15) occurs 1383
times across 13 of the 20 sequences — present, so this specific real
dataset is not at risk. Still worth a real, general presence check inside
<code>obikmer</code> before this is wired in, rather than assuming every future
<code>obiskim</code> before this is wired in, rather than assuming every future
dataset will have <code>N</code> too (nothing in IQ-TREE would catch it if not).</p>
<p><strong>Resolution: subset + compact-renumber, not rely on all 16 appearing.</strong>
Since IQ-TREE always infers <code>N</code> from the alignment's own content and
nothing overrides that, the fix is to make the file <code>obikmer</code> writes match
nothing overrides that, the fix is to make the file <code>obiskim</code> writes match
that inference <em>by construction</em>, for every run, rather than hope the
16th (or any particular) state happens to occur:
1. Scan the real alignment for which of the 16 canonical states actually
@@ -3255,7 +3473,7 @@ genuine CTMC rate matrix <code>Q</code> could plausibly be recovered as
the stationary-frequency gap above is closed. Superseded by the two
sections below, which implement and then substantially revise this.</p>
<h3 id="r-implemented-exclude-genome-added-rogue-taxon-test-negative-2026-08-12"><code>R</code>/<code>π</code> implemented; <code>--exclude-genome</code> added; rogue-taxon test negative (2026-08-12)</h3>
<p><code>write_iqtree</code> (<code>obikmer/src/cmd/phylo/iqtree.rs</code>) implements exactly
<p><code>write_iqtree</code> (<code>obiskim/src/cmd/phylo/iqtree.rs</code>) implements exactly
the <code>R = exp(-cost)</code> / empirical-<code>π</code> design above: writes
<code>&lt;prefix&gt;_iqtree.model</code> (lower-triangular <code>R</code>, PAML order, then <code>π</code>) and
<code>&lt;prefix&gt;_iqtree.fasta</code> (alignment recoded to the compact <code>0..k-1</code>
@@ -3299,7 +3517,7 @@ tell: with <code>n_eligible=1</code>, the ratio can only be exactly <code>0</cod
3-for-3 landing on <code>0.0</code> is more than sampling noise alone would predict;
possibly ascertainment bias — see below — or possibly a few genuinely
ultra-conserved loci; not resolved).</p>
<p><strong><code>--exclude-genome LABEL</code></strong> (repeatable, <code>obikmer phylo</code>) added for
<p><strong><code>--exclude-genome LABEL</code></strong> (repeatable, <code>obiskim phylo</code>) added for
exactly this kind of test: zeroes the excluded genome's row/column in
<code>RawSnpDistanceOutput</code> after <code>raw_snp_distance</code> runs (a pair with zero
counts is already skipped by <code>calibrate_p_hat</code>/<code>base_pair_tally</code> — no
@@ -3497,7 +3715,7 @@ silently wrong data for TNT/PhyG, and a hard failure for IQ-TREE's <code>+ASC</c
(verified: excluding 2 taxa on the benchmark left 116,351 such columns —
matches the manual <code>+ASC</code> failures hit earlier in this same investigation,
before <code>--exclude-genome</code> existed). Fixed in <code>drop_excluded</code>
(<code>obikmer/src/cmd/phylo/mod.rs</code>): after dropping excluded rows,
(<code>obiskim/src/cmd/phylo/mod.rs</code>): after dropping excluded rows,
re-scan each column among the <em>surviving</em> sequences and drop any that are
now constant. Verified: 908,723 → 792,372 sites after excluding 2 taxa,
zero monomorphic columns remain, <code>π</code> recomputed from the corrected
@@ -3791,7 +4009,7 @@ prescriptions; adjust to reality when implementing.</p>
takes the min by <code>seq_hash()</code> — the same selection <code>RollingStat</code> performs,
evaluated once. Partition index is then
<code>(minimizer.seq_hash() &amp; (n_partitions - 1)) as usize</code>, exactly as
<code>QueryBatch::from_records</code> (<code>obikmer/src/cmd/query.rs:142</code>); <code>n_partitions</code>
<code>QueryBatch::from_records</code> (<code>obiskim/src/cmd/query.rs:142</code>); <code>n_partitions</code>
is a power of two so the mask is valid.</li>
</ol>
<h3 id="step-1-the-tally-accumulator-obikindex">Step 1 — the tally accumulator (<code>obikindex</code>)</h3>
@@ -3903,7 +4121,7 @@ ever queries. Instead: compute it lazily, on first <code>phylo</code> call again
given index, and persist the result alongside that index for subsequent
calls — the same lazy-derived-cache pattern <code>PersistentBitMatrix</code> already
uses for <code>Columnar</code> -&gt; <code>Packed</code>. This requires no explicit invalidation for
<code>merge</code> or <code>filter</code> (<code>obikindex/src/merge.rs</code>, <code>obikmer/src/cmd/filter.rs</code>):
<code>merge</code> or <code>filter</code> (<code>obikindex/src/merge.rs</code>, <code>obiskim/src/cmd/filter.rs</code>):
both only ever write to a fresh <code>--output</code> directory, never mutate an input
index in place, so a re-merged/re-filtered index is simply a new state with
no annex yet. <code>select --in-place</code> (<code>select_layer.rs:139-235</code>) is the
@@ -4096,7 +4314,7 @@ above) is observed anywhere in the index — fixes both:
<code>bitmatrix.rs:264-287</code>); if absent, run step 3 and persist; if present,
mmap and reuse.
5. <strong>Invalidation.</strong> <code>merge</code> and <code>filter</code> always write to a fresh <code>--output</code>
directory (<code>obikindex/src/merge.rs</code>, <code>obikmer/src/cmd/filter.rs</code>) so a
directory (<code>obikindex/src/merge.rs</code>, <code>obiskim/src/cmd/filter.rs</code>) so a
re-merged/re-filtered index simply has no annex yet — nothing to
invalidate. <code>select --in-place</code> (<code>select_layer.rs:139-235</code>) mutates
columns of an existing index without changing its location, which can
@@ -4124,7 +4342,7 @@ accumulated counts (same shape as <code>jaccard_to_mash</code>):</p>
</ul>
<p>Guard the singularities (<code>p &gt;= 3/4</code> for JC, <code>1-2P-Q &lt;= 0</code> or <code>1-2Q &lt;= 0</code> for
K2P) by clamping to a max distance, as <code>jaccard_to_mash</code> clamps <code>J &lt;= 0</code>.</p>
<h3 id="step-4-surfacing-obikindex-obikmer-cli">Step 4 — surfacing (<code>obikindex</code> + <code>obikmer</code> CLI)</h3>
<h3 id="step-4-surfacing-obikindex-obiskim-cli">Step 4 — surfacing (<code>obikindex</code> + <code>obiskim</code> CLI)</h3>
<p>These metrics do not fit <code>DistanceMetric</code>'s current <code>LayeredStore</code>-partial
dispatch (they need the cross-partition sweep and produce a different
intermediate). Two options, to decide:</p>
@@ -4163,7 +4381,7 @@ lookups proportionally; <code>p_hat</code> is unbiased. Off by default (exact).<
<ol>
<li>Step 0 primitives + their unit tests (self-contained, no distance wiring).
This also unblocks the long-declared-but-unimplemented <code>query --mismatch</code>
(<code>obikmer/src/cmd/query.rs:676</code>, currently a warning), which needs the same
(<code>obiskim/src/cmd/query.rs:676</code>, currently a warning), which needs the same
neighbour + routing machinery.</li>
<li><code>SnpTally</code> + finalisation math with a brute-force (non-swept) reference
backend, validated on a tiny index.</li>
@@ -4209,7 +4427,7 @@ tree weakly — will likely need a minimum-detected-loci-per-genome filter
upstream (exclude or flag under-covered genomes) before this becomes a
correctness problem rather than a power problem. Not designed yet.</p>
<h3 id="-free-loss-implemented-2026-08-13"><code>--free-loss</code> implemented (2026-08-13)</h3>
<p><code>obikmer phylo --sankoff --free-loss</code> (with <code>--tnt</code>/<code>--phyg</code>/<code>--iqtree</code>)
<p><code>obiskim phylo --sankoff --free-loss</code> (with <code>--tnt</code>/<code>--phyg</code>/<code>--iqtree</code>)
recodes <code>∅</code> (a family's non-detection in a genome) to <code>?</code> instead of the
default ordinary, costed 16th state — the resolution of the discussion
above. <code>?</code>, not <code>-</code>: <code>-</code> still carries gap/indel semantics in TNT/PhyG/
@@ -4284,7 +4502,7 @@ filtered alignment — next verification step, alongside the still-open PhyG
<p><strong>Diagnostic added: <code>--family-overlap</code>.</strong> Real per-genome-pair count of
shared variable families (columns where neither genome is <code>∅</code>), diagonal
kept (degenerates to "genome's own total family count", not a separate
computation — see <code>obikmer/src/cmd/phylo/family_overlap.rs</code>). On the
computation — see <code>obiskim/src/cmd/phylo/family_overlap.rs</code>). On the
20-genome benchmark this predicted the <code>--tnt</code>/<code>--iqtree</code> rogue-placement
pattern exactly: Candidozyma shares <strong>0</strong> families with all 19 others (hence
its ~0-length branch, placed anywhere); the mean off-diagonal shared-family
@@ -4345,13 +4563,13 @@ it stores) from a run on one taxon set against a regenerated <code>iqtree.fasta<
with a different taxon count crashes with <code>Assertion 'i &gt;= 0 &amp;&amp; i &lt;
(int)seq_names.size()' failed</code> in <code>Alignment::getSeqName</code> /
<code>PhyloTree::assignLeafNames</code> — <code>--undo</code> tries to graft a stored tree with
the old leaf count onto the new, smaller alignment. Not an <code>obikmer</code> bug;
the old leaf count onto the new, smaller alignment. Not an <code>obiskim</code> bug;
avoid by using a fresh <code>--prefix</code> (or <code>-redo</code>) whenever the underlying
alignment's taxon set changes, never <code>--undo</code> across them.</p>
<h2 id="_iqtree_statescsv-compact-symbol-traceability-2026-08-15"><code>_iqtree_states.csv</code>: compact-symbol traceability (2026-08-15)</h2>
<p>User-reported suspicion: <code>--iqtree --free-loss</code> state frequencies "don't
sum to 1". Verified both by code trace and unit test
(<code>obikmer/src/cmd/phylo/iqtree.rs</code>, <code>free_loss_excludes_absent_state_and_freq_sums_to_one</code>)
(<code>obiskim/src/cmd/phylo/iqtree.rs</code>, <code>free_loss_excludes_absent_state_and_freq_sums_to_one</code>)
— <strong>not a bug</strong>: <code>compact_alphabet</code>'s counting loop <code>continue</code>s on
<code>free_loss &amp;&amp; b == b'-'</code> <em>before</em> recoding/counting, so the absent state
never enters <code>occurs</code>/<code>counts</code>, and <code>freq[i] = counts[old]/total</code> sums to
@@ -4435,7 +4653,7 @@ multi-base states too — biologically, a family showing 3–4 simultaneously
observed central bases across genomes is far more likely to be
assembly/detection noise than a genuinely ancestral, widely-preserved
polymorphism, the same reasoning already used for <code>-</code>.</p>
<p><strong>Mechanism</strong> (<code>obikmer/src/cmd/phylo/iqtree.rs</code>, <code>write_iqtree</code>): a
<p><strong>Mechanism</strong> (<code>obiskim/src/cmd/phylo/iqtree.rs</code>, <code>write_iqtree</code>): a
<em>second</em> filtering pass, active only under <code>--free-loss</code>. After the first
<code>compact_alphabet</code> call (post ascertainment-filtering), any state with
<code>freq &lt; --iqtree-min-freq</code> (default <code>0.001</code>) has every occurrence recoded
@@ -4934,7 +5152,7 @@ generally (the same mechanism as <code>corrected_log</code>, not a coincidence
Nei's own formula is the <code>θ=0</code> special case applied to a pairwise <code>D</code>
rather than a whole-tree one). Explicitly stated by the authors as
infeasible beyond about 5–6 taxa (their own simulations stop at 5); not a
candidate for obikmer's typical genome counts. Notable contribution worth
candidate for obiskim's typical genome counts. Notable contribution worth
keeping in mind regardless: <code>ρ = (1+θα)/(1+α)</code> is shown to be a more robust
summary of rate heterogeneity than <code>α</code> alone whenever <code>θ</code> isn't negligible
— <code>α</code> and <code>θ</code> are confounded (nearly-invariant sites can come from either a
@@ -4955,7 +5173,7 @@ not a closed form; (4) the site-level <code>k̂</code> values (real-valued, not
integers) are fit to a negative binomial (Uzzell &amp; Corbin 1971) by ML to
get α — again no closed form, numerical optimization. This is a real
per-site pipeline requiring a tree <em>before</em> distances/α can be computed —
the reverse of obikmer's current dependency order (<code>snp_distance</code> computes
the reverse of obiskim's current dependency order (<code>snp_distance</code> computes
distances, which <code>--nj</code>/<code>--upgma</code> only turn into a tree <em>afterward</em>). Their
own answer to this chicken-and-egg problem is an iterative
distance→tree→α→distance loop, which they themselves flag as expensive.
@@ -5018,7 +5236,7 @@ proper is judged not worth the effort).</p>
<p><strong>Correctness bug, not just a performance one.</strong> <code>--sankoff</code>/<code>--tnt</code>/<code>--phyg</code>/
<code>--iqtree</code> (via <code>SiblingExt::sankoff_bundle</code>) and a <code>snp-*</code> <code>--distance</code>
(via <code>SiblingExt::snp_distance</code>) always consume the <em>exact same</em> selection
parameters when requested together in one <code>obikmer phylo</code> invocation
parameters when requested together in one <code>obiskim phylo</code> invocation
(<code>n</code>/<code>free_loss</code>/<code>no_ambiguity</code>/excluded-set/<code>entropy_bias</code> — the CLI has
no way to give them different values in one run, see <code>cmd/phylo/args.rs</code>).
Before this fix, each independently called <code>sample_index</code>, and
@@ -5057,7 +5275,7 @@ the same tiny test index.</p>
<code>--session DIR</code> (<code>cmd/phylo/args.rs</code>) names a directory (outside the
index) that persists the <code>snp-*</code> <code>--distance</code> sample — the
<code>PairwiseTally</code>/<code>PartitionDispersion</code> pair <code>sample_index</code> would otherwise
rebuild from scratch — across <em>separate</em> <code>obikmer phylo</code> invocations.</p>
rebuild from scratch — across <em>separate</em> <code>obiskim phylo</code> invocations.</p>
<p><strong>Crate placement, as planned</strong>: a new <strong><code>obiksession</code></strong> crate
(<code>src/obiksession/</code>), domain-agnostic — no <code>PairwiseTally</code>/"site" concept
anywhere in it. <code>Session::open(dir, params: &amp;[u8], force: bool)</code> handles
@@ -5194,6 +5412,83 @@ the new <code>snp-*</code> ones — accepted explicitly (pre-release, single dev
user, no external consumers to break). Scoped to the distance matrix only:
<code>--shared-kmers</code> and <code>--raw-snp-counts</code> are counts, not distances, and keep
their existing CSV-only format.</p>
<h2 id="vcf-export-of-the-pseudo-alignment">VCF export of the pseudo-alignment</h2>
<p><code>phylo --vcf</code> writes the drawn sites of <code>--pseudo-alignment</code> as a VCF
(<code>--fasta</code>/<code>--vcf</code> choose the formats, FASTA is the default, both can be
combined). A family has no genomic coordinate, so coordinates are virtual and
derived from where the scan finds the family: <code>CHROM = obiskim_&lt;partition&gt;_&lt;layer&gt;</code>,
<code>POS = family_idx + 1</code> (<code>scan_layer_families</code>' iteration-order index inside
that layer). Stable for a given index + annex, sorted by construction because
<code>on_family</code> is replayed in <code>family_idx</code> order. A global dense rank or a bit
packing of (layer, partition, idx) into one <code>POS</code> was rejected: it needs
per-layer minorant counts and can exceed VCF's 2^31-1 bound.</p>
<p><code>ID</code> is <code>CanonicalKmer::family_id()</code>: centre forced to <code>A</code> on the
k-mer and on its revcomp, each canonicalised, minimum of the two (centre
printed as <code>N</code>). Index-independent, hence the key for merging VCFs from
different indexes. No <code>INFO/LOCUS</code> duplicate (dropped: same string as <code>ID</code>, costly
at 5M loci); <code>QUAL</code>/<code>FILTER</code>/<code>INFO</code> are all <code>.</code>. An alternative defined as the minimum of
<code>central_canonical_neighbors()</code> was dropped: it canonicalises 4 k-mers where
this one needs 2, with no other benefit. <code>family_id</code> idempotence and
family-wide equality are tested exhaustively for k = 3, 5, 7.</p>
<p><code>SurvivingFamily</code> now carries the minorant k-mer (the scan callback passes it),
and <code>SnpAlignment</code> a <code>SiteLocus</code> per column. Alleles are the unambiguous cells
of the IUPAC matrix, in the FASTA's convention (central base of the member's
canonical form, not necessarily the <code>ID</code> k-mer's strand).</p>
<p>Absence handling. <code>masked_state</code> keeps absence (<code>m == 0</code>, <code>-</code>) as a real state
unless <code>--free-loss</code>, where it becomes missing (<code>?</code>). A first version mapped
<code>-</code> and <code>?</code> both to <code>.</code>: on a toy 4-genome index half of the lines then had
<code>ALT = .</code> (presence/absence-only sites, selected by <code>survives_masking</code>), i.e.
polymorphic sites rendered as monomorphic. Absence became an extra allele,
first written <code>*</code>; that was a misuse: in VCF 4.5 (section on the ALT column)
<code>*</code> is "allele missing due to overlapping deletion", and <code>&lt;*&gt;</code> is the gVCF
unspecified allele, <code>DEL</code>/<code>INS</code>/<code>DUP</code>/<code>INV</code>/<code>CNV</code> are structural-variant
types. Now the symbolic allele <code>&lt;ABS&gt;</code> (free-form ID, declared by a
<code>##ALT=&lt;ID=ABS,...&gt;</code> line, always written in the header, listed after the
bases); <code>?</code> and IUPAC ambiguity codes stay <code>.</code> (haploid GT cannot express a
genome carrying several forms; superseded below). A symbolic ALT formally
asks for a padding base before <code>POS</code>; moot here, positions being virtual.
Checked with <code>bcftools view</code>/<code>stats</code> and <code>tabix</code>: no warning, the sites with
<code>&lt;ABS&gt;</code> are classed "others" by <code>bcftools stats</code>, and
<code>-e 'ALT="&lt;ABS&gt;"'</code> drops exactly them. The writer needs no knowledge of
<code>--free-loss</code>: <code>-</code> simply never occurs with it. A reference-genome option
(<code>--vcf-ref</code>) was implemented then dropped: <code>REF</code> is always the per-site
majority base (alphabetical on ties).</p>
<p>Ploidy. VCF allows any ploidy in <code>GT</code> (number of alleles written, variable
per sample/site), but an obiskim cell only says <em>which</em> forms a genome
carries, not their multiplicity (<code>A/A/G</code> and <code>A/G/G</code> are both <code>R</code>), nor
whether several forms mean heterozygosity or paralogues. Compromise chosen:
<code>--no-ambiguity</code> =&gt; haploid (ambiguous cells are already <code>?</code>); otherwise
diploid, single base <code>X</code> -&gt; <code>X/X</code>, two-base code -&gt; <code>X/Y</code>, <code>-</code> -&gt; <code>&lt;ABS&gt;/&lt;ABS&gt;</code>, and
three/four-base codes or <code>?</code> -&gt; <code>./.</code>. <code>REF</code> is the majority allele counting
each copy once (so a het contributes 1+1, a homozygote 2). Counting copies
for a real dosage (polyploids) would need k-mer counts (<code>--with-counts</code>),
not used by the pseudo-alignment scan today. <code>--only-diploid</code> (selection option, <code>conflicts_with --no-ambiguity</code>) adds a
third <code>masked_state</code> rule: <code>count_ones() &gt; 2</code> -&gt; missing. It lives in
<code>SamplingSpec</code>/<code>masked_state</code>, i.e. the post-hoc masking and
<code>survives_masking</code>, so FASTA, Sankoff and <code>snp-*</code> see it too. Unit-tested
(<code>masked_state</code>); the toy index has no 3/4-member cells, so the end-to-end
run is identical to the default mode.</p>
<p>First version of this flag read the persisted annexes under the default
convention (a third variant was judged not worth it). Rejected: the draw
would then describe other genomes than the alignment, and the pair-balance
weights and entropy are computed from the carrier set. Replaced by
<code>AmbiguityPolicy { Keep, Forbid, OnlyDiploid }</code> (one type instead of
<code>free_loss</code>/<code>no_ambiguity</code>/<code>only_diploid</code> booleans in <code>masked_state</code>,
<code>is_carrier</code>, <code>SamplingSpec</code> and every annex key). Annex headers store
<code>AmbiguityPolicy::header_flags</code> (0 = Keep, 1 = Forbid, as the old bit, 2 =
OnlyDiploid), so annexes written before the change stay valid; each policy
has its own file (<code>*.diploid.*</code> for the new one). <code>--sibling-annex</code> no longer
precomputes everything (<code>AnnexRequest::everything</code> removed, a rebuild only
costs the base annex): it builds the derived annexes named by the other
options of the command (<code>AnnexSelection</code>: <code>--entropy</code>, <code>--quartet</code>,
<code>--pair-balance</code>, <code>--family-overlap</code>/<code>--min-shared-family</code>, under the one
policy given); the rest is built on demand as before. A rebuild still drops
every derived annex (their <code>family_idx</code> numbering is tied to the base one).
Checked on the toy index: <code>--sibling-annex</code> alone leaves only
<code>siblings.psib</code>; <code>--quartet --only-diploid</code> adds <code>quartet.diploid.pbiv</code> only.
Toy index: default mode 187
lines, no <code>ALT = .</code>; <code>--no-ambiguity</code> 93 lines (the sites whose polymorphism
was only ambiguity codes disappear, since those cells became <code>?</code>).</p>
<h2 id="references">References</h2>
<p>The Mash mutation-rate model this discussion contrasts with:
(Fan <em>et al.</em> 2015; Marbl Lab 2026)<sup id="fnref:Mash-distances-doc"><a class="footnote-ref" href="#fn:Mash-distances-doc">1</a></sup> <sup id="fnref:Fan2015-mash-formula"><a class="footnote-ref" href="#fn:Fan2015-mash-formula">2</a></sup>.</p>