-
Notifications
You must be signed in to change notification settings - Fork 1
/
extraplot.Rmd
139 lines (105 loc) · 3.28 KB
/
extraplot.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Plots from other packages
We will see two additional types of plots:
* Heat map (from package pheatmap)
* Venn diagram (from package VennDiagram)
## pheatmap function from the pheatmap package
A heatmap is a graphical representation of data where the values are represented with **colors**.
<br>
The **heatmap.2** function from the **gplots** package allows to produce highly customizable heatmaps.
```{r, eval=F}
# install pheatmap package
install.package("pheatmap")
```
Get started:
```{r, eval=T, results="hide"}
# load package
library(pheatmap)
# create matrix
mat <- matrix(rnorm(1200), ncol=6)
# heatmap with the defaults parameters
pheatmap(mat)
# add a title
pheatmap(mat, main="My pretty heatmap")
```
Change the color palette / gradient
```{r, eval=T}
# with "rainbow" colors
pheatmap(mat,
color=rainbow(50))
# with blue to red (middle color white)
pheatmap(mat,
color=colorRampPalette(c("navy", "white", "red"))(50))
```
Do not cluster rows or columns
```{r, eval=T, results="hide"}
# remove the clustering by rows
pheatmap(mat,
cluster_rows=FALSE)
# remove the clustering by columns
pheatmap(mat,
cluster_cols=FALSE)
# remove both clusterings
pheatmap(mat,
cluster_rows=FALSE,
cluster_cols=FALSE)
```
Add some **annotation colored bar(s)**:
```{r, eval=T}
# add column names to mat
colnames(mat) <- paste0("Sample", 1:6)
# create data frame for annotation (in the case of samples, information about the experiment, for example)
annot_cols = data.frame(
Group = c(rep("WT", 3), rep("KO", 3)),
TimePoint = rep(c(0, 5, 10), each=2),
row.names = colnames(mat)
)
# plot
pheatmap(mat,
annotation_col = annot_cols)
```
## venn.diagram function from VennDiagram package
*A Venn diagram shows all possible logical relations between data sets.*
<br>
The **venn.diagram** function from the **VennDiagram** package allows to create up to a 5-way Venn Diagram (i.e. 5 circles representing 5 data sets).
```{r, eval=FALSE}
# load package
library(VennDiagram)
# Prepare character vectors
v1 <- c("DKK1", "NPC1", "NAPG", "ERG", "VHL", "BTD", "MALL", "HAUS1")
v2 <- c("SMAD4", "DKK1", "ASXL3", "ERG", "CKLF", "TIAM1", "VHL", "BTD", "EMP1", "MALL", "PAX3")
v3 <- c("PAX3", "SMAD4", "DKK1", "MALL", "ERG", "CDKN2A", "DENR", "NPC1", "NAPG")
# Create a list of vectors
vlist <- list(v1, v2, v3)
names(vlist) <- c("list1", "list2", "list3")
# 2-way Venn
venn.diagram(vlist[1:2],
filename="Venn_2way.png",
imagetype="png")
```
<img src="images/plots/Venn_2way.png" width="450"/>
```{r, eval=FALSE}
# 3-way Venn
venn.diagram(vlist,
filename="Venn_3way.png",
imagetype="png")
```
<img src="images/plots/Venn_3way.png" width="450"/>
* More arguments:
* main : title
* sub : sub-title
* main.col : color of title font
* fill : color of circles
* col : color of circle lines
* cat.col : color of category labels
```{r, eval=FALSE}
venn.diagram(vlist,
filename="Venn_3way_more.png",
imagetype="png",
main="Venn diagram",
sub="3-way",
main.col="red",
fill=c("lightgreen", "lightblue", "lightsalmon"),
col=c("lightgreen", "lightblue", "lightsalmon"),
cat.col=c("green", "blue", "salmon"))
```
<img src="images/plots/Venn_3way_more.png" width="500"/>