2
저는 Rpy2를 사용하여 Bioconductor에서 고전적인 유전자 발현 example을 수행하는 방법을 알아 내려고하고 있습니다. 데이터를 어떻게로드합니까? R에서 우리가 할 : 파이썬에서RPy2 및 Bioconductor : 유전자 발현 예
> library('ALL')
> library('limma')
> data('ALL')
는 우리가 할 : 패키지 데이터가 어디 있는지 예를 볼 수 없습니다
> data('ALL') ??
:의 파이썬 해당 작업을 수행하는 방법에
>>> import rpy2.robjects as robjects
>>> from rpy2.robjects.packages import importr
>>> base = importr('base')
>>> ALL = importr('ALL')
확장 프로그램의 문서에로드됩니다. 나는이 그것을 할 수 있다고 생각하지만 featureNames
에 공급 때 signature "character"
을 가지고 있기 때문에 데이터를하지 않을 권리 클래스의 것 같습니다 :
>>> data = robjects.r('data(ALL)')
>>> data.rclass
<rpy2.rinterface.SexpVector - Python:0x1004b3828/R:0x10376d558>
>>> featureNames = robjects.r('featureNames')
>>> featureNames(data)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "featureNames", for signature "character"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/rpy2-2.2.2dev_20110818-py2.6-macosx-10.6-universal.egg/rpy2/robjects/functions.py", line 82, in __call__
return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
File "/Library/Python/2.6/site-packages/rpy2-2.2.2dev_20110818-py2.6-macosx-10.6-universal.egg/rpy2/robjects/functions.py", line 34, in __call__
res = super(Function, self).__call__(*new_args, **new_kwargs)
rpy2.rinterface.RRuntimeError: Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "featureNames", for signature "character"
업데이트 : 내가 지금 생각 :
>>> import rpy2.robjects as robjects
>>> from rpy2.robjects.packages import importr
>>> base = importr('base')
>>> ALL = importr('ALL')
>>> data = robjects.r('data(ALL)')
>>> data.rclass
<rpy2.rinterface.SexpVector - Python:0x258b190/R:0xdf86c8>
>>> data = robjects.globalenv['ALL']
>>> data
<RS4 - Python:0x2591490/R:0x29a2134>
>>> data.rclass
<rpy2.rinterface.SexpVector - Python:0x258b3b0/R:0xdf85c8>
>>> featureNames = robjects.r('featureNames')
>>> featureNames(data)
<StrVector - Python:0x23e4f08/R:0x304fc00>
['1000..., '1001..., '1002..., ..., 'AFFX..., 'AFFX..., 'AFFX...]
>>> exprs = robjects.r['exprs']
>>> e = exprs(data)
>>> e
<Matrix - Python:0x23b2da0/R:0x84d8000>
[7.597323, 5.046194, 3.900466, ..., 3.095670, 3.342961, 3.842535]
>>>
고마워요. 나는 문서를 통해 자신의 길을 가고있다. 바로 R 코드를 실행하는이 "지름길"을 보지 못했습니다. – telliott99
확장은 R S4 클래스를 나타내는 파이썬 클래스를 포함합니다. ALL 데이터 세트를로드하려면 rpy2의 기본 설명서에 있습니다. 보십시오 'ALL = importr ("ALL"); ALL.ALL ' – lgautier