R installation

Kent Riemondy https://github.com/kriemo (RNA Bioscience Initiative)https://medschool.cuanschutz.edu/rbi
10-27-2021

This article will explain how to install R, Rstudio, and packages in R.If you are already familar with this material, skip to the Install packages for workshop section to see the packages that we will use in the workshop.

Download R

Download R from CRAN. Go to the cran homepage https://cran.r-project.org/. Select your operating system.

MacOS

Select the newest R version, download the .pkg file, then open and install.

Windows

Select the base link, then click download to download the .exe file. Open this file to install R.

Linux

If you are on linux, then follow the documentation for your linux OS.

Download compiler tools

MacOS

You may need to install the xcode command line tools if a package requires compilation. Open the Terminal from /Applications/Utilities/ (or use the search tool to search for terminal)

Type the following into Terminal:

xcode-select --install

Press “Install” and verify installation by typing into terminal:

gcc --version

Which should print something similar to this:

#' gcc (GCC) 4.8.5
#' Copyright (C) 2015 Free Software Foundation, Inc.
#' This is free software; see the source for copying conditions.  There is NO
#' warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here’s a youtube video explainer

Next you need to install gfortran. Follow this link and go to the “INSTALL OS-SPECIFIC GFORTRAN BINARY” section. Select the download link based on your macOS version. This will supply an installer.

Windows

You need to install Rtools from CRAN. Go to this link and download the exe installer for your OS: https://cran.r-project.org/bin/windows/Rtools/

Linux

You probably have a compiler already?

Download Rstudio

Go to the Rstudio website and download the installer for your OS.

Installing packages

Once you have R and Rstudio set up, open up rstudio, then we will install various packages.

In general there are 3 common places that you can get R packages from:

  1. CRAN, this is the official R package repository. CRAN has 16,000+ packages, including the tidyverse (ggplot2, dplyr, etc) and Seurat. Packages are installed using the install.packages() function. A successful install only needs to be done once.

In your console execute the following:

install.packages("tidyverse")
install.packages("Seurat")

Test package installation once complete by loading the package(s)

library(tidyverse)
library(Seurat)
  1. Bioconductor, which generally has bioinformatics related packages, such as clustifyr, DESeq2, ComplexHeatmap, etc.

To install bioconductor packages you should use the CRAN package BiocManager. BiocManager has a function called install() to install bioconductor packages. For example to install clustifyr

install.packages("BiocManager")
library(BiocManager)
install("clustifyr")
# or equivalently you could run BiocManager::install("clustifyr")
  1. Github hosts open-source code from millions of projects. R packages hosted on github can be installed using the remotes package. Presto or djvdj are examples of single cell RNA-seq analysis packages on github. You’ll need to find the organization name and the repository name on github to install.
install.packages("remotes")
remotes::install_github('rnabioco/djvdj')
remotes::install_github('immunogenomics/presto')

Install packages for workshop

We will use the following packages:

From CRAN:
- tidyverse
- Seurat
- rmarkdown
- cowplot
- pheatmap
- markdown

install.packages(c('tidyverse',
                   'rmarkdown',
                   'Seurat',
                   'cowplot',
                   'pheatmap',
                   'markdown'))

From Bioconductor:
- ComplexHeatmap
- scran
- scDblFinder
- limma
- clustifyr
- slingshot
- tradeSeq
- clusterExperiment

BiocManager::install(c('ComplexHeatmap', 
                       'scran',
                       'scDblFinder',
                       'limma',
                       'clustifyr',
                       'slingshot',
                       'tradeSeq',
                       'clusterExperiment'))

From github:
- destiny (hosted on bioconductor typically but not building correctly right now) - harmony (batch correction approach) - LaCroixColoR (pretty color palette)

remotes::install_github('theislab/destiny')
remotes::install_github('immunogenomics/harmony')
remotes::install_github('johannesbjork/LaCroixColoR')

To test the installation, run the prerequisite Rmarkdown which will load all of these packages.