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

df_to_anndata does not assign binary numerical columns correctly in .uns #422

Closed
Imipenem opened this issue Nov 22, 2022 · 1 comment · Fixed by #429
Closed

df_to_anndata does not assign binary numerical columns correctly in .uns #422

Imipenem opened this issue Nov 22, 2022 · 1 comment · Fixed by #429
Assignees
Labels
bug Something isn't working

Comments

@Imipenem
Copy link
Collaborator

Describe the bug

When calling ep.df_to_anndata(...) the binary columns (columns with only two values like 1,0) do not get correctly assigned to "numerical_columns" in uns.

To Reproduce

Example:

df = pd.DataFrame({"Col1":[i for i in range(4)], "Col2":["str" + str(i) for i in range(4)], "Col3":[1.0,0.0,np.nan,1.0]})
adata = ep.ad.df_to_anndata(df)
print(adata.uns)

# OverloadedDict, wrapping:
	# OrderedDict([('numerical_columns', ['Col1']), ('non_numerical_columns', ['Col3', 'Col2'])])
# With overloaded keys:
	# ['neighbors'].

Col3 should be numerical!

Expected behavior

The binary columns with numerical values such as only 0 and 1 should be assigned to numerical columns.
The bug is caused by the following line:

uns["numerical_columns"] = list(set(numerical_columns) ^ set(binary_columns))

The XOR excludes the binary columns since they are in both sets. This should be fixed.

System [please complete the following information]:

  • Ehrapy version: 0.2.0
@Imipenem Imipenem added the bug Something isn't working label Nov 22, 2022
namsaraeva added a commit that referenced this issue Dec 2, 2022
@namsaraeva namsaraeva linked a pull request Dec 2, 2022 that will close this issue
Imipenem added a commit that referenced this issue Dec 3, 2022
df_to_anndata logical XOR to OR, issue #422
@Zethson Zethson reopened this Mar 11, 2023
@Zethson
Copy link
Member

Zethson commented Mar 11, 2023

We are unfortunately still running into this. We can supply an object to test this out and fix this very soon.

@Zethson Zethson closed this as completed Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants