-
Notifications
You must be signed in to change notification settings - Fork 167
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
scatter plot: avoid pandas positional index error #393
Conversation
When creating a scatter plot with a single chromosome, it can error out with: ``` File "build/bdist.linux-x86_64/egg/cnvlib/commands.py", line 914, in _cmd_scatter File "build/bdist.linux-x86_64/egg/cnvlib/scatter.py", line 49, in do_scatter File "build/bdist.linux-x86_64/egg/cnvlib/scatter.py", line 216, in chromosome_scatter File "build/bdist.linux-x86_64/egg/cnvlib/scatter.py", line 340, in select_range_genes File "build/bdist.linux-x86_64/egg/skgenome/gary.py", line 370, in in_range File "/usr/local/share/bcbio/anaconda/lib/python2.7/site-packages/future/builtins/newnext.py", line 59, in newnext return iterator.next() File "build/bdist.linux-x86_64/egg/skgenome/intersect.py", line 92, in iter_ranges File "/usr/local/share/bcbio/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 1373, in __getitem__ return self._getitem_axis(maybe_callable, axis=axis) File "/usr/local/share/bcbio/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 1819, in _getitem_axis return self._get_list_axis(key, axis=axis) File "/usr/local/share/bcbio/anaconda/lib/python2.7/site-packages/pandas/core/indexing.py", line 1797, in _get_list_axis raise IndexError("positional indexers are out-of-bounds") IndexError: positional indexers are out-of-bounds ``` There is a similar issue reported on BioStars (https://www.biostars.org/p/326154/). Using loc instead of iloc, inspired by this StackOverflow discussion (https://stackoverflow.com/questions/44123056/indexerror-positional-indexers-are-out-of-bounds-when-theyre-demonstrably-no) fixes the issue for my failing cases.
Ack. Thanks! |
I'm not sure about this. On my end,
|
Eric; |
No worries, I've rolled it back pending a full investigation. There could be something to do with the versions of numpy and pandas, I know they've both been fine-tuning their slice/index behaviors to be more rigorous. |
Hi, Thank you for cnvkit! I'm using your docker container like this: I need some help with the plots. Here's what I'm seeing:
Here's that index error I mentioned above:
Is there a workaround to get single chromosomes to work? I also see a lot of RuntimeWarning's (even just with "cnvkit.ph -h") but I saw on another thread that they could probably be safely ignored. |
In skgenome.intersect, if chromosome but no start/end coordinates are given, both iter_range and idx_ranges were trimming the table to the specified chromosome. Apparently that was messing up the dataframe's index. Now, iter_ranges leaves that work to idx_ranges.
When creating a scatter plot with a single chromosome, it can error out
with:
There is a similar issue reported on BioStars (https://www.biostars.org/p/326154/).
Using loc instead of iloc, inspired by this StackOverflow discussion (https://stackoverflow.com/questions/44123056/indexerror-positional-indexers-are-out-of-bounds-when-theyre-demonstrably-no)
fixes the issue for my failing cases.