安装ggcor包
原作者已经删除了该R包的链接,需要自己上网搜索下载并安装该包。本地安装包。
PS: 为了方便大家,暂时把安装包放在百度云盘,尽量下载保存到本地,后期我可能会删除该包
链接:https://pan.baidu.com/s/10zk5El3kooeHuPsz2qul-A
提取码:3zly
加载包
library(vegan)
library(ggcor)
library(tidyverse)
Correlation plot
set_scale()
quickcor(mtcars) + geom_square()
quickcor(mtcars, type = "upper") + geom_circle2()
quickcor(mtcars, cor.test = TRUE) +
geom_square(data = get_data(type = "lower", show.diag = FALSE)) +
geom_mark(data = get_data(type = "upper", show.diag = FALSE), size = 2.5) +
geom_abline(slope = -1, intercept = 12)
Mantel test plot
data(varechem)
data(varespec)
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.value, breaks = c(-Inf, 0.01, 0.05, Inf),
labels = c("< 0.01", "0.01 - 0.05", ">= 0.05")))
quickcor(varechem, type = "upper") +
geom_square() +
anno_link(aes(colour = pd, size = rd), data = mantel) +
scale_size_manual(values = c(0.5, 1, 2))+
guides(size = guide_legend(title = "Mantel's r",
order = 2),
colour = guide_legend(title = "Mantel's p",
order = 1),
fill = guide_colorbar(title = "Pearson's r", order = 3))
Circular heatmap
rand_correlate(100, 8) %>% ## require ambient packages
quickcor(circular = TRUE, cluster = TRUE, open = 45) +
geom_colour(colour = "white", size = 0.125) +
anno_row_tree() +
anno_col_tree() +
set_p_xaxis() +
set_p_yaxis()