Repository navigation
Fix ImpliedLosses: look up taxonomic levels by name - #126
Merged
Merged
Conversation
_count_untouched_clades compares species tree nodes by identity, but the scoring tree (full_species_tree) and the trees of the separately pickled levels are different copies. Every nested level therefore counted one extra loss; a complete 1:1 family over the 30 fungi-30 species got ImpliedLosses=22 at Fungi instead of 0. _hog_implied_losses now resolves the sub-HOGs' levels by name in the scoring tree, so all comparisons stay within one tree object. Golden snapshots regenerated: apart from ImpliedLosses values (and the order of siblings, which the snapshot sorts by their text), all 13 are unchanged. The sum of all ImpliedLosses values in the snapshots drops from 1483 to 910. Fixes #115 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the scoring-tree taxonomic lookup changes.
No open issues 🎉
What changed in this PR
Fixes #115 by resolving sub-HOG taxonomic levels by name in the scoring tree, preventing incorrect ImpliedLosses counts caused by comparing nodes from different tree copies.
Changes:
- Uses the scoring tree’s name index for recursive loss calculations and reached-clade comparisons.
- Enables previously failing regression tests and adds duplication coverage across separately pickled tree copies.
- Refreshes golden snapshots with corrected loss scores, including zero losses for the complete F0848294 family.
| File | Description |
|---|---|
tests/test_hog_class.py |
Enables loss regressions and tests duplication across tree copies. |
tests/data/fungi30/golden/F1085561.txt |
Updates loss scores and resulting group ordering. |
tests/data/fungi30/golden/F0848294.txt |
Records zero losses throughout the complete family. |
tests/data/fungi30/golden/F0848191.txt |
Updates loss scores across multiple families. |
tests/data/fungi30/golden/F0489906.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0480898.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0478382.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0477229.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0476910.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0459413.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0453151.txt |
Refreshes expected loss scores. |
tests/data/fungi30/golden/F0413304.txt |
Updates loss scores and resulting group ordering. |
tests/data/fungi30/golden/clust12762.txt |
Refreshes expected loss scores. |
FastOMA/_hog_class.py |
Resolves taxonomic nodes within one scoring tree by name. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2 of #124. Stacked on #125: the base is
fix/small-bugs-input-validation, so this PR only shows the #115 change. GitHub retargets it todevonce #125 is merged.Problem
ImpliedLosseswas too high: roughly one extra loss per nested orthologGroup. A complete 1:1 family over all 30 fungi-30 species (F0848294, CompletenessScore 1.0 everywhere) gotImpliedLosses=22at Fungi instead of 0._count_untouched_cladescompares species tree nodes by identity (ete3TreeNodehas no__eq__), but the nodes came from different tree objects:full_species_tree, a copy;_tax_nowpoints into the pruned working tree;Fix
_hog_implied_lossesnow looks up the sub-HOGs' taxonomic levels by name in the scoring tree (_species_name_index), so all comparisons stay within one tree object.CompletenessScoreandTCSScorewere not affected.Storing taxon names instead of
TreeNodes inHOG(fewer ete3 dependencies, smaller pickles) is left to a separate, output-neutral refactor.Tests
test_implied_losses_against_full_species_tree, previously a strict xfail, now passes (complete family = 0, two lost clades = 2; in memory and pickled per level).test_implied_losses_with_duplication_independent_of_tree_copies: with a duplication, the value is the same whether the levels share one tree object or are pickled separately. It fails with the old code.dessimozlab/fastoma:dev. Apart fromImpliedLossesvalues, all 13 are unchanged: structure, TaxRange, CompletenessScore and TCSScore are identical. In the text diff, some sibling groups also change places, because the snapshot sorts siblings by their text, which includes the scores. The sum of allImpliedLossesvalues in the snapshots drops from 1483 to 910.Fixes #115
🤖 Generated with Claude Code