8000 feat(map): expose --max-sub-occ and --min-sub-occ CLI ablation flags by nh13 · Pull Request #2 · nh13/minibwa · GitHub
[go: up one dir, main page]

Skip to content

feat(map): expose --max-sub-occ and --min-sub-occ CLI ablation flags - #2

Draft
nh13 wants to merge 1 commit into
masterfrom
feat/submem-ablation
Draft

nh13 wants to merge 1 commit into
masterfrom
feat/submem-ablation

Conversation

@nh13
@nh13 nh13 commented Jun 25, 2026
Copy link
Copy Markdown
Owner

Recreated from lh3/minibwa#12, which Heng closed unmerged on 2026-06-15.
Heng's closing rationale: "Always apply two passes as 1-pass only reduces accuracy."
Recreated as a draft in this fork (nh13/minibwa) for continued development and review.


Summary

Exposes the existing Pass-2 sub-SMEM reseeding threshold on the CLI, and adds a symmetric lower-bound knob for ablation studies. No change to default behavior.

What master already does

mb_seed_intv / mb_seed_intv_batch run a two-pass seeding loop. Pass-1 collects standard SMEMs; Pass-2 reseeds inside each Pass-1 SMEM to find shorter sub-SMEMs that could anchor paralog hits. Pass-2 is gated on the Pass-1 SMEM's SA-interval size: a hard-coded opt->max_sub_occ = 10 in options.c skips Pass-2 for any SMEM with size > 10. There was no lower bound, but Pass-1 only appends SMEMs with size > 0, so the effective floor was 1.

What this PR changes

Flag Default Effect
--max-sub-occ N 10 Existing internal threshold, now CLI-exposed. Skip Pass-2 for SMEMs with size > N. N=0 disables Pass-2 entirely (ablation knob).
--min-sub-occ N 1 New symmetric lower bound. Skip Pass-2 for SMEMs with size < N. Default of 1 is a no-op since SMEM sizes are always ≥ 1; intended as an ablation for the "skip Pass-2 on uniquely-anchored SMEMs" hypothesis.

Defaults reproduce master bit-for-bit. Both flags gate on the same SMEM SA-interval size field; symmetric naming reflects that.

Plumbed through the mb_seed_intv / mb_seed_intv_batch signatures (mbpriv.h, seed.c) and the three callers in map-algo.c (mb_map + mb_map_batch) and map-main.c (streaming worker_for_se_batch). CLI option codes are 312 / 313 (310 and 311 are taken by --meth and --hic on this branch).

Follow-up to #10 (Pass-2 sub-SMEM reseeding reduces MAPQ60 recall).

Stacked on #11

This PR is stacked on top of #11 (fix(map): drop is_pe param from mb_map_batch definition + minimal build CI). Once #11 merges, GitHub will retarget this PR onto master automatically. The base branch is fix/mb-map-batch-is-pe-build-break so CI on this PR exercises the ablation feature on top of a buildable tree.

Empirical measurement

WGS-1M R1-only against GRCh38 (1,000,000 SE Illumina reads, hs38 ref, 8 threads):

Pass-2 ON (default) Pass-2 OFF (--max-sub-occ=0) predA (--min-sub-occ=2)
Wall 14.6 s 6.4 s 12.4 s
CPU 54.5 s 33.0 s 39.6 s
shift60 vs ON - 34,675 reads 316 of 34,675 (0.91%)

shift60 = same-placement reads where Pass-2 ON deflates MAPQ from 60 to <60. The lower-bound predicate preserves only 0.91% of those deflations -- the dominant case is "uniquely-seeded SMEM with paralog signal hidden inside it" -- so --min-sub-occ is a measurement knob, not a recommended production setting.

Test plan

  • make and make -C api-test build clean
  • minibwa map --help lists --max-sub-occ=INT [10] and --min-sub-occ=INT [1]
  • On test/chrM-human.fa.gz, output is bit-identical between minibwa map -a and minibwa map -a --max-sub-occ=10 --min-sub-occ=1 (defaults preserve master's behavior; chrM is too small to exercise Pass-2 deflation)
  • Empirical numbers above reproduced from prior implementation
  • CI green on this PR

@nh13 nh13 added the feature review vehicle for a manifest feature; never a merge vehicle label Aug 3, 2026
Add two CLI flags that gate Pass-2 sub-SMEM reseeding (the inner loop
in mb_seed_intv / mb_seed_intv_batch) on the SA-interval size of each
Pass-1 SMEM:

  --max-sub-occ N  (default 10)  upper bound: skip Pass-2 for SMEMs with
                                 occurrence > N (existing internal default,
                                 now user-configurable; N=0 disables Pass-2
                                 entirely)
  --min-sub-occ N  (default 1)   lower bound: skip Pass-2 for SMEMs with
                                 occurrence < N; intended as an ablation
                                 for the "skip Pass-2 on uniquely-anchored
                                 SMEMs" hypothesis

Default values preserve current behavior bit-for-bit (Pass-1 only ever
appends SMEMs with size > 0, so size < 1 never fires). Plumbed through
the mb_seed_intv / mb_seed_intv_batch signatures (mbpriv.h, seed.c) and
the three callers in map-algo.c (mb_map_seq + mb_map_batch) and
map-main.c (streaming worker_for_se_batch).

CLI option codes are 312 / 313 (310 and 311 are taken by --meth and
--hic on this branch). Documented in usage() output. Both flags gate on
the same SMEM SA-interval size field; symmetric naming
(max-/min-sub-occ) reflects that.

Smoke-tested on test/chrM-human.fa.gz: default behavior is bit-identical
whether the flags are omitted or set to their defaults explicitly.

Empirical measurement on WGS-1M R1-only against GRCh38 (1,000,000 SE
Illumina reads, hs38 ref, 8 threads), reproducing the numbers from the
prior implementation on the methylation branch:

                       Pass-2 ON     Pass-2 OFF       predA (size>=2)
                       (default)     (--max=0)        (--min=2)
  Wall                 14.6 s        6.4 s            12.4 s
  CPU                  54.5 s        33.0 s           39.6 s
  shift60 vs ON        -             34,675 reads     316 of 34,675 (0.91%)

shift60 = same-placement reads where Pass-2 ON deflates MAPQ from 60 to
<60. The lower-bound predicate preserves only 0.91% of those deflations
-- the dominant case is "uniquely-seeded SMEM with paralog signal hidden
inside it" -- so --min-sub-occ is a measurement knob, not a recommended
production setting.

Follow-up to issue #10 (Pass-2 sub-SMEM reseeding reduces MAPQ60
recall). Implementation ported from the methylation branch.
@nh13
nh13 force-pushed the feat/submem-ablation branch from 8fb79a9 to 270cd04 Compare August 7, 2026 20:52
@nh13
nh13 commented Sep 4, 2026
Copy link
Copy Markdown
Owner Author

@coderabbitai pause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature review vehicle for a manifest feature; never a merge vehicle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0