-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathREADME.Rmd
142 lines (109 loc) · 3.4 KB
/
README.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
139
140
141
142
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# linkET
<!-- badges: start -->
<!-- badges: end -->
The goal of `linkET` is to visualize simply and directly a matrix heatmap based
on 'ggplot2'. **Note: all functions of network have been merged in netET package.**
## Installation
You can install the released version of `linkET` from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("Hy4m/linkET", force = TRUE)
packageVersion("linkET")
```
## Example
This is a basic example which shows you how to solve a common problem:
### Data processing
```{r data_processing}
library(linkET)
## matrix_data
matrix_data(list(mtcars = mtcars))
## md_tbl
matrix_data(list(mtcars = mtcars)) %>%
as_md_tbl()
## as method
as_matrix_data(mtcars)
as_md_tbl(mtcars)
## special function for correlation matrix
correlate(mtcars) %>%
as_matrix_data()
correlate(mtcars) %>%
as_md_tbl()
```
### Heatmap
```{r heatmap}
library(ggplot2)
matrix_data(list(mtcars = mtcars)) %>%
hyplot(aes(fill = mtcars)) +
geom_tile()
as_md_tbl(mtcars) %>%
hyplot(aes(size = mtcars)) +
geom_point(shape = 21, fill = NA)
correlate(mtcars) %>%
as_md_tbl() %>%
qcorrplot() +
geom_square()
library(vegan)
data("varespec")
data("varechem")
correlate(varespec[1:30], varechem) %>%
qcorrplot() +
geom_square() +
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu"))
qcorrplot(varespec[1:30], type = "lower") +
geom_square() +
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu"))
## you can set your style
set_corrplot_style()
qcorrplot(mtcars) + geom_square()
## reset to default style
set_default_style()
```
## mantel test
```{r mantel}
library(dplyr)
data("varechem", package = "vegan")
data("varespec", package = "vegan")
mantel <- mantel_test(varespec, varechem,
spec_select = list(Spec01 = 1:7,
Spec02 = 8:18,
Spec03 = 19:37,
Spec04 = 38:44)) %>%
mutate(rd = cut(r, breaks = c(-Inf, 0.2, 0.4, Inf),
labels = c("< 0.2", "0.2 - 0.4", ">= 0.4")),
pd = cut(p, breaks = c(-Inf, 0.01, 0.05, Inf),
labels = c("< 0.01", "0.01 - 0.05", ">= 0.05")))
qcorrplot(correlate(varechem), type = "lower", diag = FALSE) +
geom_square() +
geom_couple(aes(colour = pd, size = rd),
data = mantel,
curvature = nice_curvature()) +
scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu")) +
scale_size_manual(values = c(0.5, 1, 2)) +
scale_colour_manual(values = color_pal(3)) +
guides(size = guide_legend(title = "Mantel's r",
override.aes = list(colour = "grey35"),
order = 2),
colour = guide_legend(title = "Mantel's p",
override.aes = list(size = 3),
order = 1),
fill = guide_colorbar(title = "Pearson's r", order = 3))
```
## pairs plot
```{r}
qpairs(iris) + geom_pairs()
```
## Citation
To cite linkET in publications use:
Houyun Huang(2021). linkET: Everything is Linkable. R package version 0.0.3.