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

fvm.plot_rna(): nan values in annot_pos cause plotting errors #53

Open
eugenechow opened this issue Oct 17, 2023 · 0 comments
Open

fvm.plot_rna(): nan values in annot_pos cause plotting errors #53

eugenechow opened this issue Oct 17, 2023 · 0 comments

Comments

@eugenechow
Copy link

Hi, I encountered an issue when using the fvm.plot_rna() function.

The following code and RNA structure can trigger the issue consistently using forgi 2.2.2 on Ubuntu 22.04 / python 3.10 / matplotlib 3.8.0

import matplotlib.pyplot as plt
import forgi.visual.mplotlib as fvm
import forgi.graph.bulge_graph as fgb

seq = "GUACGAUCAAGAGAAGAGUCAUCAUGGACAUCGUCCUCGGGUUCUCCCUCGGGGGUGUCAUGGCCUCUUACUGGUGGUGGGGAUUCCACAUGGAUAAGAUUAACAAGAGAGAGAAGUUCUACGCAGAGCUAG"
mfe =  "....((((..(((..(((((......))).))...)))(((....)))....................................(((....)))...)))).............((((((....)))))).."
cg = fgb.BulgeGraph.from_fasta_text(f">test\n{seq}\n{mfe}")[0]
fvm.plot_rna(cg, text_kwargs={"fontweight":"black"}, lighten=0.7,
             backbone_kwargs={"linewidth":3})
plt.show()

Where python would produce the following error:

File "lib/python3.10/site-packages/matplotlib/bezier.py", line 351, in split_path_inout
    ctl_points, command = next(path_iter)
StopIteration

I tried debugging and found that the _find_annot_pos_on_circle() method returned [nan nan] for some of the base position annotations, which caused the plotting to fail.

A quick fix to omit such annotations can be done by changing line #329 in forgi/visual/mplotlib.py from:

if annot_pos is not None:

to:

if annot_pos is not None and not np.any(np.isnan(annot_pos)):
@eugenechow eugenechow changed the title fvm.plot_rna(): nan values in annot_pos causes plotting errors fvm.plot_rna(): nan values in annot_pos cause plotting errors Oct 17, 2023
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

1 participant