Installing R and additional modules

To install R on the machine where you want to run the scripts, download the installation from one of the sites linked to at the R Project .  If you have any problems installing or running R, then it is a good idea to consult the R FAQ .

Once you have R installed, you can start it either on the command line with the command R or using the appropriate application shortcut, where you should get a shell that looks somewhat like this:

R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

You can then install any additional R modules that you want within the R environment.  For example BioConductor can be installed by typing at the R prompt

> source("http://bioconductor.org/biocLite.R")
> biocLite()

which should give something like:

Using R version 2.11.1, biocinstall version 2.6.9.
Installing Bioconductor version 2.6 packages:
 [1] "affy"          "affydata"      "affyPLM"       "affyQCReport"
 [5] "annaffy"       "annotate"      "Biobase"       "biomaRt"
 [9] "Biostrings"    "DynDoc"        "gcrma"         "genefilter"
 [13] "geneplotter"  "GenomicRanges" "hgu95av2.db"   "limma"
 [17] "marray"       "multtest"      "vsn"           "xtable"
Please wait...

...

The downloaded packages are in
    /var/folders/VL/VL4xSzoyGtyxaFs7KbdEU++++TI/-Tmp-//RtmpIqtotc/downloaded_packages
>

Installing Rserve

Taverna communicates with the R installation using the RServe protocol. Follow the installation instructions for RServe for information on how to install and start the RServe service.

If the machine that is running Rserve is restarted, then you will need to restart Rserve.

Rserve within R

RServe can be installed and started within the R environment.

> install.packages("Rserve")
--- Please select a CRAN mirror for use in this session ---
CRAN mirror

...

> library(Rserve)
> Rserve()

Starting Rserve on port 6311 :
 /Library/Frameworks/R.framework/Resources/bin/R CMD /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve-bin.so


R version 2.11.1 (2010-05-31)
Copyright (C) 2010 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Rserv started in daemon mode.

Note: On a Mac if you get:

Fatal error: you must specify '--save', '--no-save' or '--vanilla'
use:  Rserve(args="--no-save")

Rserve from the command line

Alternatively, Rserve can be started from the command line.

For Unix users:

Download the latest Rserve snapshot from RForge  - it is Rserve_0.6-3.tar.gz as of November 2010.
In the download directory, at the command line enter:

R CMD INSTALL Rserve_0.6-3.tar.gz

which will cause:

* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *source* package ‘Rserve’ ...
checking whether to compile the server... yes

...

* DONE (Rserve)

You may need to sudo to a user with permission to install new R source packages

Rserve can then be run from the command line using:

sudo -u nobody R CMD Rserve

We strongly recommend that you run Rserve as a separate, non-privileged user account ("nobody" in the above) so that if there is a security problem, the R script won't be able to access your files (unless you explicitly expose them) and the script can be easily isolated.

For Windows users

Download the latest Rserve Windows binary from RForge - it is Rserve_0.6-2.zip as of November 2010.

The files in the zip file need to be extracted so that Rserve.exe is in the same directory as R.dll from the R installation. For example, extract the files so that Rserve.exe is in C:\Program Files\R\R-2.12.0\bin\i386   

Rserve can be run from the command line (if you ensure that Rserve.exe is in your path) or you can create a shortcut to it.

The first time that you run Rserve, you may be prompted to allow Rserve access to ports on the machine.  You may also need to alter the firewall settings to allow access to Rserve

Allowing Taverna access to Rserve

If your workflows run R scripts using an Rserve on the same machine where you run Taverna, then there is no extra configuration of Rserve needed.  Taverna can immediately access it.

If you want your workflows to run R scripts on a different machine from where you run Taverna, then you need to configure Rserve to allow access.  A full description of the configuration possibilities can be found on Rforge .

It is very dangerous to allow unauthorized access to an Rserve. For this reason, although auth defaults to disable, always specify it as enabled and specify a password file.

For Unix users, the configuration file for Rserve defaults to /etc/RServ.conf.

For Windows users, the configuration file defaults to being in the R installation directory, for example C:\Program Files\R\R-2.12.0\bin\i386\Rserv.cfg

The configuration file may need to be created. Also, note the lack of "e" in the file names.

You can put the password file anywhere to which Rserve has read access. However, it is a good idea to put it in the same directory as the configuration file e.g. as /etc/RServ.pwd or C:\Program Files\R\R-2.12.0\bin\i386\Rserv.pwd.

Changing the configuration file

Change the configuration file to (replacing <password_file> with where you put the password file)

pwdfile <password_file>
remote enable
auth required
encoding utf8

Specifying the password file

The password file contains a list of Rserve usernames and passwords, with one username and password per line.

The Rserve usernames have no relationship to the users on the machine where the Rserve is running.  If you want to connect to an Rserver as Rserve user "stian", there does not need to be a user "stian" on the Rserve machine.  If there is a user "stian" on the Rserve machine, then connecting via the Rserver as "stian" will not give any R scripts run by the Rserve user any additional access to files.

The Rserve passwords have no relationship to the passwords of users on the machine where the Rserve is running.

It is a good idea to keep the usernames for Rserve different to those of the machine where Rserve is running.  This prevents confusion.

If the same username is used in Rserve and the machine's operating system then make sure that the passwords are different.

A password file will look something like:

alanw frog
stian fishsoup

This would allow access to Rserve with the username alanw and password frog.

Checking that Rserve can be accessed

To check if you have an Rserve installed and running on a particular machine, you can run the command

telnet themachine theport

For example,

telnet localhost 6311

If you have an accessible Rserve, then you should see a response such as:

Connected to localhost.
Escape character is '^]'.
Rsrv0103QAP1

If you get a connection refused, then the Rserve is not running or cannot be accessed.