-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathextraplot.Rmd
117 lines (91 loc) · 2.91 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
# Plots from other packages
We will see two additional types of plots:
* Heat map (package gplots)
* Venn diagram (from package VennDiagram)
## heatmap.2 function from gplots 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 gplots package
install.packages("gplots")
```
```{r, eval=T}
# load package
library("gplots")
# make matrix
mat <- matrix(rnorm(1200), ncol=6)
# heatmap with the defaults parameters
heatmap.2(x=mat)
```
<img src="images/plots/heatmap1.png" width="500"/>
* Useful arguments include:
* Rowv, Colv : process clustering of columns or rows (default TRUE to both)
* dendrogram : show dendrogram for row, col, both or none
* scale : scale data per row, column, or none
* col : dendrogram color palette
* trace : control the cyan density lines
* RowSideColors, ColSideColors : block of colors that represent the columns or the rows
* labRow,labCol : remove or keep row or col labels
* main : title
* xlab, ylab: x-axis or y-axis label
```{r}
heatmap.2(x=mat,
Colv=FALSE,
dendrogram="row",
scale="row",
col="bluered",
trace="none",
ColSideColors=rep(c("green","orange"), each=3),
labRow=FALSE,
main="my heatmap",
ylab="Genes",
xlab="Samples")
```
<img src="images/plots/heatmap2.png" width="500"/>
## 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}
# 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}
# 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}
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"/>