Generate correlation matrix
library(psych)
occor = corr.test(data,use="pairwise",method="spearman",adjust="fdr",alpha=0.05)
occor.r = occor$r # 取相关性矩阵R值
occor.p = occor$p # 取相关性矩阵p值
# occor.r[occor.p>0.01|abs(occor.r)<0.6] = 0
occor.r[1:5, 1:5] #查看部分数据
## OTU805 OTU646 OTU160 OTU151 OTU472
## OTU805 1.0000000 1.0000000 0.7378648 -0.4000000 -0.2000000
## OTU646 1.0000000 1.0000000 0.7378648 -0.4000000 -0.2000000
## OTU160 0.7378648 0.7378648 1.0000000 0.1054093 -0.1054093
## OTU151 -0.4000000 -0.4000000 0.1054093 1.0000000 0.8000000
## OTU472 -0.2000000 -0.2000000 -0.1054093 0.8000000 1.0000000
dat = occor.r[1:30, 1:30]
Set color
library(paletteer)
library(RColorBrewer)
my_color = rev(paletteer_d("RColorBrewer::RdYlGn"))
my_color = colorRampPalette(my_color)(10)
Plot!
library(corrplot)
## corrplot 0.87 loaded
corrplot(dat,
method="pie",
order="hclust",
col=my_color,
tl.col=NULL,
#tl.pos = "d",
tl.srt=45, tl.cex = 0.4, addgrid.col = 'white', outline = 'white')

Just the upper
library(corrplot)
corrplot(dat, method="pie", type = 'upper', order="hclust", col=my_color,
tl.col=NULL, #tl.pos = "d",
tl.srt=45, tl.cex = 0.4, addgrid.col = 'white', outline = 'white')

Just the lower
corrplot(dat,
method="pie", type = 'lower',
order="hclust",
col=my_color,
tl.col=NULL,
#tl.pos = "d",
tl.srt=45, tl.cex = 0.4, addgrid.col = 'white', outline = 'white')

Change color and shape!
corrplot(dat,
method="circle",
order="hclust",
col=my_color,
tl.col=NULL,
#tl.pos = "d",
tl.srt=45, tl.cex = 0.4, addgrid.col = 'white', outline = 'white')

my_color = rev(paletteer_d("RColorBrewer::RdYlBu"))
my_color = colorRampPalette(my_color)(10)
corrplot(dat,
method="pie",
order="hclust",
col=my_color,
tl.col=NULL,
#tl.pos = "d",
tl.srt=45, tl.cex = 0.4, addgrid.col = 'white', outline = 'white')
