R is a popular, powerful and a free statistical package. In the ABCC, R software (version 2.7.1) is installed in /opt/nasapps and is available from tork.ncifcrf.gov and small blade center (SBC). You will need your ABCC username & password to access tork (& SBC).

Compilers Used: Intel Compiler Collection icc/ifort: 10.0.023 MKL: 9.1

How to run R?

Add /opt/nasapps/bin, to your path, and type R.

The following are the added Packages for R-2.7.1.

Bioconductor version 2.2

Rmpi Version (0.5-5) an interface wrapper to MPI APIs has been installed and added to R-2.7.1 libraries.

Many Other Packages were added to the basic R-installation. Which includes, GEOquery, graph, RMySQL: R interface to the MySQL database (version 0.6-1 ) and RSQLite.

The following is the full library collection in R-2.7.1: affy, affydata, affyio, affyPLM, affyQCReport, annaffy, annotate, AnnotationDbi, base, Biobase, Biostrings, boot, class, cluster, codetools, datasets, DBI, DynDoc, foreign, gcrma, geneplotter, GEOquery, GO.db, graph, graphics, grDevices, grid, hgu95av2.db,KEGG.db, KernSmooth, lattice, limma, marray, MASS, matchprobes, methods, mgcv, multtest, nlme, nnet, preprocessCore, RcolorBrewer, RMySQL, rpart, RSQLite, spatial, splines, stats, stats4, survival, tcltk, tools, utils, vsn, xtable

The following section will explain how to add packages/libraries in R

There are two ways to add packages in R. The first one needs administrative privileges and will add packages to the standard R library collection (a directory containing all the standard and administrator added packages). The second one doesn't require root access and can be used to install package(s) in a local library (usually a directory of User's choice). User(s) can add any number of packages and can then add his local library(ies) to the standard R library. In this document, I will explain how you can add R-packages using the second method.

In this document, unix and R commands are shown in red and blue fonts.

  1. Log into the ABCC front node, tork
      ssh tork.ncifcrf.gov
    
  2. Let us see how we can create local R-package libraries and use them in R. For this example, let us take a R package called UsingR. This package is not part of our R library, but, I have downloaded this package from a R-repository. Please go ahead and download this by clicking on the package name, UsingR_0.1-8.tar.gz. After downloading, do a listing ( ls) command to make sure that you have the file, UsingR_0.1-8.tar.gz, in your local directory. Now make a subdirectory called myRlibs under your HOME directory to build your own R-package library.
     
    cd   
    mkdir ~/myRlibs 
    

    In this exercise, we will be using Intel compilers (C/Fortran) to compile and create library files. Make sure you are pointing to intel compilers (icc and ifort), by typing

    whereis icc 
    whereis ifort
    

    If you want you can use GNU compiler collection or G95 for compilation. Please note that not all packages use compilers.

    For example, suppose if we are interested in using a package called UsingR. UsingR is a collection of datasets to learn basic statistics. First, we have to find out whether this package is already installed in our R installation. Type

       R
    
    to start a new R session.
     library()
    

    to list the packages that are available. Use spacebar to scroll through the library listing and type q to come out of the listing. Use q() to come out of the R session. Type n to the question, save workspace image. When we scrolled through the list, we found that UsingR is not part of our R library. In the next few paragraphs, I will explain how you can add packages without super-user privileges.

    Make sure you are out of R session, then type the following command:

     R CMD INSTALL -l myRlibs UsingR_0.1-8.tar.gz 

    The command INSTALL will install UsingR under myRlibs directory. Do a listing command, ls myRlibs , to make sure that a directory called UsingR exists.

    Now, let us see how we can force R to use myRlibs as an additional library location.

  3. Start R
    R 
    
    From within R session, type
    .libPaths()
    
    (Note: the "." before libPaths).

    This should list the standard R-library path

    "/usr/local/inst/R-2.6.0/library" 
    
    Now, type
    
     .libPaths(c("~/myRlibs"))
     library(usingR)
    
    

    (Note: the "." before libPaths.) This should list the standard R-library path and package(s) you had added to your local R-library (ie myRlibs). For example, in my case, when I type library() , I see the following output.

    Packages in library '~/myRlibs':
    
    UsingR                  Data sets for the text "Using R for
                            Introductory Statistics"
    Packages in library '/usr/local/inst/R-2.6.0/library':
    .....
    ....
    ...
    

That finishes the exercise on how to create local library containing R-packages. If you want to practice adding one more package to your local collection, click here and download the randomForest(4.5-23) package. randomForest is a classification and regression method based on a forest of trees using random inputs. Run through the instructions one more time to add RandomForest package to your local library.

Finally, you can carry out this procedure in several different ways in R. For instance, you can also set your own library path as a variable in your .cshrc file as follows

setenv R_LIBS ~/myRlibs

This will load your own library each time you start R, and so you can skip step 4.

Acknowledgements

I would like to thank Dennis Foley, our IBM System Administrator, for working with me closely during the installation of R-2.6.0. Many thanks to Dr. Brian D. Peyser, USAMRIID, for identifying a typo in the document and for his suggestion on using the HOME directory for myRlibs.

Please contact Dennis (foleyd at ncifcrf dot gov) or me if you have any questions about using R in ABCC. Thanks to Bob Lebherz for proof-reading this document; any remaining errors are my own.


S. Ravichandran, Ph.D.
Scientist
Advanced Biomedical Computing Center
Bldg 430, Room 227
National Cancer Institute
Frederick, MD 21702
Email:  sravi at ncifcrf dot gov
Web: http://ncisgi.ncifcrf.gov/~ravichas
Voice:   301-846-1991
Fax:     301-846-5762