Skip to content

Issue with ZeroDivisionError in Circos Plot #49

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

Closed
MattFill opened this issue Jan 16, 2024 · 3 comments
Closed

Issue with ZeroDivisionError in Circos Plot #49

MattFill opened this issue Jan 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@MattFill
Copy link

MattFill commented Jan 16, 2024

Firstly, thank you for this outstanding circular visualization package.

However, I've encountered an issue while attempting to create a circos plot. I'm aiming for something similar to Example 4-2 in your documentation. My dataset consists of a 'to-from' table that includes approximately 37,000 entries, many of which are zeros. While using the following code to generate the circos diagram, I encounter a "ZeroDivisionError: float division by zero":

from pycirclize.parser import Matrix
matrix = Matrix.parse_fromto_table(tmp_weights)

circos = Circos.initialize_from_matrix(
    matrix,
    space=3,
    cmap="viridis",
    ticks_interval=5,
    label_kws=dict(size=12, r=110),
    link_kws=dict(direction=1, ec="black", lw=0.5),
)

fig = circos.plotfig()

I'm curious about the potential cause of this error. Could it be related to the size of my matrix or its sparsity? Any insights or suggestions you could provide would be immensely helpful.

@Zymeth0211
Copy link

Zymeth0211 commented Jan 17, 2024

I was too having that problem.
But when I checked my matrix data for link plot. I realized a problem due to zero link.
I deleted columns or rows that have 0 value.
Here's my data
image
That is Okay.

But if you have one or more columns or rows containing all 0. You need to delete that column. I hope you could understand.

@moshi4
Copy link
Owner

moshi4 commented Jan 17, 2024

Hi @MattFill

My dataset consists of a 'to-from' table that includes approximately 37,000 entries, many of which are zeros.

If you remove all data with a value of 0 from the "from-to" table, the ZeroDivisionError should not occur.

@moshi4 moshi4 closed this as completed Jan 18, 2024
@moshi4 moshi4 mentioned this issue Feb 18, 2024
@moshi4 moshi4 added the bug Something isn't working label May 3, 2024
@MengxingLiu
Copy link

Hi @moshi4
thanks for this beautiful package. is there any chance it supports all zero rows/columns so that it circos plot has this label appearing on the plot only with no connections?
The rational behind this is that pairs not showing on the plot can be not tested or not positive, but if it shows on the plot, meaning it's tested, but not positive.

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

No branches or pull requests

4 participants