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