Mercurial > repos > mingchen0919 > rmarkdown_deseq2_test
comparison DESeq_results.Rmd @ 0:61c184384d02 draft default tip
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
| author | mingchen0919 |
|---|---|
| date | Tue, 07 Nov 2017 10:02:57 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:61c184384d02 |
|---|---|
| 1 --- | |
| 2 title: 'DESeq2: Results' | |
| 3 output: | |
| 4 html_document: | |
| 5 number_sections: true | |
| 6 toc: true | |
| 7 theme: cosmo | |
| 8 highlight: tango | |
| 9 --- | |
| 10 | |
| 11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} | |
| 12 knitr::opts_chunk$set( | |
| 13 echo = ECHO | |
| 14 ) | |
| 15 | |
| 16 library(DESeq2) | |
| 17 library(pheatmap) | |
| 18 library(genefilter) | |
| 19 ``` | |
| 20 | |
| 21 # Import workspace | |
| 22 | |
| 23 ```{r eval=TRUE} | |
| 24 fcp = file.copy("DESEQ_WORKSPACE", "deseq.RData") | |
| 25 load("deseq.RData") | |
| 26 ``` | |
| 27 | |
| 28 # Results {.tabset} | |
| 29 | |
| 30 ## Result table | |
| 31 | |
| 32 ```{r} | |
| 33 group = colnames(sample_table)[CONTRAST_GROUP] | |
| 34 res <- results(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL')) | |
| 35 datatable(as.data.frame(res), style="bootstrap", filter = 'top', | |
| 36 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
| 37 ``` | |
| 38 | |
| 39 ## Result summary | |
| 40 | |
| 41 ```{r} | |
| 42 summary(res) | |
| 43 ``` | |
| 44 | |
| 45 | |
| 46 # MA-plot {.tabset} | |
| 47 | |
| 48 ## Shrinked with `lfcShrink()` function | |
| 49 | |
| 50 ```{r eval=FALSE} | |
| 51 shrink_res = DESeq2::lfcShrink(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL'), res=res) | |
| 52 plotMA(shrink_res) | |
| 53 ``` | |
| 54 | |
| 55 ## Shrinked with Bayesian procedure | |
| 56 | |
| 57 ```{r} | |
| 58 plotMA(res) | |
| 59 ``` | |
| 60 | |
| 61 | |
| 62 # Histogram of p values | |
| 63 | |
| 64 ```{r} | |
| 65 hist(res$pvalue[res$baseMean > 1], breaks = 0:20/20, | |
| 66 col = "grey50", border = "white", main = "", | |
| 67 xlab = "Mean normalized count larger than 1") | |
| 68 ``` | |
| 69 | |
| 70 | |
| 71 # Gene clustering | |
| 72 | |
| 73 ```{r} | |
| 74 group_index = as.numeric(strsplit("CLUSTERING_GROUPS", ',')[[1]]) | |
| 75 clustering_groups = colnames(sample_table)[group_index] | |
| 76 | |
| 77 topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20) | |
| 78 mat <- assay(rld)[ topVarGenes, ] | |
| 79 mat <- mat - rowMeans(mat) | |
| 80 annotation_col <- as.data.frame(colData(rld)[, clustering_groups]) | |
| 81 colnames(annotation_col) = clustering_groups | |
| 82 rownames(annotation_col) = colnames(mat) | |
| 83 pheatmap(mat, annotation_col = annotation_col) | |
| 84 ``` | |
| 85 |
