-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10-visu.Rmd
80 lines (62 loc) · 1.74 KB
/
10-visu.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
# Bonus
Dans cette partie, nous allons produire un même graphe avec différentes approches.
## R de base
```{r}
plot(x = exprs$A, y = exprs$M, main = "MA plot",
col = "blue", pch = 16, xlab = "A = intensity", ylab = "M = log2FC")
grid(lty = "solid", col = "lightgray")
abline(h = 0)
```
## ggplot2
```{r}
library(ggplot2)
g <- ggplot(data = exprs, aes(x = A, y = M)) +
geom_point(aes(A, M, colour = factor(ifelse(abs(M) <= 1, 1,2))), size = 0.8) +
geom_hline(yintercept = c(-1,1)) +
scale_color_manual(values = c("black","red")) +
ggtitle("MA plot") +
labs(y = "M = log2FC", x = "A = intensity") +
theme_light() + theme(legend.position = "none")
g
```
## Plotly
### A partir de ggplot2
```{r}
library(plotly)
ggplotly(g)
```
### En plotly pur
```{r}
plot_ly(data = exprs_annot, x = ~A, y = ~M, text = paste("Gene name :", exprs_annot$name), type = 'scatter', mode = 'markers')
```
## echarts
```{r}
library(echarts4r)
library(dplyr)
exprs_annot %>%
mutate(interst = ifelse(abs(M) <= 1, 1,2))|>
group_by(interst)|>
e_charts(A) |>
e_scatter(M, bind = name, symbol_size=10) |>
e_legend(FALSE) |>
e_tooltip() |>
e_color(
c("black", "red")
) |>
e_title("MA plot") |>
e_axis_labels(y = "M = log2FC", x = "A = intensity") |>
e_toolbox_feature(feature = "saveAsImage") |>
e_toolbox_feature(feature = "dataZoom") |>
e_toolbox_feature(feature = "dataView") |>
e_mark_line(data = list(yAxis = -1.5)) |>
e_mark_line(data = list(yAxis = 1.5)) |>
e_tooltip(
formatter = htmlwidgets::JS("
function(params){
return('<strong>' + params.name +
'</strong><br />M: ' + params.value[1] +
'<br />A: ' + params.value[0])
}
")
)
```