Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError when no reads (same as #3) #5

Open
kautto opened this issue Nov 13, 2017 · 2 comments
Open

ValueError when no reads (same as #3) #5

kautto opened this issue Nov 13, 2017 · 2 comments

Comments

@kautto
Copy link

kautto commented Nov 13, 2017

I'm still getting the same issues as described in #3 , when there are chromosomes that have no reads. I've had this occur both when looking at a single chromosome (in my case, chromosome 8) or when looking at whole genome data (in which case it gets to ...21>22>X>Y>MT and breaks).

  mu = data.mean()
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/numpy-1.13.3-py2.7-linux-x86_64.egg/numpy/core/_methods.py:80: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py:406: RuntimeWarning: Mean of empty slice.
  m2 = ((data - mu)**2).mean()
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py:407: RuntimeWarning: Mean of empty slice.
  m3 = ((data - mu)**3).mean()
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py:2286: RuntimeWarning: Mean of empty slice.
  muhat = tmp.mean()
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py:2287: RuntimeWarning: Degrees of freedom <= 0 for slice
  mu2hat = tmp.var()
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/numpy-1.13.3-py2.7-linux-x86_64.egg/numpy/core/_methods.py:105: RuntimeWarning: invalid value encountered in true_divide
  arrmean, rcount, out=arrmean, casting='unsafe', subok=False)
/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/numpy-1.13.3-py2.7-linux-x86_64.egg/numpy/core/_methods.py:127: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
Traceback (most recent call last):
  File "NAIBR.py", line 88, in <module>
    main()
  File "NAIBR.py", line 59, in main
    data = parallel_execute(run_NAIBR,chroms)
  File "src/utils.py", line 386, in parallel_execute
    data = map(function,input_list)
  File "NAIBR.py", line 33, in run_NAIBR
    cands,p_len,p_rate = get_candidates(discs,reads_by_LR)
  File "src/get_reads.py", line 150, in get_candidates
    p_len,p_rate,barcode_overlap = get_distributions(reads_by_LR)
  File "src/distributions.py", line 114, in get_distributions
    p_rate = get_rate_distr(LRs)
  File "src/distributions.py", line 139, in get_rate_distr
    alpha,loc,beta = scipy.stats.gamma.fit(rate)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_continuous_distns.py", line 2011, in fit
    return super(gamma_gen, self).fit(data, *args, **kwds)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py", line 2171, in fit
    start = self._fitstart(data)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_continuous_distns.py", line 2000, in _fitstart
    return super(gamma_gen, self)._fitstart(data, args=(a,))
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py", line 2019, in _fitstart
    loc, scale = self._fit_loc_scale_support(data, *args)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/scipy-0.18.1-py2.7-linux-x86_64.egg/scipy/stats/_distn_infrastructure.py", line 2239, in _fit_loc_scale_support
    data_a = np.min(data)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/numpy-1.13.3-py2.7-linux-x86_64.egg/numpy/core/fromnumeric.py", line 2372, in amin
    out=out, **kwargs)
  File "/igm/apps/python/Python-2.7.12_install_static/lib/python2.7/site-packages/numpy-1.13.3-py2.7-linux-x86_64.egg/numpy/core/_methods.py", line 29, in _amin
    return umr_minimum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation minimum which has no identity

There's nothing odd about my config file:

# minimum mapping quality (default=40)
min_mapq=40

# input bam file
bam_file=./KAUTTO_Esko/data/17-0020-04_H1576_Tumor.chr8.bam

# output directory (default=.)
outdir=./KAUTTO_Esko/output/NAIBR/17-0020-04_H1576_Tumor/chr8

# list of intervals not to be intcluded in analysis (default=None)
blacklist=None

# list in BEDPE format of novel adjacencies to be scored by NAIBR (default=None)
candidates=None

# maximum distance between read-pairs in a linked-read (default=10000)
d=10000

# minimum size of structural variant (default=lmax)
min_sv=1000

# number of cores (default=1)
cores=4

# minimum number of barcode overlaps supporting a candidate NA (default = 3)
k=3

And I'm using the newest commit eb59166 , so that shouldn't be the issue.. any ideas? Thanks!

@kautto
Copy link
Author

kautto commented Nov 14, 2017

So the issue is specifically occuring in get_rate_distr() in distributions.py

The line

rate = rate[len(rate)/10:len(rate)/10*9]

causes nothing to be selected when you have < 10 entries in the input LRs list, because using integer math, you get 0:0 as your selection range, i.e.

rate[0:0*9] = rate[0:0] = []

and that's what causes the script to break a few lines later with the call to

scipy.stats.gamma.fit(rate)

@relyanow
Copy link
Contributor

Thanks for finding the source of this bug. I'll fix it and push an update shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants