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
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

Reply via email to