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

behavior of on=[] #91

Open
Tracked by #92
gfudenberg opened this issue Aug 26, 2021 · 2 comments
Open
Tracked by #92

behavior of on=[] #91

gfudenberg opened this issue Aug 26, 2021 · 2 comments

Comments

@gfudenberg
Copy link
Member

How to infer the space of all possible values of columns passed into on=[] argument. e.g. this arises for implementing complement(..., on=['strand']), which is relied on in subtract.

The simplest solution for inferring all possibilities is by looking at all unique values in these columns. This creates questions:

  1. we need to know the space of all possibilities, even for combinations of ['chrom']+on that are not represented in any interval of the input dataframe. Thus we need a way to specify this space.
  2. we need to specify the behavior for pd.NA values in columns passed to on.

Potential solutions:
For (1):

  • require formatting the column as a categorical with all desired possibilities before passing to bioframe functions (as they call groupby). We could provide a utility function to parse/cast strand column as a categorical.
  • develop a new input format, e.g. pass a dictionary: on={‘strand’: (‘-‘, ‘+’, pd.NA)}

For (2), three options for how to deal with missing values in columns passed to on. We could allow the user to select one of these with a flag.

  • drop any intervals with pd.NA in the on column from the operation
  • add any intervals with pd.NA to each group.
  • treat pd.NA as a separate category for groupby
@gfudenberg gfudenberg mentioned this issue Aug 26, 2021
27 tasks
@agalitsyna
Copy link
Member

For strand column, pd.NA here should actually '.' according to the bioframe specs: https://bioframe.readthedocs.io/en/latest/guide-specifications.html
This does not change the logic for some unknown columns, though

@nvictus
Copy link
Member

nvictus commented Apr 3, 2023

For the behavior in (2), I'd try to align as close as possible to the native behavior of applying df.groupby() to a categorical column where some instances of an allowed categorical value are missing.

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

No branches or pull requests

3 participants