You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImpliedLosses score is wrong: species tree nodes are compared by identity #115
The ImpliedLosses score in the orthoXML is too high. A complete 1:1 family over all 30 species of fungi-30 (rootHOG F0848294, CompletenessScore 1.0 at every level) gets ImpliedLosses=22 at Fungi, where it should be 0. Roughly, every nested orthologGroup adds one loss. Families that really lost clades are also wrong: with species A and C of ((A,B),(C,D)) the expected value is 2.
Cause
_count_untouched_clades (_hog_class.py:82-86) decides with tree_node in reached_nodes / tree_node in r.get_ancestors() whether a clade is reached. ete3 TreeNode has no __eq__, so this compares object identity. The nodes come from different tree objects:
the scoring node is taken from full_species_tree, a copy() of the species tree (_hog_class.py:576, _infer_subhog.py:118);
each HOG's _tax_now points into the pruned working tree;
every taxonomic level is written to and read from its own pickle file (infer_hogs_this_level), so the HOGs of different levels point into different copies of the tree.
The existing unit tests (tests/test_hog_scores.py) build everything on one tree object, so they don't catch it. CompletenessScore and TCSScore are not affected (they use names / the size feature).
the golden snapshots in tests/data/fungi30/golden/ record the current, wrong values and will change with the fix.
Proposed fix
Compare species tree nodes by name (names are unique after check-input), or resolve each _tax_now into the scoring tree via _species_name_index before comparing. More generally, storing the taxon name in HOG instead of a TreeNode would remove this class of bug and shrink the per-level pickles (each currently contains a copy of the species tree); that also helps the ete4 migration.
After the fix, regenerate the golden snapshots and check that the diff only changes ImpliedLosses values.
Activity