annotate DESeq_results_04.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 output: html_document
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
3 ---
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
4
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
5 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
6 knitr::opts_chunk$set(
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
7 echo = as.logical(opt$X_e),
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
8 error = TRUE
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
9 )
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
10 ```
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
11
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
12
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
13 # Visualization {.tabset}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
14 ## Gene clustering
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
15
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
16 ```{r}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
17 clustering_groups = strsplit(opt$X_M, ',')[[1]]
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
18
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
19 topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
20 mat <- assay(rld)[ topVarGenes, ]
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
21 mat <- mat - rowMeans(mat)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
22 annotation_col <- as.data.frame(colData(rld)[, clustering_groups])
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
23 colnames(annotation_col) = clustering_groups
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
24 rownames(annotation_col) = colnames(mat)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
25 pheatmap(mat, annotation_col = annotation_col)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
26 ```
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
27
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
28 ## Sample-to-sample distance
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
29
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
30 ```{r}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
31 sampleDistMatrix <- as.matrix( sampleDists )
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
32 colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
33 pheatmap(sampleDistMatrix,
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
34 clustering_distance_cols = sampleDists,
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
35 col = colors)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
36 ```
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
37
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
38 ## PCA plot
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 plotPCA(rld, intgroup = clustering_groups)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
42 ```
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
43
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
44 ## MDS plot {.tabset}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
45
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
46 ### Data table
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
47 ```{r}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
48 mds <- as.data.frame(colData(rld)) %>%
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
49 cbind(cmdscale(sampleDistMatrix))
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
50 knitr::kable(mds)
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
51 ```
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
52
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
53 ### Plot
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
54 ```{r}
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
55 ggplot(mds, aes(x = `1`, y = `2`, col = time)) +
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
56 geom_point(size = 3) + coord_fixed()
6f94b4b9de44 planemo upload
mingchen0919
parents:
diff changeset
57 ```