Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 948 #959

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Bug fixes:
* Allow `Table.to_json` to properly handle numpy types in metadata, see issue [#886](https://github.com/biocore/biom-format/issues/886)
* Do not modify IDs in place in the presence of duplicate relabels, see issue [#892](https://github.com/biocore/biom-format/issues/892)
* Catch an edge case where a failured ID update in place would actually change IDs, see issue [#892](https://github.com/biocore/biom-format/issues/892)
* Fixed an edge case on in `align_tree` when a feature was empty, see issue [#948](https://github.com/biocore/biom-format/issues/948)

New features:

Expand Down
1 change: 0 additions & 1 deletion biom/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ def align_tree(self, tree, axis='observation'):
raise TableException("No common ids between table and tree.")
_tree = tree.shear(names=common_tips)
_table = self.filter(common_tips, axis=axis, inplace=False)
_table.remove_empty()
_tree.prune()
order = [n.name for n in _tree.tips()]
_table = _table.sort_order(order, axis=axis)
Expand Down
15 changes: 15 additions & 0 deletions biom/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,21 @@ def test_align_to_dataframe_samples_no_common_ids(self):
with self.assertRaises(TableException):
table.align_to_dataframe(metadata)

@pytest.mark.skipif(not HAVE_SKBIO, reason="skbio not installed")
def test_align_tree_issue_948(self):
table = Table(np.array([[0, 0, 0, 0],
[2, 3, 4, 4],
[5, 5, 3, 3],
[0, 0, 0, 1]]).T,
['a', 'b', 'c', 'd'],
['s1', 's2', 's3', 's4'])
tree = skbio.TreeNode.read(["(a,b,c,d)r;"])
exp_tree = tree
exp_table = table.copy()
res_table, res_tree = table.align_tree(tree)
self.assertEqual(res_table, exp_table)
self.assertEqual(str(exp_tree), str(res_tree))

@pytest.mark.skipif(not HAVE_SKBIO, reason="skbio not installed")
def test_align_tree_intersect_tips(self):
# there are less tree tips than observations
Expand Down
Loading