cooltools icon indicating copy to clipboard operation
cooltools copied to clipboard

Rarely reproducible error with fftconvolve for expected_cis

Open agalitsyna opened this issue 2 years ago • 1 comments

clever solution that immensely speeds up the expected_cis calculation is to do fast Fourier convolution for calculation of pairwise distances between bad bins (here). However, at least with latest scipy version 1.8.1, there is a rarely encountered problem that fftconvolve produces NaNs for all of the output (it is not stochastic, but happens for some shapes of bad bins vectors). Because we explicitly convert nans to integers, they become negative very large numbers. (noticed by @kannandeepti ) I do not know what might be a problem with fftconvolve, but maybe we can pass an option to calculate regular convolution?

E.g. this scipy.signal.convolve(x, x[::-1], mode="full", method="direct") will produce no error if used instead of: https://github.com/open2c/cooltools/blob/ab5d775ee50fb3d4483520a40f758914348e89b7/cooltools/api/expected.py#L57

agalitsyna avatar Jun 03 '22 01:06 agalitsyna