<!--
%\VignetteIndexEntry{03.3 Reproducible Research}
%\VignettePackage{LearnBioconductor}
%\VignetteEngine{knitr::knitr}
-->

```{r setup, echo=FALSE}
library(LearnBioconductor)
stopifnot(BiocInstaller::biocVersion() == "3.1")
```

```{r style, echo = FALSE, results = 'asis'}
BiocStyle::markdown()
```

# Reproducible Research

Martin Morgan<br/>
February 3, 2015

## Importance of reproducibility

A [cautionary tale](http://bioconductor.org/help/course-materials/2013/EMBOBGI/reproducible-research.pdf) 

## Facilities enabling reproducible analysis in _R_

Basics -- quickly becomes unsatisfactory

- 'Old-school' text scripts
- Comments describing approaches
- Package versions

Vignettes -- 'literate programming'

- Markdown
- _R_ markdown; weaving and tangling
- _LaTeX_

## More advanced considerations
    
Version control

- Alternative (better!) to using cryptic file names to indicate
  different versions
- Create a 'repository', add / edit files, 'commit' changes
- Easily review 'diff'erences, restore previous versions, ...
- _RStudio_

    - File -> New Project --> New Directory --> Empty Project. Click
      'Create git repository.
    - File --> New File --> R Script. Edit. 
    - 'Git' icon on menu bar --> Commit 

Packages

- The Rstudio 'wizard'
- Benefits

    - Code re-use standardizes analysis
    - No need to copy / paste code
    - Easy to share with colleagues (work group, company, world)

## Lab

Produce a short 'vignette' summarizing your RNA-seq work
yesterday. The code chunks might be along the lines of

```{r workflow-code-chunks, eval=FALSE}
library(airway)
library(DESeq2)

data(airway)

dds <- DESeqDataSet(airway, design = ~ cell + dex)
dds$dex <- relevel(dds$dex, "untrt")
dds <- DESeq(dds)
res <- results(dds)
```

Embed this in textual description with relevant descriptive
information (title, author, date) as well as text describing nuances
of each step, plus figures or tables of your choosing to illustrate
relevant aspects of the experimental design or results.

Render this as an HTML document to share with your colleagues at home.
