The RStudio interface, RMarkdown syntax, and Bioconductor

Garrett Graham
171128

Today

  • RStudio interface
  • RMarkdown conventions
  • Bioconductor

RStudio IDE

Why use an IDE?

(Integrated Development Environment)

RStudio IDE

Why use an IDE?

Well, you don't need to…

You can use R directly from the command line, it's just much more work

RStudio IDE

Using the RStudio IDE (and most other IDEs), you can easily track objects in your environment

RStudio IDE

Using the RStudio IDE (and most other IDEs), you can easily track objects in your environment. Creating a variable in the local environment Iris Variable

creates a corresponding entry in the “Environment” pane of the IDE Iris Environment

RStudio IDE

RStudio also provides a convenient editor for R scripts and R Markdown New File

Blank Markdown

RStudio IDE

I'll strongly recommend that you use RMarkdown and the project environments in RStudio

This will help you to

  • Create reproducible code
  • Maintain separate projects
  • Produce legible, annotated output

The exam will include the creation of a RMarkdown document that is syntactically correct

RStudio IDE

RMarkdown is a format that makes it convenient to annotate code as you write

It's good practice to format code into blocks by function

Initial Markdown

RStudio IDE

RMarkdown is a format that makes it convenient to annotate code as you write

It's good practice to format code into blocks by function

Initial Markdown

RStudio IDE

This is an example of a code block that loads the “tidyverse”, “wesanderson”, and “limma” packages

Initial Markdown

Bioconductor

[1] "http://bioconductor.org"

Bioconductor

Bioconductor

R packages provide functionality around a specific purpose

The “readr” package has functions associated with reading in text files

Bioconductor is a central package repository for bio-associated R packages

Bioconductor

Standard R packages from the nearest R package maintainer can be installed with the “install.packages()” command

install.packages('wesanderson')

Similarly, Bioconductor R packages can be installed with the “biocLite()” command

source('http://bioconductor.org/biocLite.R')
biocLite('limma')

Bioconductor

If you came across a package you were interested in, say a set of functions written to visualize pathways:

Pathview 1

And you saw that the software was written in R and distributed via Bioconductor:

Pathview 2

Bioconductor

Either by following the link in the article text or by searching in Bioconductor:

Pathview 3

Bioconductor

You could then install the package locally using the “biocLite()” command

source('http://bioconductor.org/biocLite.R')
biocLite('pathview')

Bioconductor

Now you can use the commands in the “pathview” package

library(pathview)
data("gse16873.d")
pathview(gene.data = gse16873.d[, 1],
         pathway.id = "04110",
         species = "hsa")