I'm trying to covert UniProt accession numbers to Entrez IDs using the BioconductoR package org.Hs.eg.db (which is an S4 object). I'm also trying to do this as part of a Python script with rpy2. Calling the select function gives me errors. Here's the code (the program is 400 lines, I'm excerpting the relevant stuff):
from rpy2.robjects.packages import importr
from rpy2.robjects import StrVector, DataFrame, r
# get UniProt accension numbers from first two columns of data
uniprotA = []
uniprotB = []
for row in interactions:
uniprotA.append(row[0][10:])
uniprotB.append(row[1][10:])
# convert to vectors in r
uniprotA = StrVector(uniprotA)
uniprotB = StrVector(uniprotB)
homosap = importr('org.Hs.eg.db')
geneidA = r.select(homosap, keys = uniprotA, columns = "ENTREZID", keytype="UNIPROT")
And here are the error messages:
Traceback (most recent call last):
File "mitab_preprocess.py", line 356, in <module>
reformat_data(interactions)
File "mitab_preprocess.py", line 140, in reformat_data
geneidA = r.select(homosap, keys = uniprotA, columns = "ENTREZID", keytype="UNIPROT")
File "//anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py", line 178, in __call__
return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
File "//anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py", line 102, in __call__
new_args = [conversion.py2ri(a) for a in args]
File "//anaconda/lib/python2.7/site-packages/singledispatch.py", line 210, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
File "//anaconda/lib/python2.7/site-packages/rpy2/robjects/conversion.py", line 60, in _py2ri
raise NotImplementedError("Conversion 'py2ri' not defined for objects of type '%s'" % str(type(obj)))
NotImplementedError: Conversion 'py2ri' not defined for objects of type '<class 'rpy2.robjects.packages.InstalledSTPackage'>'