ksamuk / pixy

Software for painlessly estimating average nucleotide diversity within and between populations
https://pixy.readthedocs.io/
MIT License
117 stars 14 forks source link

IndexError during Fst calc when chrom has no variants passing filter #21

Closed mscharmann closed 3 years ago

mscharmann commented 3 years ago

Hello, I am using a genome assembly that contains a few hundred small contigs in addition to large chromosome-scale scaffolds, in combination with very sparse RAD-data. Unfortunately, pixy crashes during the Fst calculation for some "chromosomes", presumably because there were no variants, or only a single one, left after filtering on the "chromosome":

Traceback (most recent call last): File "XXX/pixy", line 13, in sys.exit(main()) File "/XXX/pixy/main.py", line 626, in main maf_array = allele_freqs[:,1] > args.fst_maf_filter IndexError: index 1 is out of bounds for axis 1 with size 1

I propose to except IndexError in this case and simply return "NA". You may argue that this "chromosome" should be removd from the input VCF before running pixy, but I am trying to integrate pixy in a pipeline that calculates various stats for all "chromosomes" in a genome assembly includind these small "junk" contigs, irrespective of how many variants they contain or not.

Cheers, Mathias

ksamuk commented 3 years ago

Hi Mathias,

This issue should be solved in the new version, can you try updating and see if the problem persists?

ksamuk commented 3 years ago

Going to go ahead and close this for now, please let me know if the error persists in the new version.