Repository navigation
Closed
Description
I'm having some trouble getting the mitochondrial gene query to not throw an error. Here's an example:
import scanpy.api as sc
sc.queries.mitochondrial_genes(host="www.ensembl.org", org="hsapiens")The output and traceback
You must set the host (e.g. f.host='www.ensembl.org'
You must set the host (e.g. f.host='www.ensembl.org'
You must set the host (e.g. f.host='www.ensembl.org'
You must set the host (e.g. f.host='www.ensembl.org'
You must set the host (e.g. f.host='www.ensembl.org'
You must set the host (e.g. f.host='www.ensembl.org'
---------------------------------------------------------------------------
EmptyDataError Traceback (most recent call last)
<ipython-input-14-a6967c88fd61> in <module>()
----> 1 sc.queries.mitochondrial_genes(host="www.ensembl.org", org="hsapiens")
/usr/local/lib/python3.6/site-packages/scanpy/queries/__init__.py in mitochondrial_genes(host, org)
40
41 # parsing mitochondrial gene symbols
---> 42 res = pd.read_csv(StringIO(s.query(xml)), sep='\t', header=None)
43 res.columns = ['symbol', 'chromosome_name']
44 res = res.dropna()
/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision)
676 skip_blank_lines=skip_blank_lines)
677
--> 678 return _read(filepath_or_buffer, kwds)
679
680 parser_f.__name__ = name
/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
438
439 # Create the parser.
--> 440 parser = TextFileReader(filepath_or_buffer, **kwds)
441
442 if chunksize or iterator:
/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
785 self.options['has_index_names'] = kwds['has_index_names']
786
--> 787 self._make_engine(self.engine)
788
789 def close(self):
/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
1012 def _make_engine(self, engine='c'):
1013 if engine == 'c':
-> 1014 self._engine = CParserWrapper(self.f, **self.options)
1015 else:
1016 if engine == 'python':
/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1706 kwds['usecols'] = self.usecols
1707
-> 1708 self._reader = parsers.TextReader(src, **kwds)
1709
1710 passed_names = self.names is None
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
EmptyDataError: No columns to parse from fileThe arguments I've passed there are whats in the documentation for the function, so I'd figured I'd give them a shot first. I've also tried host="www.ensembl.org/biomart", but had no such luck.
This is after installing the bioservices module via pip and it creating some config file the first time I tried to run the query.
Metadata
Metadata
Assignees
Labels
No labels
Activity
fbrundu commentedon Aug 27, 2018
I had this error in the past. Try with a different mirror, you can look them from here. For example, I usually use
useast.ensembl.org.Hope it helps.
ivirshup commentedon Aug 28, 2018
I'd tried
asia.ensembl.org, but no luck there.Has the function worked for you?
fbrundu commentedon Aug 28, 2018
Try with
useast.ensembl.org. I am unable to retrieve anything fromasia.useastworks, see below. I think this is a problem on ensembl servers, not of scanpy API.ivirshup commentedon Aug 29, 2018
I still get the same error with
useastThe output and traceback
But it seems to work no matter what server I choose in R, here's the test code
I don't think the issue is with ensembl's servers. Is it possible you have a config for this
bioservicesmodule you've done anything with?ivirshup commentedon Aug 29, 2018
Just found this:
So I'll go open an issue with the
bioservicespackage.fbrundu commentedon Aug 29, 2018
Weird behavior, I have the same version
1.5.2but no issues..ivirshup commentedon Sep 9, 2018
I did a little more looking into this, and think I see what's going on. If you set the host, it sends a query to the host to make sure it's real. If it doesn't get a 200 response, it silently fails and does not set the host. Every time I've checked,
www.ensembl.orgreturns some30*code, which is a redirect, and would successfully fill any query anyways.asia.ensembl.orgmight have actually been down when I was checking, but it might be worth updating the docs that this probably won't work withwww.ensembl.org.Also I'm pretty sure setting the host at instantiation would never work, cause I don't see it happening in their
__init__function.gokceneraslan commentedon Dec 26, 2018
useast.ensembl.orgseems to be working.fbrundu commentedon Jan 23, 2019
You can check if the mirror is working by using the url:
http://<ensembl_biomart_mirror>/biomart/martview
This is the url used internally by bioservices. The available mirrors are listed here.
For example, at the moment the mirror useast is not available.
I think we can close this issue since it's not related to the scanpy's code.
ivirshup commentedon Jan 24, 2019
I'd argue a janky dependency is an issue with scanpy's code, as there are interfaces to BioMart which are better behaved. Here's a proof of concept:
Running it:
The drawback with pybiomart is it's unclear how actively it's maintained. However if this looks reasonable to you, I can open a PR with this change.
fbrundu commentedon Jan 24, 2019
I agree but I'm not in charge of the PRs. Probably a better solution would be to provide a backend parameter in the PR to choose which module to use. In my opinion bioservices looks more mature and maintained.
falexwolf commentedon Jan 26, 2019
Hm, my impression is also that
bioservicesis relatively mature but tries to achieve a lot of things.pybiomartlooks minimalistic and evidently only focuses on interfacing biomart and has a high coverage, which is nice. For that reason, I tend to prefer @ivirshup implementation over the @fbrundu's originalbioservices-based one.But I don't have a strong opinion. I would not have implementations for two "backends" here for such a simple thing (querying biomart).
@fbrundu, would you be alright with changing this to @ivirshup implementation?
fbrundu commentedon Jan 26, 2019
Of course! Whatever works, I don't mind have the implementation changed..
Thanks
LuckyMD commentedon Jan 28, 2019
Maybe I could throw in another ID mapping tool. BED is pretty good. More comprehensive than Biomart and quicker too. It is however a local implementation that runs in a docker container. The image is updated every month or so. At the moment I run a container internally here... but maybe we could make a webserver out of this which can be directly integrated with scanpy?
falexwolf commentedon Feb 3, 2019
Interesting, but hm, I can't really judge on BED... sounds like a more long-term and comprehensive project?
LuckyMD commentedon Feb 4, 2019
It's probably not a quick fix, you are right. Just thought that if future ID mapping is considered here, it would be good to add an option.
I could add a python API (I have a barebones version already) and we could add it to
scefor anyone who is running a local BED container anyway?falexwolf commentedon Feb 5, 2019
Yes, in
scethis would be welcome!LuckyMD commentedon Feb 5, 2019
It's on my Todo list!
ivirshup commentedon Feb 6, 2019
Just an update, I've got the PR mostly done, but I'm having trouble keeping the arguments to
sc.queries.gene_coordinatessimple. Could someone who uses that function show me their use case? Is it that common to want the coordinates for only one gene, but also want to limit the coordinates to particular coordinates?Would it be reasonable to replace this function with something more simple and open ended? I'm thinking just letting the user specify an organism and the fields they'd like.
Here's a doc-string for what I'm thinking:
ivirshup commentedon Feb 6, 2019
@LuckyMD that BED tool does look cool, and I can think of a couple times it'd would've been really useful. Is it easy to get information beyond gene-ids out of it? For instance, could I give a uniprot id and get transcript locations from ensembl?
flying-sheep commentedon Feb 6, 2019
Yes. The only problem with BED is that it’s super large and needs quite some memory to run as well. Having a publicly hosted instance backed by some rich company would be great.
LuckyMD commentedon Feb 6, 2019
The latest BED docker image is 1.62 GB, which is not that big for an ID mapping DB I reckon (with the docker environment of course). You can also build your own, more limited versions of the database. There are instructions for this in the github.
BED memory usage I haven't really checked. Server side it's using 1 GB idly at the moment, no idea how that changes at peak usage. It has a client-side cache system to speed up multiple look-ups, but that can be turned off to limit client-side memory usage.
And yes, as @flying-sheep said it's really easy to use for mapping between biological entities and even organisms as well. For transcript locations, you may need to use a separate file that contains the locations which will probably be annotated with RefSeq IDs. You can get to the RefSeq IDs easily though.
It was actually designed for company use... but I think Thompson-Reuters (now Clarivate analytics) or UCB aren't interested in hosting public servers ;).
flying-sheep commentedon Nov 13, 2019
This was fixed in #467, right?
ivirshup commentedon Nov 14, 2019
👍