annotate rmarkdown_report.Rmd @ 0:55d2db17c67c draft

planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
author mingchen0919
date Fri, 14 Dec 2018 00:21:26 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
1 ---
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
2 title: 'Aurora DESeq2 Report'
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
3 output:
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
4 html_document:
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
5 highlight: pygments
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
6 ---
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
7
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
8 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
9 knitr::opts_chunk$set(error = TRUE, echo = FALSE)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
10 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
11
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
12 ```{css, echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
13 pre code, pre, code {
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
14 white-space: pre !important;
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
15 overflow-x: scroll !important;
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
16 word-break: keep-all !important;
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
17 word-wrap: initial !important;
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
18 }
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
19 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
20
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
21 ```{r, echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
22 # to make the css theme to work, <link></link> tags cannot be added directly
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
23 # as <script></script> tags as below.
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
24 # it has to be added using a code chunk with the htmltool functions!!!
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
25 css_link = tags$link()
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
26 css_link$attribs = list(rel="stylesheet", href="vakata-jstree-3.3.5/dist/themes/default/style.min.css")
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
27 css_link
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
28 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
29
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
30 ```{r, eval=FALSE, echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
31 # this code chunk is purely for adding comments
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
32 # below is to add jQuery and jstree javascripts
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
33 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
34
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
35 <script src="vakata-jstree-3.3.5/dist/jstree.min.js"></script>
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
36
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
37
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
38 ```{r, eval=FALSE, echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
39 # this code chunk is purely for adding comments
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
40 # javascript code below is to build the file tree interface
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
41 # see this for how to implement opening hyperlink: https://stackoverflow.com/questions/18611317/how-to-get-i-get-leaf-nodes-in-jstree-to-open-their-hyperlink-when-clicked-when
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
42 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
43 <script>
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
44 jQuery(function () {
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
45 // create an instance when the DOM is ready
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
46 jQuery('#jstree').jstree().bind("select_node.jstree", function (e, data) {
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
47 window.open( data.node.a_attr.href, data.node.a_attr.target )
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
48 });
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
49 });
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
50 </script>
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
51
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
52
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
53 ```{r, eval=FALSE, echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
54 ---
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
55 # ADD YOUR DATA ANALYSIS CODE AND MARKUP TEXT BELOW TO EXTEND THIS R MARKDOWN FILE
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
56 ---
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
57 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
58
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
59 ## DESeq2 analysis
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
60
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
61 ```{r echo=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
62 # import count data
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
63 count_data = read.csv(opt$X_A, row.names = 1, header = TRUE)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
64 # import column data
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
65 coldata = read.csv(opt$X_B, row.names = 1, header = TRUE)[colnames(count_data),,drop=FALSE]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
66 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
67
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
68 ```{r}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
69 f = gsub('~', '~ 1 +', opt$X_C) # build formula
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
70 dds = DESeqDataSetFromMatrix(countData = count_data,
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
71 colData = coldata,
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
72 design = formula(f))
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
73
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
74
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
75 # prefiltering
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
76 keep <- rowSums(counts(dds)) >= 10
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
77 dds <- dds[keep,]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
78
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
79 # Run DESeq
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
80 if (opt$X_T == 'LRT') {
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
81 reduced_f = gsub(paste0('\\+\\s*', opt$X_D), '', f)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
82 dds = DESeq(dds, test=opt$X_T, fitType = opt$X_H, reduced = formula(reduced_f))
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
83 } else {
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
84 dds = DESeq(dds, test=opt$X_T, fitType = opt$X_H)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
85 }
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
86
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
87 ## Differential expression test results
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
88 res = results(dds, contrast = c(opt$X_D, opt$X_E, opt$X_F), alpha = opt$X_I)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
89 DT::datatable(as.data.frame(res))
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
90 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
91
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
92
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
93 ```{r}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
94 # save all padj sorted res to tool output directory
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
95 padj_sorted_res = res[order(res$padj), ]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
96 write.table(padj_sorted_res,
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
97 file = paste0(opt$X_d, '/padj-sorted-genes.txt'),
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
98 quote = FALSE)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
99
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
100 # save significant genes to a file in tool output directory
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
101 sig_res = res[(res$padj < opt$X_I) & !is.na(res$padj), ]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
102 sig_res_sorted = sig_res[order(sig_res$padj), ]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
103 sig_res_sorted$feature_id = rownames(sig_res_sorted)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
104 n_col = ncol(sig_res_sorted)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
105 sig_res_sorted = sig_res_sorted[, c(n_col, 1:(n_col - 1))]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
106 write.table(sig_res_sorted,
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
107 file = paste0(opt$X_d, '/padj-sorted-significant-genes.txt'),
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
108 quote = FALSE, row.names = FALSE)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
109 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
110
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
111 ## MA-plot
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
112
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
113 ```{r warning=FALSE}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
114 log_fold_change = res$log2FoldChange
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
115 base_mean = res$baseMean
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
116 significant = res$padj
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
117 significant[significant < 0.1] = 'yes'
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
118 significant[significant != 'yes'] = 'no'
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
119
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
120 maplot_df = data.frame(log_fold_change, base_mean, significant)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
121 maplot_df = maplot_df[!is.na(maplot_df$significant), ]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
122 p = ggplot(data = maplot_df) +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
123 geom_point(mapping = aes(log(base_mean), log_fold_change, color = significant),
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
124 size = 0.5) +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
125 scale_color_manual(name = 'Significant',
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
126 values = c('no' = 'black', 'yes' = 'red'),
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
127 labels = c('No', 'Yes')) +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
128 xlab('Log base mean') +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
129 ylab('Log fold change') +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
130 theme_classic()
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
131
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
132 plotly::ggplotly(p)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
133 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
134
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
135
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
136 ## Heatmap of count matrix
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
137
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
138 ```{r}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
139 ntd <- normTransform(dds)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
140 select <- order(rowMeans(counts(dds,normalized=TRUE)),
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
141 decreasing=TRUE)[1:20]
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
142 df <- as.data.frame(colData(dds)[, -ncol(colData(dds))])
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
143 pheatmap(assay(ntd)[select,], annotation_col=df)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
144 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
145
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
146
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
147 ## Principle component analysis plot
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
148
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
149 ```{r}
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
150 vsd <- vst(dds, blind=FALSE)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
151 p = plotPCA(vsd, intgroup=c(opt$X_D)) +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
152 scale_color_discrete(name = 'Group') +
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
153 theme_classic()
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
154 ggplotly(p)
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
155 ```
55d2db17c67c planemo upload commit 841d8b22bf9f1aaed6bfe8344b60617f45b275b2-dirty
mingchen0919
parents:
diff changeset
156