Basic R Setup

Note: R and RStudio are separate downloads and installations. R is the underlying statistical computing environment, but using R alone is no fun. RStudio is a graphical integrated development environment that makes using R much easier. You need R installed before you install RStudio.

  1. Create a new folder somewhere on your computer that’s easy to get to (e.g., your Desktop). Name it bims8382. Inside that folder, make a folder called data, all lowercase.
  2. Download 8 datasets from bioconnector.org/data. Save these data files to bims8382/data, that new folder you just made. Or just click these direct links:
    1. brauer2007_tidy.csv
    2. brauer2007_messy.csv
    3. brauer2007_sysname2go.csv
    4. heartrate2dose.csv
    5. gapminder.csv
    6. airway_rawcounts.csv
    7. airway_metadata.csv
    8. annotables_grch37.csv
  3. Install R. You’ll need R version 3.1.2 or higher. Download and install R for Windows or Mac OS X (download the latest R-3.x.x.pkg file for your appropriate version of OS X).
  4. Install RStudio. Download and install the latest stable version of RStudio Desktop.
  5. Install R packages. Launch RStudio (RStudio, not R itself). Ensure that you have internet access, then enter the following commands into the Console panel (usually the lower-left panel, by default). A few notes:
    • These commands are case-sensitive.
    • You need to be connected to the internet to do this.
    • Even if you’ve installed these packages in the past, go ahead and re-install the most recent version. Many of these packages are updated often. For instance, ggplot2 2.0 (released December 2015) came with many new features and changes.
    • At any point (especially if you’ve used R/Bioconductor in the past), R may ask you if you want to update any old packages by asking Update all/some/none? [a/s/n]:. If you see this, type a at the propt and hit Enter to update any old packages.
    • If you see a note long the lines of “binary version available but the source version is later”, followed by a question, “Do you want to install from sources the package which needs compilation? y/n”, type n for no, and hit enter.
    • If you’re using a Windows machine you might get some errors about not having permission to modify the existing libraries – don’t worry about this message. You can avoid this error altogether by running RStudio as an administrator (right click the RStudio icon, then click “run as administrator”).
install.packages("dplyr")
install.packages("ggplot2")
install.packages("tidyr")
install.packages("readr")
install.packages("stringr")
install.packages("knitr")
install.packages("rmarkdown")

You can check that you’ve installed everything correctly by closing and reopening RStudio and entering the following commands at the console window:

library(dplyr)
library(ggplot2)
library(tidyr)
library(readr)
library(stringr)
library(knitr)
library(rmarkdown)

These commands may produce some notes or other output, but as long as they work without an error message, you’re good to go. If you get a message that says something like: Error in library(packageName) : there is no package called 'packageName', then the required packages did not install correctly. Please do not hesitate to email me prior to the course if you are still having difficulty.

Bioconductor

Additionally, you’ll need to install a few Bioconductor packages. These packages are installed differently than “regular” R packages from CRAN. Copy and paste these lines of code into your R console.

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

You can check that you’ve installed everything correctly by closing and reopening RStudio and entering the following commands at the console window:

library(DESeq2)

If you get a message that says something like: Error in library(packageName) : there is no package called 'packageName', then the required packages did not install correctly. Please do not hesitate to email me prior to the course if you are still having difficulty.

Additional steps for Reproducible Research classes

A few additional setup steps required for the reproducible research / dynamic documents class.

  1. First, launch RStudio (not R). Click File, New File, R Markdown. This may tell you that you need to install additional packages (knitr, yaml, htmltools, caTools, bitops, and rmarkdown). Click “Yes” to install these.
  2. Sign up for a free account at RPubs.com.
  3. If you want to convert to PDF, you will need to install a LaTeX typesetting engine. This differs on Mac and Windows. Note that this part of the installation may take up to several hours, and isn’t strictly required for the class.
    • Windows LaTeX instructions:
      1. Download the installer using this link (or this link if you’re using an older 32-bit version of Windows). It is important to use the full installer, not the basic installer. Run the installer .exe that you downloaded.
      2. Run the installer twice, making sure to use the Complete, not Basic, installation:
        1. First, When prompted, select the box to “Download MiKTeX.” Select the closest mirror to your location. If you’re doing this from Charlottesville, the United States / JMU mirror is likely the closest. This may take a while.
        2. Run the installer again, but this time select “Install” instead of “Download.” When prompted “Install missing packages on-the-fly”, drag your selection up to “Yes.”
    • Mac LaTeX instructions:
      1. Download the installer .pkg file using this link. This is a very large download (>2 gigabytes). It can take a while depending on your network speed.
      2. Run the installer package.