setwd(choose.dir())
options(repos=structure(c(CRAN="The Comprehensive R Archive Network")))
install.packages('psych')
install.packages("reshape2")
library(psych)
library(corrplot)
library(pheatmap)
library(reshape2)
Order<-read.table('nirk_属水平.txt', header = TRUE,
sep = '\t',row.names = 1)
Order<-t(Order)
lihua<-read.table('env_table.txt', header = TRUE,
sep = '\t',row.names = 1)
res<-corr.test(Order, lihua, method = 'spearman',
adjust = 'holm',alpha = 0.05)
rmt<-res$r
pmt<-res$p
mycol<-colorRampPalette(c("blue","white","tomato"))(800)
if (!is.null(pmt)){ssmt <- pmt< 0.01
pmt[ssmt] <-'**'
smt <- pmt >0.01& pmt <0.05
pmt[smt] <- '*'
pmt[!ssmt&!smt]<- ''
} else {
pmt <- F
}
pheatmap(rmt, cluster_rows = F, cluster_cols = F,
display_numbers = pmt,fontsize_number = 12,
number_color = "black", cellwidth = 20,
cellheight = 20,color = mycol)