Use polars for collapsing archive OTU tables#285
Merged
Conversation
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.
Motivation
write_collapsed_paired_with_unpaired_otu_tableimplementation usedpandasand produced failures in the collapse-to-sample tests; switching topolarsenables safer, typed ingestion and deterministic grouping/aggregation for archive OTU tables.Description
pandasusage inwrite_collapsed_paired_with_unpaired_otu_tablewithpolarsand removed thepandasimport.archive_schemato map archive fields to typed Polars schema and read rows withorient="row"to avoid orientation warnings.pl.concat, removed sample suffixes usingplstring ops, checked unique constraints via Polars, and sorted bysequence/geneto preserve deterministic order.partition_byand manual aggregation to preserve list-valued fields (read_names,nucleotides_aligned,read_unaligned_sequences,equal_best_hit_taxonomies) and producear.dataas the expected list-of-lists structure.Testing
pixi run -e dev pytest test/test_summariser.pywhich passed:28 passed, 1 skipped.pixi run -e dev pytest test, which completed but had one unrelated failure intest/test_pipe.py::Tests::test_sample_name_strange_characterscaused by an externaldiamondprocess exit (exit status -7), not by the summariser changes.Codex Task