Mercurial > repos > mingchen0919 > aurora_deseq2_site
comparison DESeq.Rmd @ 0:6f94b4b9de44 draft
planemo upload
author | mingchen0919 |
---|---|
date | Tue, 27 Feb 2018 23:57:53 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6f94b4b9de44 |
---|---|
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 = as.logical(opt$X_e), | |
14 error = TRUE | |
15 ) | |
16 ``` | |
17 | |
18 # `DESeqDataSet` object | |
19 | |
20 ```{r 'DESeqDataSet object'} | |
21 count_file_paths = strsplit(opt$X_P, ',')[[1]] | |
22 count_file_names = strsplit(opt$X_N, ',')[[1]] | |
23 sample_table = read.table(opt$X_S, header = TRUE) | |
24 row.names(sample_table) = sample_table[,2] | |
25 sample_table = sample_table[count_file_names, ] | |
26 | |
27 ## copy count files into OUTPUT_DIR/counts | |
28 dir.create(paste0(OUTPUT_DIR, '/counts'), recursive = TRUE) | |
29 file_copy = file.copy(count_file_paths, paste0(OUTPUT_DIR, '/counts/', count_file_names), overwrite = TRUE) | |
30 | |
31 ## DESeqDataSet object | |
32 dds = DESeqDataSetFromHTSeqCount(sampleTable = sample_table, | |
33 directory = paste0(OUTPUT_DIR, '/counts'), | |
34 design = formula(opt$X_p)) | |
35 dds | |
36 ``` | |
37 | |
38 # Pre-filtering the dataset. | |
39 | |
40 We can remove the rows that have 0 or 1 count to reduce object size and increase the calculation speed. | |
41 | |
42 * Number of rows before pre-filtering | |
43 ```{r} | |
44 nrow(dds) | |
45 ``` | |
46 | |
47 * Number of rows after pre-filtering | |
48 ```{r} | |
49 dds = dds[rowSums(counts(dds)) > 1, ] | |
50 nrow(dds) | |
51 ``` | |
52 | |
53 # Peek at data {.tabset} | |
54 | |
55 ## Count Data | |
56 | |
57 ```{r 'count data'} | |
58 datatable(head(counts(dds), 100), style="bootstrap", | |
59 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
60 ``` | |
61 | |
62 ## Sample Table | |
63 | |
64 ```{r 'sample table'} | |
65 datatable(sample_table, style="bootstrap", | |
66 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
67 ``` | |
68 | |
69 # Sample distance on variance stabilized data {.tabset} | |
70 | |
71 ## `rlog` Stabilizing transformation | |
72 | |
73 ```{r} | |
74 rld = rlog(dds, blind = FALSE) | |
75 datatable(head(assay(rld), 100), style="bootstrap", | |
76 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) | |
77 ``` | |
78 | |
79 ## Sample distance | |
80 | |
81 ```{r} | |
82 sampleDists <- dist(t(assay(rld))) | |
83 sampleDists | |
84 ``` | |
85 | |
86 # Differential expression analysis | |
87 | |
88 ```{r} | |
89 dds <- DESeq(dds) | |
90 ``` | |
91 | |
92 ```{r echo=FALSE} | |
93 # save objects except for opt. | |
94 save(list=ls()[ls() != "opt"], file=opt$X_w) | |
95 ``` | |
96 | |
97 |