May be with deseq.estimateVarianceFunctions ?
On 2011-10-07 16:09, Nick Schurch wrote:
on a related matter, I've put a local install of pyr2 on my machine
(also running R2.12.1) and tried the script you suggested:
Python 2.6.4 (r264:75706, Sep 10 2010, 16:37:14)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from rpy2.robjects.packages import importr
>>> base = importr('base')
>>> deseq = importr('DESeq')
locfit 1.5-6 2010-01-20
>>> my_env = base.new_env()
>>> rdata_filename = "mydata.Rdata"
>>> base.load(rdata_filename, envir = my_env)
<StrVector - Python:0x7ba1998 / R:0x8a0c4c8>
['z']
>>> deseq.estimateVarianceFunction(my_env['z'])
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'SignatureTranslatedPackage' object has no attribute
'estimateVarianceFunction'
>>>
I'm not sure why its doing this, but I don't thing importr('DESeq') is
loading everything it needs. Under rpy v1 I was using
>>> r.library("DESeq")
Loading required package: locfit
Loading required package: akima
Loading required package: lattice
locfit 1.5-6 2010-01-20
c.f.
>>> deseq = importr('DESeq')
locfit 1.5-6 2010-01-20
any ideas?
Nick
On 7 October 2011 14:46, Nick Schurch <n.schu...@dundee.ac.uk
<mailto:n.schu...@dundee.ac.uk>> wrote:
Doh! You are, of course, correct. Thansk again for the help it is
working fine now.
The rpy2 way looks a lot nicer than the horrible hacks I'm writing
now though, so I guess I should make the effor to start using that
and convert all mu old codes.
Thanks again!
Nick
On 7 October 2011 14:37, Laurent Gautier <lgaut...@gmail.com
<mailto:lgaut...@gmail.com>> wrote:
Did you terminate your session and restarted ?
If not, it won't work until you clear
"estimateVarianceFunction" from the current R GlobalEnv.
L.
On 2011-10-07 15:33, Nick Schurch wrote:
Thanks for the swift replies!
I've tried renaming the function and running things again and
unfortunately this doesn't solve the problem.
So:
r('testVarFunc <-
function(rdata){x=estimateVarianceFunctions(rdata)\nstr(x)\nreturn(x)}')
returns exactly the same error. Unfortunately at the moment
I'm stuck using rpy v1 until rpy2 gets installed on our
cluster. Could it be a problem with using rpy rather than rpy2?
Nick
On 7 October 2011 12:57, Laurent Gautier <lgaut...@gmail.com
<mailto:lgaut...@gmail.com>> wrote:
On 2011-10-07 13:05, Thomas Kluyver wrote:
On 7 October 2011 11:57, Nick Schurch
<n.schu...@dundee.ac.uk <mailto:n.schu...@dundee.ac.uk>>
wrote:
r('estimateVarianceFunctions <-
function(){load("mySavedR.rdata")\nx=estimateVarianceFunctions(z)\nreturn(x)}')
and then call it from python:
>>> test = r.estimateVarianceFunctions()
I get:
Traceback (most recent call last):
File "<console>", line 1, in <module>
RPy_RException: Error: evaluation nested too deeply:
infinite recursion / options(expressions=)?
By giving your function the same name as the function
from the library, I assume you're overriding it. This
would mean your function calls itself instead of the
library function, and recurses infinitely.
Thomas' intuition about an infinite recursion is correct.
The R statement is creating a copy in the search path
found before the one from the package DESeq.
There is a bit of documentation about that at:
http://rpy.sourceforge.net/rpy2/doc-2.2/html/rinterface.html#sexpenvironment
Why not call your function something else (even just
"myEstimateVarianceFunctions" or
"wrapperEstimateVarianceFunctions")?
There is also some demo code to use related Bioconductor
code (edgeR). By chronological order:
-
http://bcbio.wordpress.com/2009/09/13/differential-expression-analysis-with-bioconductor-and-python/
- http://www.biomedcentral.com/1471-2105/11/S12/S11
Statements like the one just below can be confusing and
error-prone, obviously.
r('estimateVarianceFunctions<-
function(){load("mySavedR.rdata")\nx=estimateVarianceFunctions(z)\nreturn(x)}')
Consider replacing it with:
from rpy2.robjects.packages import importr
base = importr('base')
deseq = importr('DESeq')
def estimate_variance(rdata_filename = "mySaveR.rdata"):
my_env = base.new_env()
# keep R's GlobalEnv clean (and avoid overwriting elements)
base.load(rdata_filename, envir = my_env)
return deseq.estimateVarianceFunction(my_env['z'])
estimate_variance()
Thomas
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously
valuable.
Why? It contains a definitive record of application performance,
security
threats, fraudulent activity, and more. Splunk takes this data and
makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
<mailto:rpy-list@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/rpy-list
--
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707 <tel:%2B44%201382%20388707>
Fax: +44 1382 345 893
--
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707
Fax: +44 1382 345 893
<tel:%2B44%201382%20345%20893>
--
Cheers,
Nick Schurch
Data Analysis Group (The Barton Group),
School of Life Sciences,
University of Dundee,
Dow St,
Dundee,
DD1 5EH,
Scotland,
UK
Tel: +44 1382 388707
Fax: +44 1382 345 893
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list