Skip to content

assign_view: drop_unassigned should not drop rows with NaNs in other columns#241

Closed
OfficialBishal wants to merge 1 commit into
open2c:mainfrom
OfficialBishal:fix-assign-view-drop-unassigned
Closed

assign_view: drop_unassigned should not drop rows with NaNs in other columns#241
OfficialBishal wants to merge 1 commit into
open2c:mainfrom
OfficialBishal:fix-assign-view-drop-unassigned

Conversation

@OfficialBishal

Copy link
Copy Markdown

Closes #160.

assign_view(..., drop_unassigned=True) dropped every row containing a NaN in any column:

out_df = out_df.iloc[pd.isna(out_df).any(axis=1).values == 0, :]

So an interval that was assigned to a view region got dropped if it had a NaN in an unrelated column (the reporter's example: cooler bins with missing weights). drop_unassigned should only drop intervals that fall outside the view — i.e. whose assignment column (df_view_col) is NaN.

Example — with drop_unassigned=True, only the chr2 row (outside the view) should be dropped, but before this PR the chr1:10-20 row is also lost:

chrom start end value view_region
chr1 10 20 NaN region1
chr1 30 40 5.0 region1
chr2 10 20 7.0 (unassigned)

Added test_assign_view_drop_unassigned_keeps_nan_in_other_columns; pytest tests/test_ops.py passes.

…her columns

assign_view(drop_unassigned=True) dropped every row containing a NaN in any column, so intervals that were assigned to a view region were lost if they had a NaN in an unrelated column (e.g. cooler bins with missing weights). Only drop intervals whose view assignment is NaN, and add a regression test.

Closes open2c#160
@OfficialBishal

Copy link
Copy Markdown
Author

Closing this for now to keep to a single open PR on bioframe and let #240 land first. The fix here for #160 still stands — happy to reopen or resubmit it whenever it's useful. Thanks!

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.

bioframe.assign_view drop_unassigned drops all NaNs?

1 participant