view DESeq_results.Rmd @ 0:6f94b4b9de44 draft

planemo upload
author mingchen0919
date Tue, 27 Feb 2018 23:57:53 -0500
parents
children
line wrap: on
line source

---
title: 'DESeq2: Results'
output:
    html_document:
      number_sections: true
      toc: true
      theme: cosmo
      highlight: tango
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
  echo = as.logical(opt$X_e),
  error = TRUE
)
```


```{r eval=TRUE}
# Import workspace
# fcp = file.copy(opt$X_W, "deseq.RData")
load(opt$X_W)
```

# Results {.tabset}

## Result table

```{r}
cat('--- View the top 100 rows of the result table ---')
res <- results(dds, contrast = c(opt$X_C, opt$X_T, opt$X_K))
write.csv(as.data.frame(res), file = opt$X_R)
res_df = as.data.frame(res)[1:100, ]
datatable(res_df, style="bootstrap", filter = 'top',
          class="table-condensed", options = list(dom = 'tp', scrollX = TRUE))
```

## Result summary

```{r}
summary(res)
```


# MA-plot {.tabset}



```{r}
cat('--- Shrinked with Bayesian procedure ---')
plotMA(res)
```


# Histogram of p values

```{r}
hist(res$pvalue[res$baseMean > 1], breaks = 0:20/20,
     col = "grey50", border = "white", main = "",
     xlab = "Mean normalized count larger than 1")
```


# Visualization {.tabset}
## Gene clustering

```{r}
clustering_groups = strsplit(opt$X_M, ',')[[1]]

topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20)
mat  <- assay(rld)[ topVarGenes, ]
mat  <- mat - rowMeans(mat)
annotation_col <- as.data.frame(colData(rld)[, clustering_groups])
colnames(annotation_col) = clustering_groups
rownames(annotation_col) = colnames(mat)
pheatmap(mat, annotation_col = annotation_col)
```

## Sample-to-sample distance

```{r}
sampleDistMatrix <- as.matrix( sampleDists )
colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)
pheatmap(sampleDistMatrix,
         clustering_distance_cols = sampleDists,
         col = colors)
```

## PCA plot 

```{r}
plotPCA(rld, intgroup = clustering_groups)
```

## MDS plot {.tabset}

### Data table
```{r}
mds <- as.data.frame(colData(rld))  %>%
         cbind(cmdscale(sampleDistMatrix))
knitr::kable(mds)
```

### Plot
```{r}
ggplot(mds, aes(x = `1`, y = `2`, col = time)) +
  geom_point(size = 3) + coord_fixed()
```