annotate DESeq.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: Perform DESeq analysis'
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 error = TRUE
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 ```
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
17
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
18 ```{r}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
19 str(opt)
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
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
22 # `DESeqDataSet` object
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
23
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
24 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
25 count_files = strsplit(opt$count_files, ',')[[1]]
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
26 sample_table = read.table(opt$sample_table, header = TRUE)
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 ## copy count files into working directory
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
29 file_copy = file.copy(count_files, sample_table$fileName, overwrite = TRUE)
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
30
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
31 ## DESeqDataSet object
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
32 dds = DESeqDataSetFromHTSeqCount(sampleTable = sample_table,
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
33 directory = './',
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
34 design = DESIGN_FORMULA)
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
35 dds
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
36 ```
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 # Pre-filtering the dataset.
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
39
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
40 We can remove the rows that have 0 or 1 count to reduce object size and increase the calculation speed.
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
41
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
42 * Number of rows before pre-filtering
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
43 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
44 nrow(dds)
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
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
47 * Number of rows after pre-filtering
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
48 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
49 dds = dds[rowSums(counts(dds)) > 1, ]
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
50 nrow(dds)
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
51 ```
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
52
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
53 # Peek at data {.tabset}
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 ## Count Data
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 eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
58 datatable(head(counts(dds), 100), style="bootstrap",
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
59 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
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 ## Sample Table
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 eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
65 datatable(sample_table, style="bootstrap",
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
66 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
67 ```
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 # Sample distance on variance stabilized data {.tabset}
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 ## `rlog` Stabilizing transformation
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 eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
74 rld = rlog(dds, blind = FALSE)
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
75 datatable(head(assay(rld), 100), style="bootstrap",
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
76 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
77 ```
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
78
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
79 ## Sample distance
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
80
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
81 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
82 sampleDists <- dist(t(assay(rld)))
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
83 sampleDists
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
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
86 # Differential expression analysis
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
87
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
88 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
89 dds <- DESeq(dds)
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
90 ```
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
91
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
92 ```{r eval=FALSE}
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
93 rm("opt")
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
94 save(list=ls(all.names = TRUE), file='DESEQ_WORKSPACE')
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
95 ```
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
96
61c184384d02 planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_deseq2
mingchen0919
parents:
diff changeset
97