samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
682 stars 240 forks source link

plot-vcfstats ScalarFormatter error under latest matplotlib (2.1.0) #687

Closed ghost closed 7 years ago

ghost commented 7 years ago

Under the latest matplotlib release (2.1.0) when I run plot-vcfstats, while it is executing the generated plot.py code I get an error like this

AttributeError: This method only works with the ScalarFormatter

which happens during the method call ax1.ticklabel_format(...) in the block of code contained in the if plot_hethom_by_sample: statement (so it only happens when you call bcftools stats with the --samples option).

I'm no expert on matplotlib, but it looks like it's interpreting some of the points that are read in as categorical values instead of numbers (because they're formatted as strings) so the Formatter becomes a StrCategoryFormatter instead of a ScalarFormatter (probably related to one of the new features in this release, "support for string categorical values").

Most of the *.dat files are read in with the pattern dat.append([float(x) for x in row]), but tstv_by_sample.*.dat just has dat.append(row), since it contains sample names which can't be converted to a float, which causes the numbers to be interpreted as strings.

I think this is something I actually might be able to do a fix for, so I'll try and submit a PR for it, but I figured I'd submit this first so I have an issue to reference in the PR. Sorry if I'm doing this all wrong, I'm pretty new to contributing to projects like these.

pd3 commented 7 years ago

Thank you for the bug report and the fix