wilkelab / Opfi

A Python package for discovery, annotation, and analysis of gene clusters in genomics or metagenomics data sets.
https://opfi.readthedocs.io/
MIT License
21 stars 5 forks source link

Allow diagram line wrapping #155

Closed alexismhill3 closed 3 years ago

alexismhill3 commented 4 years ago

Our plotting dependency dna_features_viewer already has this capability (which I have been using locally) so I figured we may as well have this option too. I find that wrapping gene diagrams on 25000 nt per line makes the visualizations nicer for really long operons, which of course are not actual operons; nevertheless, we have a lot of long candidate systems in our real data.

Below are diagrams of the same candidate, plotted in three different ways:

With line wrapping, 25000 nt per line: operon_new_with_wrapping Without line wrapping, before this PR: operon_old And you can't even see it being rendered here, but this is what plotting this candidate on a single line looks like now: operon_new_no_wrap

This changes how the single-line operon plot looks because the figure_width and figure_height arguments of record.plot are actually being applied now - they weren't before because an Axes object was also being passed to this function, which apparently nullifies those parameters. Note that plot_operon_pairs still passes an Axes to record.plot out of necessity, but it seems like the figure dimensions haven't been an issue with stacked operons so this is apparently fine.