annotate DESeq_results.Rmd @ 8:3f84334c3de8 draft

Uploaded
author mingchen0919
date Mon, 07 Aug 2017 18:12:02 -0400
parents cf6012738737
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
1 ---
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
2 title: 'DESeq2: Results'
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
3 output:
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
4 html_document:
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
5 number_sections: true
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
6 toc: true
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
7 theme: cosmo
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
8 highlight: tango
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
9 ---
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
10
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
11 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
12 knitr::opts_chunk$set(
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
13 echo = ECHO
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
14 )
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
15
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
16 library(DESeq2)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
17 library(pheatmap)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
18 library(genefilter)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
19 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
20
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
21 # Import workspace
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
22
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
23 ```{r eval=TRUE}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
24 fcp = file.copy("DESEQ_WORKSPACE", "deseq.RData")
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
25 load("deseq.RData")
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
26 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
27
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
28 # Results {.tabset}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
29
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
30 ## Result table
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
31
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
32 ```{r}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
33 group = colnames(sample_table)[CONTRAST_GROUP]
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
34 res <- results(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL'))
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
35 datatable(as.data.frame(res), style="bootstrap", filter = 'top',
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
36 class="table-condensed", options = list(dom = 'tp', scrollX = TRUE))
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
37 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
38
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
39 ## Result summary
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
40
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
41 ```{r}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
42 summary(res)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
43 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
44
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
45
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
46 # MA-plot {.tabset}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
47
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
48 ## Shrinked with `lfcShrink()` function
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
49
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
50 ```{r eval=FALSE}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
51 shrink_res = DESeq2::lfcShrink(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL'), res=res)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
52 plotMA(shrink_res)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
53 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
54
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
55 ## Shrinked with Bayesian procedure
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
56
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
57 ```{r}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
58 plotMA(res)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
59 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
60
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
61
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
62 # Histogram of p values
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
63
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
64 ```{r}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
65 hist(res$pvalue[res$baseMean > 1], breaks = 0:20/20,
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
66 col = "grey50", border = "white", main = "",
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
67 xlab = "Mean normalized count larger than 1")
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
68 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
69
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
70
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
71 # Gene clustering
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
72
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
73 ```{r}
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
74 group_index = as.numeric(strsplit("CLUSTERING_GROUPS", ',')[[1]])
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
75 clustering_groups = colnames(sample_table)[group_index]
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
76
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
77 topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
78 mat <- assay(rld)[ topVarGenes, ]
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
79 mat <- mat - rowMeans(mat)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
80 annotation_col <- as.data.frame(colData(rld)[, clustering_groups])
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
81 colnames(annotation_col) = clustering_groups
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
82 rownames(annotation_col) = colnames(mat)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
83 pheatmap(mat, annotation_col = annotation_col)
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
84 ```
cf6012738737 Uploaded
mingchen0919
parents:
diff changeset
85