Open pmonnahan opened 4 years ago
Thanks @pmonnahan .
This looks to reproduce with:
import allel
import numpy as np
pos = np.random.choice(100_000, 100, replace=False)
gn = np.random.randint(0, 3, (100, 100))
r2, windows, counts = allel.windowed_r_squared(pos, gn, size=5000, start=1, stop=100_000, fill=-9)
And this line (equivalent) causes the error:
np.percentile(np.array([]), 50)
I guess a check for the shape of gnw
is the best option here.
Thanks @hardingnj for the reprex and marking for change. Also, thanks to you and others for such a great package.
Hi,
I have been trying to implement the windowed_r_squared function, and I believe that I've come across a bug related to windows containing a single SNP. Below is a snippet generated via pdb, showing that the error arises within the 'windowed_statistic' function. I noticed in the source code of 'windowed_statistic' that there is an 'if n==0' catch and am wondering if this needs to be generalized for r2 calculations where a pair of observations is required at a minimum.
I could increase window size or try to identify and remove these windows beforehand, but I thought I would check whether this is a known (or non-) issue on your end.
... After about 5 windows with error-free calculation, I encounter this:
Thanks!