0
|
1 ---
|
|
2 title: 'DESeq2: Results'
|
|
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
|
|
19 ```{r eval=TRUE}
|
|
20 # Import workspace
|
|
21 # fcp = file.copy(opt$X_W, "deseq.RData")
|
|
22 load(opt$X_W)
|
|
23 ```
|
|
24
|
|
25 # Results {.tabset}
|
|
26
|
|
27 ## Result table
|
|
28
|
|
29 ```{r}
|
|
30 cat('--- View the top 100 rows of the result table ---')
|
|
31 res <- results(dds, contrast = c(opt$X_C, opt$X_T, opt$X_K))
|
|
32 write.csv(as.data.frame(res), file = opt$X_R)
|
|
33 res_df = as.data.frame(res)[1:100, ]
|
|
34 datatable(res_df, style="bootstrap", filter = 'top',
|
|
35 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE))
|
|
36 ```
|
|
37
|
|
38 ## Result summary
|
|
39
|
|
40 ```{r}
|
|
41 summary(res)
|
|
42 ```
|
|
43
|
|
44
|
|
45 # MA-plot {.tabset}
|
|
46
|
|
47
|
|
48
|
|
49 ```{r}
|
|
50 cat('--- Shrinked with Bayesian procedure ---')
|
|
51 plotMA(res)
|
|
52 ```
|
|
53
|
|
54
|
|
55 # Histogram of p values
|
|
56
|
|
57 ```{r}
|
|
58 hist(res$pvalue[res$baseMean > 1], breaks = 0:20/20,
|
|
59 col = "grey50", border = "white", main = "",
|
|
60 xlab = "Mean normalized count larger than 1")
|
|
61 ```
|
|
62
|
|
63
|
|
64 # Visualization {.tabset}
|
|
65 ## Gene clustering
|
|
66
|
|
67 ```{r}
|
|
68 clustering_groups = strsplit(opt$X_M, ',')[[1]]
|
|
69
|
|
70 topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20)
|
|
71 mat <- assay(rld)[ topVarGenes, ]
|
|
72 mat <- mat - rowMeans(mat)
|
|
73 annotation_col <- as.data.frame(colData(rld)[, clustering_groups])
|
|
74 colnames(annotation_col) = clustering_groups
|
|
75 rownames(annotation_col) = colnames(mat)
|
|
76 pheatmap(mat, annotation_col = annotation_col)
|
|
77 ```
|
|
78
|
|
79 ## Sample-to-sample distance
|
|
80
|
|
81 ```{r}
|
|
82 sampleDistMatrix <- as.matrix( sampleDists )
|
|
83 colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)
|
|
84 pheatmap(sampleDistMatrix,
|
|
85 clustering_distance_cols = sampleDists,
|
|
86 col = colors)
|
|
87 ```
|
|
88
|
|
89 ## PCA plot
|
|
90
|
|
91 ```{r}
|
|
92 plotPCA(rld, intgroup = clustering_groups)
|
|
93 ```
|
|
94
|
|
95 ## MDS plot {.tabset}
|
|
96
|
|
97 ### Data table
|
|
98 ```{r}
|
|
99 mds <- as.data.frame(colData(rld)) %>%
|
|
100 cbind(cmdscale(sampleDistMatrix))
|
|
101 knitr::kable(mds)
|
|
102 ```
|
|
103
|
|
104 ### Plot
|
|
105 ```{r}
|
|
106 ggplot(mds, aes(x = `1`, y = `2`, col = time)) +
|
|
107 geom_point(size = 3) + coord_fixed()
|
|
108 ```
|
|
109
|