-
Notifications
You must be signed in to change notification settings - Fork 0
Installing R and adding packages without Root permissions.
R programming language is preferred by many for data analytics and statistical computing. There are packages available to do various kinds of bioinformatics and statistical analysis, which avoid a user to develop scripts and analysis methods from scratch. These packages are available from 3 different sources
- CRAN webpage
- Bioconductor
- Github
Many a time the installation of some packages requires root or administrator privileges and that may not be available on cluster systems. We put an outline below to explain how to install R and the packages without the root/administrator permissions using miniconda. The tutorial is explained in four steps
- Installation of miniconda and creating an environment
- Installation of R
- R-package installation
- Running R
Lets get started
Step1: Installation of miniconda and creating an environment
Start interactive session
srun –-pty -p general -q general –mem=5G bash
- Download miniconda for appropriate python version from https://docs.conda.io/en/latest/miniconda.html . Select the appropriate version and right-click and select “Copy Link Address”.
Use the command to down load the link
wget <paste the copied link here>
- Execute the downloaded script as
sh Miniconda3-latest-Linux-x86_64.sh
Agree to license, location and for running conda init
-
Execute command
conda
at terminal and if it display conda help file you have installed miniconda properly. -
Now we would like to create an environment which will have appropriate version of python and required python packages in it. Let say we want to create an environment named python3 (any name can be given) with python-3.8. Execute the command
conda create -n python3 python=3.8
-
Once environment is created you can install packages you require e.g
ipython
. Google “ipython conda installation” and among different option suggested select one which is from anaconda website as shown below -
Once on anaconda website find the channel (-c) and installation instructions as shown below
-
Install the package with command and specifying the environment name.
conda install -n python3 -c anaconda ipython
This will install the package from appropriate channel in appropriate environment. In future if you would like to add another package for the same environment, simply find the channel and installation instruction from anaconda website (as we did for ipython) and run the installation command as
conda install -n python3 -c <channel> <PackageName>
This is the only line you have to execute in an interactive session for a package to be added to the environment.
In order to install R, we will be first creating an environment for R so that it is isolated from other environments but this is optional.
- Create an environment for R and lets name the environment as
R411
(Installing R version 4.1.1).
conda create -n R411
and now switch to the new environment with code
conda activate R411
- In this environment we will be installing
4.1.1
version ofR
conda install -c conda-forge r=4.1.1
Similarly, older version of R can also be installed by specifying the version in the above command.
- Now lets check if installation is successful
conda deactivate
conda activate R411
. Load the environment
which R
. # This should display the path to R as some/path/R411/bin/R
or
R
. # Here the loaded R should be R version 4.1.1
Run conda deactivate
to close the environment.
Now any time you need to use R load the environment