pvalues: P-values reporting

Description Usage Arguments Details Author(s) Examples

Description

This function is implemented in the unique function for univariate statistical analysis 'univariate'. This function reports final p-values foe each pairwise caomparison of sample groups, by merging the p-values from Welch's T test for normally distributed variables with p-values from Wilcoxon-Mann Whitney U test for not-normally distributed variables.

Usage

1
pvalues(file, mtc)

Arguments

file

a connection or a character string giving the name of the file containing the variables

mtc

logical, default is 'TRUE'. Perform multiple testing correction with Banjamini-Hochberg method.

Details

A directory called 'Pvalues' is automatically generated in the directory 'Univariate' in the working directory. A report with merged p-values from each test is written.

Author(s)

Edoardo Gaude, Dimitrios Spiliotopoulos, Francesca Chignola, Silvia Mari, Andrea Spitaleri and Michela Ghitti

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
## The function is currently defined as
function (file, mtc) 
{
    pwdfile = paste(getwd(), "/Univariate/DataTable.csv", sep = "")
    file = pwdfile
    x <- read.csv(file, sep = ",", header = TRUE)
    x.x = x[, 3:ncol(x)]
    rownames(x.x) = x[, 2]
    k = matrix(x[, 1], ncol = 1)
    x.n = cbind(k, x.x)
    sorted = x.n[order(x.n[, 1]), ]
    sorted.x = sorted[, -1]
    g = c()
    for (i in 1:nrow(sorted)) {
        if (any(g == sorted[i, 1])) {
            g = g
        }
        else {
            g = matrix(c(g, sorted[i, 1]), ncol = 1)
        }
    }
    NoF = nrow(g)
    dirout.pv = paste(getwd(), "/Univariate/Pvalues/", sep = "")
    dir.create(dirout.pv)
    dirout.sign = paste(getwd(), "/Univariate/Significant_Variables/", 
        sep = "")
    dir.create(dirout.sign)
    for (i in 1:NoF) {
        for (j in 1:NoF) {
            if (i < j) {
                shapi = paste("ShapiroTest.", i, ".csv", sep = "")
                shapj = paste("ShapiroTest.", j, ".csv", sep = "")
                shap.pwdi = paste(getwd(), "/Univariate/Shapiro_Tests/", 
                  shapi, sep = "")
                shap.pwdj = paste(getwd(), "/Univariate/Shapiro_Tests/", 
                  shapj, sep = "")
                Si = read.csv(shap.pwdi, header = TRUE)
                Sj = read.csv(shap.pwdj, header = TRUE)
                Si = matrix(Si[, -1], ncol = 1)
                Sj = matrix(Sj[, -1], ncol = 1)
                welchij = paste("WelchTest_", i, "vs", j, ".csv", 
                  sep = "")
                welch.pwdij = paste(getwd(), "/Univariate/WelchTest/", 
                  welchij, sep = "")
                Wij = read.csv(welch.pwdij, header = TRUE)
                Wij = matrix(Wij[, -1], ncol = 1)
                wmwp = paste("WMWTest_pvalues_", i, "vs", j, 
                  ".csv", sep = "")
                wmw.pwd = paste(getwd(), "/Univariate/Mann-Whitney_Tests/", 
                  wmwp, sep = "")
                WMWp = read.csv(wmw.pwd, header = TRUE)
                WMWp = matrix(WMWp[, -1], ncol = 1)
                fin = ncol(sorted) - 1
                pvalues = matrix(rep(1, fin))
                for (q in 1:fin) {
                  if (Si[q, ] > 0.05 & Sj[q, ] > 0.05) {
                    pvalues[q, ] <- Wij[q, ]
                  }
                  else {
                    pvalues[q, ] <- WMWp[q, ]
                  }
                }
                if (mtc) {
                  pval.corr = matrix(p.adjust(pvalues, method = c("BH"), 
                    n = nrow(pvalues)), ncol = 1)
                  rownames(pval.corr) = colnames(x.x)
                  pvalfin = paste("Pvalues_", i, "vs", j, ".csv", 
                    sep = "")
                  assign(pvalfin, pval.corr)
                  write.csv(pval.corr, paste(dirout.pv, pvalfin, 
                    sep = ""))
                  sign = c()
                  for (q in 1:fin) {
                    if (pval.corr[q, ] < 0.05) {
                      sign = matrix(c(sign, colnames(sorted.x)[q]))
                    }
                  }
                  signnam = paste("Significant_Variables_", i, 
                    "vs", j, ".csv", sep = "")
                  assign(signnam, sign)
                  write.csv(sign, paste(dirout.sign, signnam, 
                    sep = ""), row.names = FALSE)
                }
                else {
                  rownames(pvalues) = colnames(x.x)
                  pvalfin = paste("Pvalues_", i, "vs", j, ".csv", 
                    sep = "")
                  assign(pvalfin, pvalues)
                  write.csv(pvalues, paste(dirout.pv, pvalfin, 
                    sep = ""))
                  sign = c()
                  for (q in 1:fin) {
                    if (pvalues[q, ] < 0.05) {
                      sign = matrix(c(sign, colnames(sorted.x)[q]))
                    }
                  }
                  signnam = paste("Significant_Variables_", i, 
                    "vs", j, ".csv", sep = "")
                  assign(signnam, sign)
                  write.csv(sign, paste(dirout.sign, signnam, 
                    sep = ""), row.names = FALSE)
                }
            }
        }
    }
  }

muma documentation built on May 2, 2019, 9:45 a.m.