Skip to content

Fix to_functional_df function - #677

Open
pkonieczny wants to merge 4 commits into
masterfrom
pawel/dev-11858-to_functional_df-only-returning-unclassified-taxa-in-df-by
Open

Fix to_functional_df function#677
pkonieczny wants to merge 4 commits into
masterfrom
pawel/dev-11858-to_functional_df-only-returning-unclassified-taxa-in-df-by

Conversation

@pkonieczny

@pkonieczny pkonieczny commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Status

  • Ready

Description

This PR makes 2 major changes:

  1. It changes the shape of to_functional_df to match to_classification_df: functional profiles (so, samples) are the rows whereas function ids (or function ids x taxa names for stratified results) are the columns. For stratified results, the function ids x taxa names is a MultiIndex on the columns.
  2. It ensures that taxa_stratified=True is handled properly in that data frame: each contributing taxon gets its own column in the dataframe.

As part of this PR some benchmarks were run on sparse representation of the data frame - the verdict is: not worth it since the wide format introduces a lot of columns so huge overhead in pandas. The sparse format actually uses more memory due to that even at values at ~25% full. We'd need ~1k samples for sparse to become useful.

Related PRs

  • This PR is independent

TODOs

  • Update CHANGELOG ?

Comment thread onecodex/models/base_sample_collection.py

@petraszd petraszd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code changes looks good. Though I am not fully sold on breaking backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants