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

Error in plot_clusters() in plot_cn_1d2d.py due to change in pandas df.groupby() #197

Open
BramLimSJ opened this issue Nov 2, 2023 · 2 comments

Comments

@BramLimSJ
Copy link

BramLimSJ commented Nov 2, 2023

Similar issue to an error which I posted earlier.

An error occurs in line 526 of plot_cn_1d2d.py when there is only one clone detected:

File "/software/team274/bl10/miniconda3/envs/hatchet/lib/python3.9/site-packages/hatchet/utils/plot_cn_1d2d.py", line 521, in <listcomp> my_colors = [cmap(mapping[r]) for r in bbc_.cn_clone1] KeyError: '1|1'

This is because the key in mapping is '('1|1',)' instead of '1|1'.

The error originated from line 78 of plot_cn_1d2d.py:

_, mapping = reindex([k for k, _ in bbc.groupby([f'cn_clone{i + 1}' for i in range(n_clones)])])

where a length-1 list is fed into bbc.groupby().

The newer version of pandas will return a length-1 tuple instead of a string, as highlighted here

The error can be overcome by deleting this:

if n_clones == 1: my_colors = [cmap(mapping[r]) for r in bbc_.cn_clone1] else: my_colors = [cmap(mapping[tuple(r)]) for _, r in bbc_[[f'cn_clone{i + 1}' for i in range(n_clones)]].iterrows()]

and replacing with:

my_colors = [cmap(mapping[tuple(r)]) for _, r in bbc_[[f'cn_clone{i + 1}' for i in range(n_clones)]].iterrows()]

A similar error occurs with plot_genome() in plot_cn_1d2d.py.

@immuneAI
Copy link

immuneAI commented Jul 26, 2024

@balabanmetin @mmyers1 @simozacca I'm facing the same issue with v2.0.1. Any more update after this?

@immuneAI
Copy link

immuneAI commented Aug 23, 2024

@balabanmetin @mmyers1 @simozacca I'm facing the same issue with v2.0.1. Any more update after this?

Any update on this? i'm haivng the same issue with 2|2 clones

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

No branches or pull requests

2 participants