daler/biomartpy

ValueError: Invalid SEXP type '0' (should be 16) in make_lookup()

Closed this issue · 2 comments

Hi,
I just installed biomartpy and stumbled across something that looks like a bug. Executing:

mart_name = 'ensembl'
dataset = 'dmelanogaster_gene_ensembl'
attributes = ['flybase_gene_id', 'flybasename_gene', 'description']
filters = ['flybase_gene_id']
values = [['FBgn0031208', 'FBgn0002121', 'FBgn0031209', 'FBgn0051973']]

res = bmp.make_lookup(mart_name = mart_name,
                      dataset = dataset,
                      attributes = attributes,
                      filters = filters,
                      values = values)

leads to

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-1bd03cbc42bb> in <module>()
      3                                           attributes = attributes,
      4                                           filters = filters,
----> 5                       values = values)

/Users/nwieder/miniconda3/lib/python3.5/site-packages/biomartpy/__init__.py in make_lookup(mart_name, dataset, attributes, filters, values, unique_rows)
    234 
    235         filter_value_dict = dict(zip(filters, values))
--> 236         _filters, _values = _filter_and_values_to_RList(filter_value_dict)
    237         kwargs['filters'] = _filters
    238         kwargs['values'] = _values

/Users/nwieder/miniconda3/lib/python3.5/site-packages/biomartpy/__init__.py in _filter_and_values_to_RList(d)
    199         # Could use ListVector directly with the dict, but want to guarantee
    200         # positional order of filters and values
--> 201         f = robjects.StrVector(d.keys())
    202         v = robjects.ListVector(
    203             rpy2.rlike.container.TaggedList(

/Users/nwieder/miniconda3/lib/python3.5/site-packages/rpy2-2.7.8-py3.5-macosx-10.5-x86_64.egg/rpy2/robjects/vectors.py in __init__(self, obj)
    363     def __init__(self, obj):
    364         obj = StrSexpVector(obj)
--> 365         super(StrVector, self).__init__(obj)
    366 
    367     def factor(self):

/Users/nwieder/miniconda3/lib/python3.5/site-packages/rpy2-2.7.8-py3.5-macosx-10.5-x86_64.egg/rpy2/robjects/vectors.py in __init__(self, o)
    240         if not isinstance(o, SexpVector):
    241             o = conversion.py2ri(o)
--> 242         super(Vector, self).__init__(o)
    243         self.ro = VectorOperationsDelegator(self)
    244         self.rx = ExtractDelegator(self)

ValueError: Invalid SEXP type '0' (should be 16).

Querying ensembl with a filter dict results in the same error msg, querying without filter and only attributes works flawless. I am not yet very familiar with rpy2, but maybe this is a version issue...

I am using:

  • python 3.5
  • rpy2 2.7.8
  • pandas 0.18
  • bioMart 2.26

This is a great project, keep up the good work!

daler commented

Thanks for reporting this. As you can see, I haven't updated this package in a while. I suspect the problem is likely due to Python 3.

I'm not likely to get around to this for some time, but pull requests would be more than welcome. In the meantime, you might want to check out biomartian or mygene.

Thanks for the advice!
I think I figured out whats going wrong here. Haven't actively contributed to a github repo before, plus I'm not very used to git. So if you want to give it a quick shot, just replace d.key() in the function _filter_and_values_to_RList(d) with the python 3.x version of it list(d.key()). I tried it on my machine and your initial example works again...

Sorry for this unconventional way to suggest corrections. I know I should familiarize myself with git to actually contribute, but I haven't found the time to do so yet :/