annotate DESeq_results.Rmd @ 0:6f94b4b9de44 draft

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