jts / sga

de novo sequence assembler using string graphs
http://genome.cshlp.org/content/22/3/549
237 stars 82 forks source link

Issue with sga-preqc-report.py: Invalid arguments to legend #98

Closed reubwn closed 8 years ago

reubwn commented 8 years ago

Hi Jared,

First, thanks for the great piece of software :)

I'm having issues generating the preqc report PDF. I suspect it's something to do with matplotlib - I'm running:

SGA version 0.10.14 Matplotlib version 1.5

Error message:

>> sga-preqc-report.py genome.shuff.preqc 
output_pfx:  preqc_report
preqc_files:
genome.shuff.preqc
Traceback (most recent call last):
  File "/home/rnowell/software/sga/src/bin/sga-preqc-report.py", line 871, in <module>
    sys.exit(main(argv=None))
  File "/home/rnowell/software/sga/src/bin/sga-preqc-report.py", line 101, in main
    save_png=args.png, pylab_show=args.show)
  File "/home/rnowell/software/sga/src/bin/sga-preqc-report.py", line 764, in make_report_with_subplots
    plot_legend(subplots[2][0], data)
  File "/home/rnowell/software/sga/src/bin/sga-preqc-report.py", line 333, in plot_legend
    ax.legend(proxy_arts, names, 2, bbox_to_anchor=(0,1), borderaxespad=0.)
  File "/export131/home/rnowell/virt_env/python/sga/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 536, in legend
    raise TypeError('Invalid arguments to legend.')
TypeError: Invalid arguments to legend.

From previous experience (on a different machine), I know the input file works using matplotlib 1.4, however I am having trouble installing this older version on the cluster I'm using now as it requires a specific version of freetype2 (>= 2.4).

Is there a way to get sga-preqc-report.py to work with 1.5? Or another workaround for installing 1.4?

Many thanks for any advice,

Reuben

jakevdp commented 8 years ago

I poked around through the git history: I suspect this is the commit that broke things: https://github.com/matplotlib/matplotlib/commit/2bddb792e2519908a85fe6de17450eb3185d04af That's the only change to the code in 1.5 that I can see.

jakevdp commented 8 years ago

Here's the relevant PR: https://github.com/matplotlib/matplotlib/pull/3943

jakevdp commented 8 years ago

I think the fix here is to explicitly pass the loc parameter; e.g. change

ax.legend(proxy_arts, names, 2, bbox_to_anchor=(0,1), borderaxespad=0.)

to

ax.legend(proxy_arts, names, loc=2, bbox_to_anchor=(0,1), borderaxespad=0.)
reubwn commented 8 years ago

Bingo! You're a genius :)

Tested and works (generates PDF without problems) with SGA v0.10.14 and matplotlib v1.5. BTW, the line to fix is on line #333 of sga-preqc-report.py

Thanks!

jakevdp commented 8 years ago

Great! Glad to help.

jts commented 8 years ago

great! does this work on 1.4 as well? do you want to make a PR so your contribution is noted?

jakevdp commented 8 years ago

Done in #99

jts commented 8 years ago

Merged. Thanks!