Skip to content

Conversation

@Macabe222
Copy link
Contributor

Adds warnings for merging tables with differing levels of taxonomic depth, and adds a warning when merging tables with one one level of taxonomic depth in merge_taxa.

Addresses #341

@Macabe222 Macabe222 marked this pull request as ready for review October 20, 2025 02:59
@lizgehret
Copy link
Member

Hey @Macabe222 is this ready for a review?

@Macabe222
Copy link
Contributor Author

@lizgehret Yes it is

@lizgehret
Copy link
Member

Sounds good, thanks @Macabe222! We'll get someone to look at this either this week or next 🙂

@colinvwood colinvwood self-assigned this Nov 5, 2025
@colinvwood colinvwood moved this from Needs Review to In Review in 2026.1 ❄️ Nov 5, 2025

def merge_taxa(data: pd.DataFrame) -> pd.DataFrame:
data = _merge_feature_data(data)
if isinstance(data, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data is always a list because it's typed as one (see plugin_setup.py)

Comment on lines +77 to +78
frame_one = data[0]
frame_two = data[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for multiple reasons. First, the input is a list even if there is only one taxonomy passed in--this will give an index error for data[1]. Second, this doesn't handle the case where more than two taxonomies are being merged.

count = frame_one["Taxon"].str.count(';')
count_two = frame_two["Taxon"].str.count(';')

for index, value in count.items():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this does is see if the two taxonomies have the same number of levels for each pair of taxa, matched by index. This is meaningless because taxon index has no meaning. What the issue is requesting is to see if each of the merged taxonomies as a whole has the same number of levels (maximum depth) as the others.

except KeyError:
continue

if (count == 0).any():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what the issue is requesting. Go read the forum post more carefully.

@colinvwood colinvwood moved this from In Review to In Development in 2026.1 ❄️ Nov 25, 2025
@colinvwood colinvwood assigned Macabe222 and unassigned colinvwood Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Development

Development

Successfully merging this pull request may close these issues.

3 participants