R可视化:叠加mantel test结果的相关性图

安装ggcor包

原作者已经删除了该R包的链接,需要自己上网搜索下载并安装该包。本地安装包。更多知识分享请到 https://zouhua.top/

PS: 为了方便大家,暂时把安装包放在百度云盘,尽量下载保存到本地,后期我可能会删除该包

链接:https://pan.baidu.com/s/10zk5El3kooeHuPsz2qul-A 
提取码:3zly

Example

library(vegan)
library(ggcor)
library(tidyverse)

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))
R可视化:叠加mantel test结果的相关性图_第1张图片

参考

  1. ggcor绘制相关性热图

参考文章如引起任何侵权问题,可以与我联系,谢谢。

你可能感兴趣的:(R可视化:叠加mantel test结果的相关性图)