DRL / blobtools

Modular command-line solution for visualisation, quality control and taxonomic partitioning of genome datasets
GNU General Public License v3.0
187 stars 44 forks source link

Recent commit breaks the example blobplot with log(0) #55

Closed josiahseaman closed 7 years ago

josiahseaman commented 7 years ago

Straight from installation I ran into a showstopper bug. It looks like self.max_cov and possibly others failed to initialize:

$ ./blobtools plot  -i example/blobDB.json  -o example/
[+] Reading BlobDB example/blobDB.json
[+]     Loading BlobDB into memory ...
[+]     Deserialising BlobDB (using 'ujson' module) (this may take a while) ...
[+]     Finished in 0.00183987617493s
[+] Extracting data for plots ...
/python2.7/site-packages/matplotlib/axes/_base.py:3193: UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=100.0, top=100.0
  'bottom=%s, top=%s') % (bottom, top))
Traceback (most recent call last):
  File "./blobtools/lib/blobplot.py", line 183, in <module>
    main()
  File "./blobtools/lib/blobplot.py", line 175, in main
    plotObj.plotScatter(cov_lib, info_flag, out_f)
  File "./blobtools/lib/BtPlot.py", line 598, in plotScatter
    fig, axScatter, axHistx, axHisty, axLegend, top_bins, right_bins = self.setupPlot(self.plot)
  File "./blobtools/lib/BtPlot.py", line 495, in setupPlot
    right_bins = logspace(0, (int(math.log(self.max_cov)) + 1), 200, base=10.0)
ValueError: math domain error

I deduced that 58633de837ea71f1c90ac937e670e24db69fac2d introduced this bug because it changes some relevant code and reverting it fixes the problem.

$ git checkout 2a236ea194e1129e97e9f85cb64f81030c70a856
$ ./blobtools plot  -i example/blobDB.json  -o example/
[+] Reading BlobDB example/blobDB.json
[+]     Loading BlobDB into memory ...
[+]     Deserialising BlobDB (using 'ujson' module) (this may take a while) ...
[+]     Finished in 0.00210118293762s
[+] Extracting data for plots ...
[I]     no-hit : sequences = 1, span = 0.01 MB, N50 = 6,273 nt
[I]     Nematoda : sequences = 3, span = 0.01 MB, N50 = 4,060 nt
[I]     Actinobacteria : sequences = 4, span = 0.0 MB, N50 = 951 nt
[I]     unresolved : sequences = 1, span = 0.0 MB, N50 = 2,346 nt
[I]     Tardigrada : sequences = 1, span = 0.0 MB, N50 = 216 nt
[+] Plotting example/blobDB.json.bestsum.phylum.p7.span.100.blobplot.bam0.png
[+] Plotting example/blobDB.json.bestsum.phylum.p7.span.100.blobplot.read_cov.bam0.png
[+] Writing example/blobDB.json.bestsum.phylum.p7.span.100.blobplot.stats.txt

Good luck and thanks for the great tool.

DRL commented 7 years ago

Hi, thank you for this.

I did this recently while a was working on some legacy BlobDB files and noticed the current version didn't like it when there was no read coverage.

I assumed this would not cause problems and I find I hard to believe that it does, since the changes in 58633de affect a function which is only called by view and not by the plotting function. The issue might rather be the 'legacy' example/blobDB.json file i create for test purposes and then got uploaded. I have removed that file now.

Did you create an test blobDB or did you just run the plotting command on the example file in the folder?

cheers,

dom

DRL commented 7 years ago

I made a new release removing redundant example files as the folder was a bit chaotic...

Please let me know if the issue persists on your side.

cheers,

dom

josiahseaman commented 7 years ago

I can verify that fixed the issue. Thanks!