Skip to content

fix: read a DADA2 NA rank as an unfilled rank, not a taxon - #33

Merged
hyperpolymath merged 1 commit into
mainfrom
marina/jolly-volta-lkmb1k
Nov 15, 2026
Merged

hyperpolymath merged 1 commit into
mainfrom
marina/jolly-volta-lkmb1k

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

DADA2 assignTaxonomy writes NA at every rank it could not assign. Protoctist read it as a taxon named "NA":

  • TaxPath("Eukaryota;Alveolata;NA;NA") reached 4 ranks;
  • at_rank at rank 3 returned "NA";
  • the tree gained nested NA nodes.

The docs called this "the one silent pitfall" and told users to pre-convert. The maintainer chose to fix it in the library instead.

Changes

  • src/types.jl (TaxPath): a label that is exactly "NA" becomes the unfilled rank (""). Trailing NAs drop, and the path stops at its last real rank, so "Eukaryota;Alveolata;NA;NA" equals "Eukaryota;Alveolata". Only the exact R missing-value token is special: "na" stays a label. No PR2 or SILVA taxon is named NA.
  • test/cases/types.jl: 6 cases (trailing NAs, an interior NA, all-NA, lowercase kept).
  • Docs:
    • README.adoc, docs/README.adoc, docs/EXPLAINME.adoc and docs/guide/lineage-formats.adoc now say that NA is read as an unfilled rank.
    • docs/guide/cookbook.adoc: the R recipe now pastes the ranks as they are (paste(r, collapse = ";")), and its example row shows NA.
    • docs/guide/troubleshooting.adoc: the section for the pitfall is removed.
  • Unchanged: a count cell of NA is still an error.

RSR Quality Checklist

Required

  • Tests pass (Pkg.test() on Julia 1.11.7: Aqua 11, behaviour 115)
  • Code is formatted (one-line change in an existing style)
  • Linter is clean (no new warnings)
  • No banned language patterns
  • No unsafe blocks without // SAFETY: comments
  • No banned functions
  • SPDX license headers present on all new/modified source files (unchanged)
  • No secrets, credentials, or .env files included

As Applicable

  • Documentation updated for user-facing changes

Testing

  • Before: TaxPath("Eukaryota;Alveolata;NA;NA") had length 4, and at_rank(p, PR2_RANKS[3]) == "NA".
  • After: length 2, and at_rank returns nothing. A tree built from the DADA2 lineage and a Ciliophora lineage has no NA node.
  • Pkg.test(): 126 pass.

Generated by Claude Code

DADA2 assignTaxonomy writes "NA" at every rank it could not assign.
Protoctist read it as a taxon named "NA": TaxPath("Eukaryota;Alveolata;
NA;NA") reached 4 ranks, at_rank 3 returned "NA", and the tree gained
nested "NA" nodes. The docs called this the one silent pitfall and told
users to pre-convert. The maintainer chose to fix it in the library.

- TaxPath: a label that is exactly "NA" is the unfilled rank (""), so
  trailing NAs drop and the path stops at its last real rank. Only the
  exact R missing-value token is special; "na" stays a label. No PR2 or
  SILVA taxon is named NA.
- Tests: 6 cases (trailing NAs, interior NA, all-NA, lowercase kept).
- Docs: README, docs/README, cookbook (the R recipe now pastes the ranks
  as they are), lineage-formats, EXPLAINME; the troubleshooting section
  for the pitfall is removed. Count cells of NA are still an error.

Pkg.test() on Julia 1.11.7: Aqua 11, behaviour 115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0136P7ZnB2Fzqf8br8DGDD4k
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features

    • DADA2-style NA values are now treated as unfilled taxonomic ranks, so stopped lineages can match their shorter equivalents.
  • Documentation

    • Updated DADA2 guidance and examples to explain how NA ranks are handled when joining taxonomy columns.
    • Removed the troubleshooting entry about “NA” appearing as a taxon name.

TaxPath now treats exact "NA" labels as unfilled ranks, equivalent to empty strings. Tests cover how these labels affect path length, rank lookup, and empty paths. Documentation updates describe the behaviour in DADA2 guidance and examples.

Changes: TaxPath unfilled-rank handling

Layer / File(s) Summary
Normalize and test NA ranks
src/types.jl, test/cases/types.jl
TaxPath converts exact "NA" labels to empty strings before removing trailing empty labels. Tests cover trailing and interior occurrences, empty paths, rank lookup, and lowercase "na".
Update DADA2 guidance
README.adoc, docs/EXPLAINME.adoc, docs/README.adoc, docs/guide/cookbook.adoc, docs/guide/lineage-formats.adoc, docs/guide/troubleshooting.adoc
The guidance describes "NA" as an unfilled rank and shows rank columns joined directly. The troubleshooting entry about nested "NA" nodes is removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: claude

Merge Risk: Minimal · up to d7104

TaxPath now reads an exact "NA" rank as unfilled, and the docs and tests match the implemented behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a DADA2 NA rank is now read as an unfilled rank rather than as a taxon. The raw summary confirms TaxPath treats exact "NA" labels as unfilled ranks, with matchin…
Description check Passed The description follows the template's main sections: Summary, Changes, the RSR Quality Checklist, and Testing. It explains the problem (DADA2 writes NA for unassigned ranks, which was read as a tax…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a DADA2 NA rank is now read as an unfilled rank rather than as a taxon. The raw summary confirms TaxPath treats exact "NA" labels as unfilled ranks, with matching tests and documentation updates. The title is specific and matches the objectives.

Full details: Description check

Explanation

The description follows the template's main sections: Summary, Changes, the RSR Quality Checklist, and Testing. It explains the problem (DADA2 writes NA for unassigned ranks, which was read as a taxon), lists the code, test, and documentation changes, and gives before and after test results. Two items are unclear. The Screenshots section is absent, though the template marks it as optional. The checklist omits the Linter and Formatting items' evidence details, and the description does not link an issue with 'Closes #N'. These gaps are non-critical.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f5fbccea-d639-4bb0-9083-fa5ec7ade06a
Commits

Reviewing files that changed from the base of the PR and between 5ed5875 and d7104f4.

Files selected for processing: 8

  • README.adoc
  • docs/EXPLAINME.adoc
  • docs/README.adoc
  • docs/guide/cookbook.adoc
  • docs/guide/lineage-formats.adoc
  • docs/guide/troubleshooting.adoc
  • src/types.jl
  • test/cases/types.jl
Files with no reviewable changes: 1

  • docs/guide/troubleshooting.adoc

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: Static analysis (JET)
Additional comments: 1

docs/guide/cookbook.adoc: 1

30-30: Data Integrity & Integration

The cookbook example is consistent with the implementation. An interior NA is an unfilled rank that both build_taxonomy_tree and rollup_counts skip. Glissomonadida attaches beneath Cercozoa, and the recipe's description of that placement matches. The comment's requested check is therefore answered by the inspected code, and no defect in the changed recipe remains. The only inconsistency is in the PR description's wording that an interior NA stops the path. That is a description issue outside the changed file, not a documentation error.

@sonarqubecloud

Copy link
Copy Markdown

@linear-code
linear-code Bot marked this pull request as ready for review November 15, 2026 00:11
@hyperpolymath
hyperpolymath merged commit a5f5a6e into main Nov 15, 2026
66 checks passed
@hyperpolymath
hyperpolymath deleted the marina/jolly-volta-lkmb1k branch November 15, 2026 00:14
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.

3 participants