组合相关热图
##ggcor包下载
devtools::install_git("https://gitee.com/dr_yingli/ggcor")
library(ggcor)
library(dplyr)
library(vegan)
library(ggplot2)
data("varechem", package = "vegan")
data("varespec", package = "vegan")
mantel <- mantel_test(varespec, varechem, mantel.fun = 'mantel.randtest',spec.dist.method = 'bray', env.dist.method = 'euclidean',
spec.select = list(Spec01 = 1:2,
Spec02 = 3:18,
Spec03 = 19:37
)) %>%
mutate(r_value = cut(r, breaks = c(-Inf, 0.25, 0.5, Inf),
labels = c('<0.25', '0.25-0.5', '>=0.5'), right = FALSE),
p_value = cut(p.value, breaks = c(-Inf, 0.001, 0.01, 0.05, Inf),
labels = c('<0.001', '0.001-0.01', '0.01-0.05', '>=0.05'), right = FALSE))
quickcor(varechem, type = "upper") +
geom_square() +
anno_link(aes(colour = p_value, size = r_value), data = mantel) +
scale_size_manual(values = c(0.5, 1, 2)) +
scale_colour_manual(values = c("#D95F02", "#1B9E77", "#A2A2A288")) +
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))
结果展示:
参考文献
[Structure and function of the global ocean microbiome] http://science.sciencemag.org/ on January 7, 2021