Use library Hmisc to get correlation cofficients and p-matrix

Correlation methods: (“pearson”, “kendall”, “spearman”)

# Let is create function to perform correlations
      mycorr<-function (data, type){
        result<-rcorr(as.matrix(data), type=type)
        result$r
      }
# Get the correlation cofficents
      # use function to get cor.cofficients, rounding results by two digits after point and
      # droping column first from corr data file as it contains names of the lines
      corr_mat_pe<-round(mycorr(corr[,-1], type="pearson"),2) 
      corr_mat_sp<-round(mycorr(corr[,-1], type="spearman"),2)
      head (corr_mat_pe[, 1:4])
##        GY  TKW  GPS  SPMS
## GY   1.00 0.27 0.52  0.42
## TKW  0.27 1.00 0.36  0.21
## GPS  0.52 0.36 1.00  0.64
## SPMS 0.42 0.21 0.64  1.00
## GPMS 0.53 0.15 0.08  0.03
## PH   0.01 0.37 0.02 -0.10
      head (corr_mat_sp[, 1:4])
##        GY  TKW   GPS  SPMS
## GY   1.00 0.27  0.49  0.45
## TKW  0.27 1.00  0.36  0.23
## GPS  0.49 0.36  1.00  0.66
## SPMS 0.45 0.23  0.66  1.00
## GPMS 0.54 0.12  0.04  0.04
## PH   0.04 0.37 -0.02 -0.09
#now get matrix of p-values using cor_pmat function from package corrplot package
      pmat_pe<-  cor_pmat(corr_mat_pe)
      head(pmat_pe[, 1:4])
##               GY       TKW          GPS         SPMS
## GY   0.000000000 0.3876520 0.0088497029 0.0207259864
## TKW  0.387651953 0.0000000 0.1798113511 0.4274754132
## GPS  0.008849703 0.1798114 0.0000000000 0.0001059547
## SPMS 0.020725986 0.4274754 0.0001059547 0.0000000000
## GPMS 0.042126036 0.9308283 0.9368401430 0.8960470454
## PH   0.083868330 0.4650376 0.1430241168 0.0420613975
      pmat_sp<-  cor_pmat(corr_mat_sp)
      head(pmat_pe[, 1:4]) 
##               GY       TKW          GPS         SPMS
## GY   0.000000000 0.3876520 0.0088497029 0.0207259864
## TKW  0.387651953 0.0000000 0.1798113511 0.4274754132
## GPS  0.008849703 0.1798114 0.0000000000 0.0001059547
## SPMS 0.020725986 0.4274754 0.0001059547 0.0000000000
## GPMS 0.042126036 0.9308283 0.9368401430 0.8960470454
## PH   0.083868330 0.4650376 0.1430241168 0.0420613975

Visualize the correlation matrix through heatmaps in ggcorrplot package

 myggcorr<-function(cor_cof, p.mat){
      ggcorrplot(cor_cof, method="circle",hc.order = FALSE,outline.col = "blue", 
                   type="lower", lab=TRUE,  p.mat =p.mat, insig = "blank",pch = 4, 
                   pch.col="black", pch.cex = 5,
                   show.diag = FALSE, lab_col = "black", lab_size = 2, sig.level =c(0.1,0.05,0.01),
                   tl.cex=10, tl.col="black", tl.srt=45, digits=2)
      }
# Now plot correlation heatmap method pearson using function myggcorr
      myggcorr(cor_cof=corr_mat_pe, p.mat=pmat_pe)

# Now plot correlation heat map method spearman
      myggcorr(cor_cof=corr_mat_sp, p.mat=pmat_sp)