merv merv - 2 months ago 5x
R Question

Annotation DB has no 'select' method in rpy2

I have the following code in R:


entrezIDs <- select(hgu133a.db, probeNames, "ENTREZID")

is a list of strings corresponding to probes found in this database.

I am attempting to translate it to Python using rpy2:

from rpy2.robjects.packages import importr
hgu133a_db = importr('hgu133a.db')

entrez_ids =, probe_names, 'ENTREZID')

But receive the error:

AttributeError: module 'hgu133a.db' has no attribute 'select'

I've searched the documentation (
) and as far as I can tell the database hgu133a.db inherits a
method from the AnnotationDbi class.

How do I properly resolve the library where
is coming from, so I can use it in Python?


[should have been a comment to @merv 's answer, but exceeded the number characters]

rpy2's importr() is trying to help a being specific about which package namespace an R object is coming from, while R's common usage is much less so (and can lead to annoyances such as the loading order of R packages having an influence on which one of the functions with the same name is executed).

The tradeoff with importr is that one has to know where an R symbol is coming from. There is a less-known function in rpy2 that can help finding where a given R symbol is defined(*): .

Otherwise, one can also use r() to retrieve the object that would be picked(*) in an R session.

from rpy2.robjects import r

(*: as mentioned earlier, the order in which R packages were loaded earlier in the session can have an influence on which R object is picked).