美文网首页
相关性热图

相关性热图

作者: JL笔记 | 来源:发表于2022-03-18 22:54 被阅读0次
    ###########2022.03.18########
    ######QDD相关性分析热图######
    install.packages("corrplot")
    library(corrplot)
    qiaodancorr = read.table("E:/Desktop/qiaodan.txt",header = T,sep = "\t",row.names = 1)
    corr <- round(cor(qiaodancorr), 1)
    #构建cor.mtest函数
    cor.mtest <- function(mat, ...) {
      mat <- as.matrix(mat)
      n <- ncol(mat)
      p.mat<- matrix(NA, n, n)
      diag(p.mat) <- 0
      for (i in 1:(n - 1)) {
        for (j in (i + 1):n) {
          tmp <- cor.test(mat[, i], mat[, j], ...)
          p.mat[i, j] <- p.mat[j, i] <- tmp$p.value
        }
      }
      colnames(p.mat) <- rownames(p.mat) <- colnames(mat)
      p.mat
    }
    mydatap<- cor.mtest(qiaodancorr)   #计算原始数据的p.mat并定义此数据集合
    
    pch = 4, pch.col = "black", pch.cex = 3,
    plotCI = c("n","square", "circle", "rect"), lowCI.mat = NULL, uppCI.mat = NULL, ...)
    
    corrplot.mixed(corr = corr,lower = "number", upper = "circle",p.mat = mydatap,
                   insig = "label_sig",
                   sig.level = c(0.001,0.01,0.05),
                   pch.cex = 1,
                   plotCI = c("n","square", "circle", "rect"),
                   lowCI.mat = NULL,
                   uppCI.mat = NULL)
    

    相关文章

      网友评论

          本文标题:相关性热图

          本文链接:https://www.haomeiwen.com/subject/ssnwdrtx.html