Feeds:
Posts
Comments

Archive for the ‘R’ Category

This is a working example to setup JRI.
download and setup R
tar zxvf R-2.15.3.tar.gz

Compile R:
./configure –enable-R-shlib  –with-readline=no –with-x=no
make

export R_HOME= ~/R-2.15.3
cd R-2.15.3/bin
./R

Install JRI
install.packages(“rJava”)
JRI will be installed at R-2.15.3/library/rJava
ll ~/R-2.15.3/library/rJava
total 68
-rw-r–r–. 1 rezca re 620 Apr 2 15:04 DESCRIPTION
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 help
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 html
-rw-r–r–. 1 rezca re 2403 Apr 2 15:04 INDEX
drwxr-xr-x. 3 rezca re 4096 Apr 2 15:04 java
drwxr-xr-x. 3 rezca re 4096 Apr 2 15:04 javadoc
drwxr-xr-x. 3 rezca re 4096 Apr 2 15:04 jri
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 libs
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 Meta
-rw-r–r–. 1 rezca re 1197 Apr 2 15:04 NAMESPACE
-rw-r–r–. 1 rezca re 20775 Apr 2 15:04 NEWS
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 R

ll ~/R-2.15.3/library/rJava/jri
total 280
drwxr-xr-x. 2 rezca re 4096 Apr 2 15:04 examples
-rw-r–r–. 1 rezca re 10272 Apr 2 15:04 JRIEngine.jar
-rw-r–r–. 1 rezca re 71874 Apr 2 15:04 JRI.jar
-rwxr-xr-x. 1 rezca re 157839 Apr 2 15:04 libjri.so
-rw-r–r–. 1 rezca re 32354 Apr 2 15:04 REngine.jar
-rwxr-xr-x. 1 rezca re 767 Apr 2 15:04 run

To avoid  this error java.lang.UnsatisfiedLinkError: no jri in java.library.path
the directory containing libR.so must be in LD_LIBRARY_PATH
export LD_LIBRARY_PATH=~/R-2.15.3/lib

Download test example
There are some examples in this file https://rforge.net/JRI/snapshot/JRI_0.5-5.tar.gz
tar zcvf JRI_0.5-5.tar.gz
cd JRI/examples
Compile the example:
~/jdk1.7.0_21/bin/javac -cp ~/R-2.15.3/library/rJava/jri/JRIEngine.jar:~/R-2.15.3/library/rJava/jri/JRI.jar:~/R-2.15.3/library/rJava/jri/REngine.jar rtest.java

Run the test:
~/jdk1.7.0_21/bin/java -Djava.library.path=/udd/rezca/R-2.15.3/library/rJava/jri -cp ~/R-2.15.3/library/rJava/jri/JRIEngine.jar:~/R-2.15.3/library/rJava/jri/JRI.jar:~/R-2.15.3/library/rJava/jri/REngine.jar:. rtest

Read Full Post »

How to Install an R Package

1. Install from bioconductor
$R
>source(http://www.bioconductor.org/biocLite.R)
>biocLite(“DESeq”,lib=”/mnt/galaxyTools/galaxy-central/tools/lpm_tools/my_R_lib”)
This will install the package DESeq to the custom directory

Full arguments:

pkgs
    Character vector of Bioconductor packages to install.
destdir
    File system directory for downloaded packages.
lib
    R library where packages are installed.
http://www.bioconductor.org/install/
2. Install from downloaded source
$ R CMD INSTALL deseq*.tar.gz -l =/mnt/galaxyTools/galaxy-central/tools/lpm_tools/my_R_lib

Full arguments:

R CMD INSTALL [options] [-l lib] pkgs
pkgs a space-separated list with the path names of the packages to be installed.
lib the path name of the R library tree to install to. Also accepted in the form –library=lib. Paths including spaces should be quoted, using the conventions for the shell in use.
options a space-separated list of options through which in particular the process for building the help files can be controlled. Use R CMD INSTALL --help for the full current list of options.

http://stat.ethz.ch/R-manual/R-devel/library/utils/html/INSTALL.html
3. Install from CRAN
> install.packages(“DESeq”, lib=”/mnt/galaxyTools/galaxy-central/tools/lpm_tools/my_R_lib”)

Full arguments
install.packages(pkgs, lib, repos = getOption(“repos”),
                 contriburl = contrib.url(repos, type),
                 method, available = NULL, destdir = NULL,
                 dependencies = NA, type = getOption(“pkgType”),
                 configure.args = getOption(“configure.args”),
                 configure.vars = getOption(“configure.vars”),
                 clean = FALSE, Ncpus = getOption(“Ncpus”, 1L),
                 libs_only = FALSE, INSTALL_opts, …)

http://www.inside-r.org/r-doc/utils/install.packages

The corresponding method to load this package
> library(“DESeq”, lib.loc=”/mnt/galaxyTools/galaxy-central/tools/lpm_tools/my_R_lib”)

Full arguments:

library(package, help, pos = 2, lib.loc = NULL,
        character.only = FALSE, logical.return = FALSE,
        warn.conflicts = TRUE, quietly = FALSE,
        keep.source = getOption(“keep.source.pkgs”),
        verbose = getOption(“verbose”))

require(package, lib.loc = NULL, quietly = FALSE,
        warn.conflicts = TRUE,
        keep.source = getOption(“keep.source.pkgs”),
        character.only = FALSE)

http://127.0.0.1:11495/library/base/html/library.html

Read Full Post »