Skip to content

Revision 1 - #2

Merged
ayobi merged 18 commits into
mainfrom
revision-1
Oct 8, 2026
Merged

ayobi merged 18 commits into
mainfrom
revision-1

Conversation

@ayobi

@ayobi ayobi commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Changes made in response to peer review of the SSUplex application note.

Behaviour changes

  • Default ranking statistic is now sum (previously mean). On noisy Nanopore reads, the mean (also the default of Metaxa2's HMM-based step) assigned many bacterial reads to chloroplast or mitochondria. The sum is the only statistic above 95% accuracy on every labelled dataset. --rank mean keeps the previous behaviour. Accuracy against known origins (HMMER 3.4, Metaxa2 2.2.3):

    Dataset Metaxa2 HMM stage Metaxa2 with BLAST SSUplex sum SSUplex mean SSUplex count
    Metaxa2 test file (50 SSU) 96.0% 100% 96.0% 96.0% 66.0%
    Metaxa2 reference set (500) 94.8% 99.8% 95.6% 96.8% 79.2%
    ZymoBIOMICS ONT (5,000) 54.9% 99.96% 95.9% 43.0% 95.7%

    On the rice-root sample, which has no per-read truth, sum agrees with Metaxa2's BLAST-assisted calls on 96.8% of reads (mean: 64.5%). Sum's weakness, documented in the README, is organellar reads that also match bacterial profiles. Metaxa2's normalised sum was also evaluated and not adopted (details in dev/BENCHMARK.md).

  • Overwrite protection. SSUplex previously truncated existing output files without warning. It now stops if any output for the given prefix exists; --force replaces them, including per-origin files and debug tables the new run would not write. Old files are removed only after the scan succeeds. Scripts that reuse a prefix will need --force.

  • nhmmer alphabet. SSUplex now passes --dna to nhmmer. Without it, nhmmer guesses the alphabet of each chunk of reads; the guess fails on chunks of very short or low-complexity reads, which aborted the whole run.

Build and dependencies

  • Declare rust-version = "1.85". The locked dependencies (clap 4.6, getrandom 0.4) need it; the README said 1.74, and builds with 1.75 fail.
  • Remove the unused thiserror dependency.

Help text and code comments

  • Help texts and doc comments now describe what each option does, without embedded benchmark numbers or development instructions.
  • Corrected: input is held in memory, not streamed; --min-score applies to the chosen origin's mean score; gzip input is accepted; --debug-scores also writes regions.tsv.
  • --threads no longer prints a machine-dependent default in --help.

Benchmark harness (dev/)

  • run_real_data.sh: the accuracy benchmark on Metaxa2's test.fasta, the Metaxa2 reference set, and the ZymoBIOMICS and rice-root reads, in one command.
  • run_benchmark.sh: one Metaxa2 run gives both its HMM-stage origin and its BLAST-assisted final origin. SSUplex runs with --rank mean, sum and count, and tool versions are recorded.
  • score_origins.py (replaces compare_origins.py): identical definitions for every method; confusion matrices against truth, with unclassified reads counted as errors; negatives scored separately; agreement with both Metaxa2 stages; breakdown of reads where the ranking statistics disagree.
  • compare_rank_rules.py: compares ranking rules offline on the hits from a benchmark run, after checking it reproduces SSUplex's own calls.
  • run_timing.sh, peakmem.py, plot_timing.py: wall time and peak memory for both tools across input sizes, with replicates. Memory is measured over the whole process tree, because /usr/bin/time reports only the largest single process. Only measured points are plotted.
  • fetch_ena_reads.sh: downloads the first N reads of an ENA run, with progress output.
  • assemble_metaxa2_hmms.sh: now a plain concatenation that runs on the bash shipped with macOS.
  • The documented environment runs Metaxa2 2.2.3 from its official download, so that Metaxa2 and SSUplex share one HMMER 3.4 build. Metaxa2's Bioconda package requires HMMER 3.1 and cannot be installed alongside 3.4.
  • Removed the exploratory margin-analysis scripts.

Documentation

  • README rewritten:
    • Bioconda install first, then from source with cargo install --locked.
    • A quick start that runs on test.fasta from the Metaxa2 download, with the expected per-origin counts.
    • Output files and the full option list.
    • How the ranking statistics work, why sum is the default, and where it errs.
    • An accurate description of Metaxa2 (-x T runs extraction alone).
    • Scope and limitations.
    • Removed: the download-count badge.
  • dev/BENCHMARK.md: protocol, accuracy results, and the reasoning for the default ranking statistic.
  • CHANGELOG.md added.

CI

  • fmt and clippy.
  • Build with Rust 1.85.
  • Tests and dev/smoke.sh on Linux and macOS. The smoke test now also covers overwrite protection and very short reads.
  • A job that runs the README install and quick start verbatim and checks the option list against ssuplex -h. It downloads Metaxa2 2.2.3 from microbiology.se for the HMM profiles and test file.

Testing

  • fmt and clippy clean; unit, integration and smoke tests pass; builds with Rust 1.85 and 1.91. A unit test checks the default ranking statistic.
  • The short-read smoke check fails without the --dna fix and passes with it.
  • dev/run_real_data.sh on the original benchmark workstation (AMD Ryzen 9 9950X) reproduces the previously published accuracy figures exactly, which confirms the datasets match.

Before merging

  • Evaluate the ranking statistics and decide the default
  • Accuracy results in dev/BENCHMARK.md
  • Independent simulated truth set (held-out check of the default)
  • Timing sweep with process-tree memory (running)
  • Add timing results to dev/BENCHMARK.md and the README
  • Bump to 0.2.0, tag a release, archive on Zenodo, update the Bioconda recipe

Aaron O'Brien added 18 commits October 5, 2026 18:52
…sion 1.85

SSUplex used to truncate existing output files silently. It now stops with
an error when any output for the prefix exists, and --force replaces them,
also removing per-origin FASTAs and debug tables a new run would not write.
Old files are removed only after the scan succeeds.

Also: drop the unused thiserror dependency, declare rust-version = 1.85
(the locked clap 4.6 and getrandom 0.4 need it; README said 1.74), correct
the main.rs comment that described input as streamed, and extend
dev/smoke.sh with end-to-end overwrite checks.
…criptions

Help texts and doc comments no longer embed benchmark numbers or
claims about which ranking statistic is better (those now live in
dev/BENCHMARK.md), no longer describe input as streamed, document that
--min-score applies to the chosen origin's mean score, mention gzip input
and the regions table written by --debug-scores, and note how the ranking
options relate to Metaxa2's --selection_priority.
- run_benchmark.sh runs Metaxa2's full pipeline by default, so one run gives
  both its HMM-stage and its BLAST-assisted final origin (--m2-mode extract
  runs -x T), runs SSUplex with mean, sum and count, records tool versions,
  checks for nhmmer (the tool SSUplex calls), and names the Bioconda package
  correctly (metaxa).
- score_origins.py replaces compare_origins.py: identical definitions for all
  methods, confusion matrices against truth with unclassified reads counted
  as errors, negatives scored separately, agreement with both Metaxa2 stages,
  and a breakdown of reads where the ranking statistics disagree.
- run_timing.sh, peakmem.py and plot_timing.py measure wall time and peak
  memory over the whole process tree for both tools across input sizes with
  replicates, and plot measured points only.
- assemble_metaxa2_hmms.sh is now a plain concatenation that runs on the
  bash shipped with macOS.
- Remove the exploratory margin-analysis scripts.
README: Bioconda install first; from source with cargo install --locked
(Rust 1.85+); HMM profiles; a quick start that runs on test.fasta from
the Metaxa2 download, with the expected result; output files; the full
option list (checked against ssuplex -h in CI); how the ranking
statistics work and relate to Metaxa2's --selection_priority; an accurate
description of Metaxa2 (-x T runs extraction alone); scope and
limitations. Removes the download-count badge and the benchmark numbers
that are being re-measured.

dev/BENCHMARK.md is now a protocol: software environment, datasets and
truth tables, commands, and metric definitions. dev/README.md indexes the
scripts. Adds dev/fetch_ena_reads.sh.

CI: fmt and clippy; build with Rust 1.85; tests and dev/smoke.sh on Linux
and macOS; and a job that installs and runs the README quick start
verbatim and checks the option list. --threads no longer prints a
machine-dependent default in --help.
nhmmer guesses the alphabet of each chunk of reads; on a chunk of very
short or low-complexity reads the guess fails and SSUplex aborted the
whole run. SSUplex now states the alphabet. dev/smoke.sh checks that a
file of 8 bp reads completes with every read unclassified (it failed
before this change).

dev/run_real_data.sh runs the accuracy benchmark on Metaxa2's test.fasta,
the Metaxa2 reference set, and the first N ZymoBIOMICS and rice-root
reads in one command, and collects the reports.
…vironment

Metaxa2's Bioconda package requires HMMER 3.1 and cannot be installed
alongside HMMER 3.4, even with --no-deps under the libmamba solver. The
benchmark environment now runs Metaxa2 2.2.3 from the official download,
which uses the environment's HMMER 3.4 and legacy BLAST.
On noisy Nanopore reads the mean, which is also the default of Metaxa2's
HMM-based step, assigned many bacterial reads to chloroplast or
mitochondria (ZymoBIOMICS: 43.0% for SSUplex mean, 54.9% for Metaxa2's
HMM stage). The sum is the only statistic above 95% on every labelled
dataset and agrees with Metaxa2's BLAST-assisted calls on 96.8% of the
rice-root reads. --rank mean keeps the previous behaviour.

- README: ranking section explains the default and its weakness
  (organellar reads that also match bacterial profiles), the quick start
  gives the expected per-origin counts, Metaxa2 differences and
  limitations updated, option list regenerated.
- dev/BENCHMARK.md: accuracy results, rice composition, and why the
  default and the normalised-sum alternatives were or were not chosen.
- dev/compare_rank_rules.py: offline comparison of ranking rules from the
  hits of a benchmark run, validated against SSUplex's own calls.
- dev/fetch_ena_reads.sh prints progress and no longer shows curl's
  expected write error; dev/run_timing.sh checks its inputs first;
  make_truth_set.py no longer prints instructions.
- CHANGELOG.md.
…peline

Linear time and memory axes squeezed the small input sizes against zero
and made linear scaling look curved. The Metaxa2 series is now labelled
as extraction only, colours are colour-blind safe, and --full overlays a
run_timing.sh --m2-mode full result as a third series.
Labelled reads for all five origins from sequences outside the Metaxa2
database, at three long-read accuracies:

- fetch_sources.sh downloads SILVA 138.2 SSU/LSU Ref NR99 and the RefSeq
  mitochondrion and plastid genome releases, recording the RefSeq release.
- build_sources.py takes bacteria, archaea and nuclear eukaryota from
  SILVA (organelle-labelled entries excluded) and mitochondrial and
  chloroplast SSU genes from RefSeq annotations; drops accessions in the
  Metaxa2 database and duplicate sequences; finds each candidate's closest
  Metaxa2 sequence with vsearch and samples evenly across three novelty
  bands; adds LSU and shuffled negatives.
- simulate_reads.py makes full-length reads from either strand with
  Badread's nanopore2020, nanopore2023 and pacbio2021 error models, used
  as a library so reads keep their full length; seeded and reproducible
  regardless of thread count.
- score_by_band.py reports recall by origin and novelty band, metazoan and
  non-metazoan mitochondria, negatives, and expected accuracy and
  organellar share for a bacteria-dominated and a plant-root-like mix.
- run_simulation.sh runs everything and resumes where it stopped.

README: scope states the long-read focus; short and shotgun reads run but
are not benchmarked. BENCHMARK.md describes the design.
- BENCHMARK.md: measured run time, process-tree memory and CPU time up to
  1,000,000 reads, Metaxa2's full pipeline at 5,000 and 25,000 reads, and
  which runs were repeated and why.
- plot_timing.py: legend above the panels so it cannot cover data, open
  markers for the full-pipeline series (its memory coincides with -x T),
  and --metaxa2-label; run_timing.sh passes the right label for
  --m2-mode full, whose own figure called it extraction only.
conda is normally a shell function, which a script started with nohup
does not inherit, so 'conda run' failed and the script wrongly reported
the simulation environment as missing. It now uses the executable conda
records in CONDA_EXE, and reports a missing environment, a failed import
and a missing vsearch separately.
supplementary_tables.py writes the supplementary tables as LaTeX from
the benchmark outputs: confusion matrices for every labelled dataset and
method plus the rice-root comparison (S1); the reads on which mean, sum
and count disagree, with the median region count, mean and summed score
of the origins each statistic chose (S2); and the simulated benchmark by
read accuracy, origin and novelty band (S3).
The SILVA LSU export downloads at tens of KB/s from some locations. The
negatives only need to be non-SSU, not independent of Metaxa2, so the
simulation now dumps them from the LSU database in the Metaxa2 download
(fastacmd), and downloads SILVA's LSU set only when that database is
missing (fetch_sources.sh --with-silva-lsu). build_sources.py takes any
LSU FASTA via --lsu and records its source in negatives.tsv.
At tens of KB/s, the several GB of RefSeq organelle genome files would
take days to download. Mitochondrial and chloroplast sources now come
from SILVA 138.2 SSU Ref NR99 entries labelled as such, from the file
already needed for the other origins, so the simulation needs no further
downloads. --organelles refseq keeps the RefSeq-annotation route.
fetch_sources.sh downloads RefSeq only with --with-refseq, and no longer
fails when no RefSeq files are present.
The source builder treated any SILVA taxonomy containing the substring
'Chloroplast' as a chloroplast, which also caught nuclear 18S from the
eukaryotic lineage Chloroplastida (green algae and land plants). In the
first simulated run, about 60% of the 'chloroplast' sources were such
eukaryotes, and every method, Metaxa2 with BLAST included, correctly
called them eukaryota. Chloroplast and mitochondria are now recognised
only as whole rank names under Bacteria, so Chloroplastida stays in the
eukaryotic pool (from which the older code had also wrongly excluded it).
dev/BENCHMARK.md reports the corrected simulated run: per-origin recall
for every method at three read identities, the summed score's weakness on
organelles, Metaxa2's drop on novel mitochondria, and composition-weighted
accuracy, on which the summed score remains the better default. README
gives the simulated organelle losses and when --rank mean is worth using.
supplementary_tables.py --sim now writes Table S3 as recall by read
identity, origin and novelty band plus expected results for a
bacteria-dominated and a plant-root-like composition.
Raise the version to 0.2.0, date the changelog, and add CITATION.cff
(read by GitHub and Zenodo; preferred citation is the preprint).
BENCHMARK.md notes that the benchmark logs report 0.1.0 because the runs
predate the version bump; src/ is unchanged since then.
@ayobi
ayobi marked this pull request as ready for review October 8, 2026 18:57
@ayobi
ayobi merged commit cfe2c0c into main Oct 8, 2026
5 checks passed
@ayobi
ayobi deleted the revision-1 branch October 8, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant