Mercurial > repos > ethevenot > univariate
comparison univariate_script.R @ 2:09799fc16bc6 draft
planemo upload for repository https://github.com/workflow4metabolomics/univariate.git commit 2c0d4d97c208edca1ada2035a7b7af9c4eb31afe
author | ethevenot |
---|---|
date | Sat, 06 Aug 2016 12:42:42 -0400 |
parents | ef64d3752050 |
children | 140290de7986 |
comparison
equal
deleted
inserted
replaced
1:fdefbc780d2e | 2:09799fc16bc6 |
---|---|
52 method = adjC) | 52 method = adjC) |
53 | 53 |
54 sigVn <- as.numeric(fdrVn < thrN) | 54 sigVn <- as.numeric(fdrVn < thrN) |
55 | 55 |
56 if(tesC %in% c("ttest", "wilcoxon")) | 56 if(tesC %in% c("ttest", "wilcoxon")) |
57 varPfxC <- paste0(varPfxC, paste(rev(facLevVc), collapse = "-"), "_") | 57 varPfxC <- paste0(varPfxC, paste(rev(facLevVc), collapse = "."), "_") |
58 | 58 |
59 varDF[, paste0(varPfxC, ifelse(tesC %in% c("ttest", "wilcoxon"), "dif", "cor"))] <- staVn | 59 varDF[, paste0(varPfxC, ifelse(tesC %in% c("ttest", "wilcoxon"), "dif", "cor"))] <- staVn |
60 | 60 |
61 varDF[, paste0(varPfxC, adjC)] <- fdrVn | 61 varDF[, paste0(varPfxC, adjC)] <- fdrVn |
62 | 62 |
64 | 64 |
65 } else if(tesC == "anova") { | 65 } else if(tesC == "anova") { |
66 | 66 |
67 ## getting the names of the pairwise comparisons 'class1Vclass2' | 67 ## getting the names of the pairwise comparisons 'class1Vclass2' |
68 prwVc <- rownames(TukeyHSD(aov(datMN[, 1] ~ facFcVn))[["facFcVn"]]) | 68 prwVc <- rownames(TukeyHSD(aov(datMN[, 1] ~ facFcVn))[["facFcVn"]]) |
69 | |
70 prwVc <- gsub("-", ".", prwVc, fixed = TRUE) ## 2016-08-05: '-' character in dataframe column names seems not to be converted to "." by write.table on ubuntu R-3.3.1 | |
69 | 71 |
70 aovMN <- t(apply(datMN, 2, function(varVn) { | 72 aovMN <- t(apply(datMN, 2, function(varVn) { |
71 | 73 |
72 aovMod <- aov(varVn ~ facFcVn) | 74 aovMod <- aov(varVn ~ facFcVn) |
73 pvaN <- summary(aovMod)[[1]][1, "Pr(>F)"] | 75 pvaN <- summary(aovMod)[[1]][1, "Pr(>F)"] |
95 ## getting the names of the pairwise comparisons 'class1Vclass2' | 97 ## getting the names of the pairwise comparisons 'class1Vclass2' |
96 nemMN <- posthoc.kruskal.nemenyi.test(datMN[, 1], facFcVn, "Tukey")[["p.value"]] | 98 nemMN <- posthoc.kruskal.nemenyi.test(datMN[, 1], facFcVn, "Tukey")[["p.value"]] |
97 nemVl <- c(lower.tri(nemMN, diag = TRUE)) | 99 nemVl <- c(lower.tri(nemMN, diag = TRUE)) |
98 nemClaMC <- cbind(rownames(nemMN)[c(row(nemMN))][nemVl], | 100 nemClaMC <- cbind(rownames(nemMN)[c(row(nemMN))][nemVl], |
99 colnames(nemMN)[c(col(nemMN))][nemVl]) | 101 colnames(nemMN)[c(col(nemMN))][nemVl]) |
100 nemNamVc <- paste0(nemClaMC[, 1], "-", nemClaMC[, 2]) | 102 nemNamVc <- paste0(nemClaMC[, 1], ".", nemClaMC[, 2]) |
101 nemNamVc <- paste0(varPfxC, nemNamVc) | 103 nemNamVc <- paste0(varPfxC, nemNamVc) |
102 | 104 |
103 nemMN <- t(apply(datMN, 2, function(varVn) { | 105 nemMN <- t(apply(datMN, 2, function(varVn) { |
104 | 106 |
105 pvaN <- kruskal.test(varVn ~ facFcVn)[["p.value"]] | 107 pvaN <- kruskal.test(varVn ~ facFcVn)[["p.value"]] |
106 varNemMN <- posthoc.kruskal.nemenyi.test(varVn, facFcVn, "Tukey")[["p.value"]] | 108 varNemMN <- posthoc.kruskal.nemenyi.test(varVn, facFcVn, "Tukey")[["p.value"]] |
107 c(pvaN, c(varNemMN)) | 109 c(pvaN, c(varNemMN)) |