## ----style, echo = FALSE, results = 'asis'--------------------------------------------------------
BiocStyle::markdown()
options(width=100, max.print=1000)
knitr::opts_chunk$set(
    eval=as.logical(Sys.getenv("KNITR_EVAL", "TRUE")),
    cache=as.logical(Sys.getenv("KNITR_CACHE", "TRUE")), 
    error=FALSE)

## ----load-data------------------------------------------------------------------------------------
library("airway")
data(airway)

## ----play-----------------------------------------------------------------------------------------
library("airway")
data(airway)
se <- airway
se

## ----revise-se------------------------------------------------------------------------------------
head(assay(se))
colSums(assay(se))
colData(se)
rowRanges(se)

## ----make-dds-------------------------------------------------------------------------------------
library(DESeq2)
dds <- DESeqDataSet(se, design = ~ cell + dex)  

## ----do-rlog--------------------------------------------------------------------------------------
rld <- rlog(dds)   
head(assay(rld))    

## ----dist-----------------------------------------------------------------------------------------
sampleDists <- dist( t( assay(rld) ) )
sampleDists

## ----message=FALSE--------------------------------------------------------------------------------
library("gplots")
library("RColorBrewer")

sampleDistMatrix <- as.matrix( sampleDists )
rownames(sampleDistMatrix) <- paste( rld$dex, rld$cell, sep="-" )
colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)
hc <- hclust(sampleDists)
heatmap.2( sampleDistMatrix, Rowv=as.dendrogram(hc),
          symm=TRUE, trace="none", col=colors,
          margins=c(2,10), labCol=FALSE )


## ----pca------------------------------------------------------------------------------------------
plotPCA(rld, intgroup = c("dex", "cell"))

## ----mds------------------------------------------------------------------------------------------
library(ggplot2)
mds <- data.frame(cmdscale(sampleDistMatrix))
mds <- cbind(mds, colData(rld))
qplot(X1,X2,color=dex,shape=cell,data=as.data.frame(mds))

## ----sessionInfo----------------------------------------------------------------------------------
sessionInfo()