Skip to content

Warn about an index without gene groups at index and map time - #40

Merged
rob-p merged 1 commit into
mainfrom
geneless-index-warning
Nov 14, 2026
Merged

rob-p merged 1 commit into
mainfrom
geneless-index-warning

Conversation

@rob-p

@rob-p rob-p commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

A candidate for 0.3.0. spearfish now warns, at index time and at map time, when an index has no gene groups, and the library and Python API say whether an index has them.

An index has no gene groups when every transcript is its own gene. This happens when the FASTA headers carry no gene IDs (a RefSeq FASTA, for example) and neither --t2g nor --infer-genes was given. spearfish keeps a few candidate genes per read, so the isoforms of a gene then compete for those places one by one, and ties among them are broken by FASTA order. This costs accuracy (see the indexing guide for the numbers on GENCODE).

Until now:

  • spearfish index warned, but in its summary, which -q hides;
  • spearfish map said nothing, so an index built earlier, or by someone else, gave no sign.

Behaviour

Index time. The warning is printed after the summary, and also under -q:

warning: the index has no gene groups: every transcript is its own gene (the FASTA headers carry no gene IDs, and neither --t2g nor --infer-genes was given). spearfish keeps a few candidate genes per read, so isoforms then compete for those places one by one and ties among them go by FASTA order, which costs accuracy; give --t2g FILE (a transcript-to-gene table) or --infer-genes

The summary also says isoforms not collapsed: every transcript is its own gene (with --collapse gene), in place of the old in-summary warning.

Map time. Once per run, right after the index is loaded, also under -q:

warning: the index transcripts.sfi has no gene groups: every transcript is its own gene (...). spearfish keeps a few candidate genes per read, ...; rebuild it with --t2g FILE (a transcript-to-gene table) or --infer-genes

Detection. An index of two or more transcripts has no gene groups when its manifest says genes_from: none, or when it has as many genes as transcripts. The second case also covers a --t2g table that puts each transcript in its own gene, gene inference that grouped nothing, and indexes without a manifest. The cause and the fix in the message follow genes_from.

Run record. *.meta.json gains a top-level warnings list, with entries {"code": "no_gene_groups", "message": "..."}. The key is left out when there are no warnings, so records of other runs are unchanged.

Library and Python.

  • Index::has_gene_groups() and Index::n_genes();
  • spearfish::has_gene_groups(genes_from, transcripts, genes), for a build report or a manifest alone;
  • Python: Index.has_gene_groups. Index.num_genes now uses the library's n_genes.

oarfish can use these to warn too.

Mapping output is unchanged.

Implementation notes

  • -q: until now every warning went through log::warn!, which -q hides, so there was no precedent. logging::warn_always (CLI) writes a warning at every level, in the same format and colour. It is meant only for problems with the inputs that change the results; advice and ignored options stay on log::warn!.

  • Message: index_cmd::no_gene_groups_warning(genes_from, index) builds the text for both commands.

  • Index time: the old condition skipped --infer-genes and --collapse global. The new one does not, since the candidate limits act per gene either way.

  • Python index-time warning: the wording follows the CLI's. It still goes through log::warn! (Python logging), and no longer depends on collapse.

  • Docs:

    • the indexing guide ("Gene membership") explains the warning, shows it, and recommends --t2g or --infer-genes;
    • the output guide documents warnings in the run record;
    • the mapping guide notes that -q still shows this warning.
  • CHANGELOG: an entry under ## 0.3.0 (unreleased). This branch is based on main, where that heading does not exist yet, so it adds the heading in the same form as map: quantification score with an end fit for reads without a poly(A) tail, and antisense evidence #39. Whichever of the two merges second will need the two 0.3.0 (unreleased) sections joined into one.

  • Tests:

    • gene_groups_detected (library): detection from the manifest and from the counts, for none, a one-gene-per-transcript table, and a single transcript;
    • warns_on_index_without_gene_groups (CLI): the index and map warnings with and without -q, once per map run, and the run record's warnings. With --infer-genes, a -q run prints nothing and records no warnings;
    • the toy run record has no warnings;
    • Python: has_gene_groups on grouped, ungrouped and inferred indexes.

    The toy fixture is unchanged.

Checks

See the PR checks. The same steps were run locally first: fmt, clippy (default and no-default features), tests, docs, package, Python, MSRV, and the nudgy stress tests. Miri could not run locally (a sysroot permission error, environmental); CI runs it.

🤖 Generated with Claude Code

https://claude.ai/code/session_013PdRfyfQgt9mi8eYLo2VqT

When every transcript is its own gene (FASTA headers without gene IDs and
neither --t2g nor --infer-genes), the per-gene candidate limits act on
isoforms and ties among isoforms go by FASTA order.

- spearfish index: the warning now shows under -q too, after the summary,
  names --t2g FILE and --infer-genes and says why they matter.
- spearfish map: warns once per run when the loaded index has no gene
  groups (manifest genes_from none, or as many genes as transcripts), also
  under -q, and the run record lists it under `warnings`
  (code no_gene_groups).
- Library: Index::has_gene_groups(), Index::n_genes() and
  spearfish::has_gene_groups(); Python: Index.has_gene_groups.
- Docs (indexing, output, mapping guides) and a CHANGELOG entry under
  0.3.0 (unreleased).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rob-p
rob-p merged commit a49f7e8 into main Nov 14, 2026
13 checks passed
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