```{r setup, echo=FALSE} library(LearnBioconductor) stopifnot(BiocInstaller::biocVersion() == "3.0") ``` ```{r style, echo = FALSE, results = 'asis'} BiocStyle::markdown() ``` # Visualization Martin Morgan
October 29, 2014 [Three approaches](http://bioconductor.org/help/course-materials/2014/summerx/Visualization-slides.pdf) - 'base' graphics - _lattice_ - `r CRANpkg("ggplot2")` - A neat _ggplot2_ example: [slide 19+](http://bioconductor.org/help/course-materials/2014/CSAMA2014/2_Tuesday/lectures/Visualization_in_Statistical_Genomics-Carey.pdf) from Vince Carey's presentation. Genome-centric - `r Biocpkg("Gviz")` for visualizing genomic regions - `r Biocpkg("ggbio")` provides extensive options Interactive visualization - `r Biocpkg("rtracklayer")` for visualizing genomic ranges and managing UCSC genome browser sessions. - `r Biocpkg('epivizr')` for interactive display - `r CRANpkg("shiny")` [web](http://shiny.rstudio.com) for interactive apps. Reports - `r Biocpkg("ReportingTools")` for easy report templates And... - `r CRANpkg("RColorBrewer")` and [web site](http://colorbrewer2.org/): helps choose sensible color schemes. - [Accidental aRt](http://accidental-art.tumblr.com/archive) - [stick figure](https://github.com/EconometricsBySimulation/R-Graphics/blob/master/Stick-Figures/draw.stick.R) ## Lab ### Gviz / ggbio Work through [vignette section 2](http://bioconductor.org/packages/release/bioc/vignettes/Gviz/inst/doc/Gviz.pdf) the `r Biocpkg('Gviz')` package, and then the 'Plotting fold changes in genomic space' in the [RNASeq lab](B02.1.1_RNASeqLab.html). Peruse the [vignette](http://bioconductor.org/packages/release/bioc/vignettes/ggbio/inst/doc/ggbio.pdf) of the `r Biocpkg('ggbio')` package. Run the following _DESeq2_ work flow to arrive at a top-table; coerce the result to a `data.frame`. ```{r ggplot-setup, eval=FALSE} library(DESeq2) library(airway) data(airway) se = airway dds <- DESeqDataSet(se, design = ~ cell + dex) dds$dex <- relevel(dds$dex, "untrt") dds <- DESeq(dds) res <- results(dds) resdf <- as.data.frame(res) ``` A 'volcano plot' shows the relationship between P-value and log fold change. Here's a basic volcano plot using base graphics; create a volcano plot using _ggplot2_ and / or _lattice_. ```{r volcano, eval=FALSE} plot(-log10(padj) ~ log2FoldChange, resdf) ```