-1
我試圖隱蔽UniProt登錄號使用Bioconductor的包org.Hs.eg.db(這是一個S4對象)的Entrez的ID。我也試圖用rpy2作爲Python腳本的一部分。調用select函數會導致錯誤。下面的代碼(該計劃是400線,我摘錄了相關的東西):在Python使用R選擇功能使用rpy2
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")
而且這裏的錯誤信息:
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'>'
我認爲你是對的。改變這種代碼行: 「geneidA = r.select(org.Hs.eg.db,鍵= uniprotA,列= 」ENTREZID「,關鍵字類型=」 UNIPROT 「)」,我現在得到的錯誤:文件「 mitab_preprocess.py 「線路346,在 reformat_data(相互作用) 文件 」mitab_preprocess.py「,管線138,在reformat_data geneidA = r.select(org.Hs.eg.db,鍵= uniprotA,列=」 ENTREZID」的KeyType =‘UNIPROT’) NameError:全局名稱‘組織’沒有定義 –
hannah
不不不。你的Python命名空間被稱爲'homosap'。您可能需要傳遞一個像「homosap」的參數。'。 –
lgautier