❝本节来回答交流群内的一个问题,如何绘制对角线热图,数据为随意构建无实际意义,整个过程仅参考。希望对各位观众老爷能有所帮助。❞
❝通过对角线分割,一半展示r值,一半展示p值 ❞
library(tidyverse)
library(magrittr)
library(reshape)
library(psych)
library(MetBrewer)
table1 <- read_tsv("varechem.tsv")
table2 <- read_tsv("varespec.tsv") %>% select(1:20)
pp <- corr.test(table1,table2,method="pearson",adjust = "fdr")
df <- melt(pp$r) %>% mutate(pvalue=melt(pp$p)[,3],
p_signif=symnum(pvalue, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", "", " "))) %>%
set_colnames(c("env","genus","r","p","p_signif")) %>%
mutate(p=round(p,digits = 2))