Mercurial > repos > mingchen0919 > deseq2_rmarkdown
comparison DESeq.Rmd @ 7:a5fdd120b2c7 draft
Uploaded
author | mingchen0919 |
---|---|
date | Mon, 07 Aug 2017 18:11:50 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
6:f1e4bfc58975 | 7:a5fdd120b2c7 |
---|---|
1 --- | |
2 title: 'DESeq2: Perform DESeq analysis' | |
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(stringi) | |
17 library(DESeq2) | |
18 library(pheatmap) | |
19 library(PoiClaClu) | |
20 library(RColorBrewer) | |
21 ``` | |
22 | |
23 # `DESeqDataSet` object | |
24 | |
25 ```{r} | |
26 count_files = strsplit(opt$count_files, ',')[[1]] | |
27 sample_table = read.table(opt$sample_table, header = TRUE) | |
28 | |
29 ## copy count files into working directory | |
30 file_copy = file.copy(count_files, sample_table$fileName, overwrite = TRUE) | |
31 | |
32 ## DESeqDataSet object | |
33 dds = DESeqDataSetFromHTSeqCount(sampleTable = sample_table, | |
34 directory = './', | |
35 design = DESIGN_FORMULA) | |
36 dds | |
37 ``` | |
38 | |
39 # Pre-filtering the dataset. | |
40 | |
41 We can remove the rows that have 0 or 1 count to reduce object size and increase the calculation speed. | |
42 | |
43 * Number of rows before pre-filtering | |
44 ```{r} | |
45 nrow(dds) | |
46 ``` | |
47 | |
48 * Number of rows after pre-filtering | |
49 ```{r} | |
50 dds = dds[rowSums(counts(dds)) > 1, ] | |
51 nrow(dds) | |
52 ``` | |
53 | |
54 # Peek at data {.tabset} | |
55 | |
56 ## Count Data | |
57 | |
58 ```{r} | |
59 datatable(head(counts(dds), 100), style="bootstrap", | |
60 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
61 ``` | |
62 | |
63 ## Sample Table | |
64 | |
65 ```{r} | |
66 datatable(sample_table, style="bootstrap", | |
67 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
68 ``` | |
69 | |
70 # Sample distance on variance stabilized data {.tabset} | |
71 | |
72 ## `rlog` Stabilizing transformation | |
73 | |
74 ```{r} | |
75 rld = rlog(dds, blind = FALSE) | |
76 datatable(head(assay(rld), 100), style="bootstrap", | |
77 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
78 ``` | |
79 | |
80 ## Sample distance | |
81 | |
82 ```{r} | |
83 sampleDists <- dist(t(assay(rld))) | |
84 sampleDists | |
85 ``` | |
86 | |
87 # Differential expression analysis | |
88 | |
89 ```{r} | |
90 dds <- DESeq(dds) | |
91 ``` | |
92 | |
93 ```{r} | |
94 rm("opt") | |
95 save(list=ls(all.names = TRUE), file='DESEQ_WORKSPACE') | |
96 ``` | |
97 | |
98 |