pmelsted / KmerStream

Streaming algorithm for computing kmer statistics for massive genomics datasets
53 stars 11 forks source link

ValueError: f(a) and f(b) must have different signs #11

Open tseemann opened 8 years ago

tseemann commented 8 years ago

Error on a 1K amplicon:

cat raw.tsv

Q       k       F0      f1      F1
0       21      964     0       271790
0       27      952     0       247142
0       33      954     0       222535
0       39      938     0       198291
0       45      976     0       174626
0       51      978     2       151616
0       57      916     6       129282
0       63      902     10      107766
0       69      926     14      87280
0       75      908     24      67707

KmerStreamEstimate.py raw.tsv

Q       k       F0      f1      F1      F0-f1   G       e       lambda
Traceback (most recent call last):
  File "/home/linuxbrew/.linuxbrew/bin/KmerStreamEstimate.py", line 43, in <module>
    x,e = EMfit2(F0,f1,F1,int(k))
  File "/home/linuxbrew/.linuxbrew/bin/KmerStreamEstimate.py", line 26, in EMfit2
    e = brentq(func, 0, 1)
  File "/home/linuxbrew/.linuxbrew/Cellar/python/2.7.12_1/lib/python2.7/site-packages/scipy/optimize/zeros.py", line 442, in brentq
    r = _zeros._brentq(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
ValueError: f(a) and f(b) must have different signs
tseemann commented 8 years ago

Here's a bigger 170kbp plasmid - it dies at the k=61 line:

    r = _zeros._brentq(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
ValueError: f(a) and f(b) must have different signs

Q       k       F0      f1      F1
0       21      3294864 2287125 12998292
0       29      4389344 3411027 12197818
0       37      5143539 4228546 11397425
0       45      5701978 4923828 10597107
0       53      5994600 5339172 9796857
0       61      6073264 5527317 8996681
0       69      6021409 5605572 8196603
0       77      5807117 5482701 7396581
0       85      5443943 5167614 6596629
0       93      4998627 4766073 5796729
0       101     4450685 4259462 4996947
0       109     3853174 3688735 4197217
0       117     3203916 3093976 3397561

Q       k       F0      f1      F1      F0-f1   G       e       lambda
0       21      3294864 2287125 12998292        1007739.0       962481.253392   0.182981051863  13.5049819975
0       29      4389344 3411027 12197818        978317.0        900043.587899   0.292634155143  13.5524747512
0       37      5143539 4228546 11397425        914993.0        810346.500288   0.389667296542  14.0648784143
0       45      5701978 4923828 10597107        778150.0        622556.193101   0.494428741631  17.02192849
0       53      5994600 5339172 9796857 655428.0        407729.342565   0.596356932129  24.0278439083