[R] Calling R from a Perl script: much slower?

J.delasHeras at ed.ac.uk J.delasHeras at ed.ac.uk
Fri Sep 4 17:34:14 CEST 2009


Ah! sorted!

it was NOT running the same code.

We're making a GUI using Perl (Tcl/Tkx) to facilitate a number of  
analyses in our lab to other people who don't necessarily want to know  
about R (their loss ;-)

I provided the R code to my colleague and he assured me he used it  
without changes... but when I've looked into it, there were a number  
of changes... (?) I restored the code to what I knew to work and from  
the Tcl/Tkx GUI it's *almost* as fast as when I run it from a clean  
session from the R console. So that was the problem.

In case I'm still not doing things teh best way, we're invoking R from  
Perl like this:

invoking the script from Perl:
@output = qx($R.exe --vanilla --args $list of arguments...)

should I use Rterm.exe or Rcmd.exe instead of R.exe?

Jose




Quoting jim holtman <jholtman at gmail.com>:

> What operating system are you running under?  You should take a look
> at the R process and see how much time it is using to see if there is
> a difference in the CPU time.  Are you paging?  Exactly how are you
> invoking the R script?  Why are you using the GUI instead of Rterm?
> You might try to run Rprof on the code to see if there are
> differences.  Are you sure you are running exactly the same data in
> both cases?
>
> On Thu, Sep 3, 2009 at 11:42 AM, <J.delasHeras at ed.ac.uk> wrote:
>>
>> Hello list,
>>
>> I use R for microarray analysis.
>> One procedure I use takes a large matrix, and loops through it looking for
>> specific rows, does an operation with them, and outputs a result (single
>> row) as a row of another matrix. The loop goes on about 25000 times.
>>
>> When I run the loop directly from the R console itself, it takes about 3
>> minutes in my computer. I'm ok with that.
>>
>> Now, when that same code is ran from within a GUI we created using Perl
>> (Tcl/Tkx) it's taking 25-30 minutes to run.
>>
>> Within the R code I inserted a line so that it writes a little file every
>> 1000th iteration of the loop, so that I can follow the progress. I don't
>> understand why it takes 10x longer when ran from Perl.
>>
>> I am not new to R, but I am new to using it within Perl or any other
>> language. Is there a way to improve performance? What is the reason for the
>> slower speed?
>>
>> I'll happily provide the code if somebody wants it.
>>
>> thank you.
>>
>> Jose
>>
>> --
>> Dr. Jose I. de las Heras                      Email: J.delasHeras at ed.ac.uk
>> The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
>> Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
>> Swann Building, Mayfield Road
>> University of Edinburgh
>> Edinburgh EH9 3JR
>> UK
>> *********************************************
>> NEW EMAIL from July'09: nach.mcnach at gmail.com
>> *********************************************
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
>



-- 
Dr. Jose I. de las Heras                      Email: J.delasHeras at ed.ac.uk
The Wellcome Trust Centre for Cell Biology    Phone: +44 (0)131 6513374
Institute for Cell & Molecular Biology        Fax:   +44 (0)131 6507360
Swann Building, Mayfield Road
University of Edinburgh
Edinburgh EH9 3JR
UK
*********************************************
NEW EMAIL from July'09: nach.mcnach at gmail.com
*********************************************

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.




More information about the R-help mailing list