Mercurial > repos > bebatut > compute_wilcoxon_test
comparison compute_wilcoxon_test.R @ 0:bba4cafe21a8 draft
planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
author | bebatut |
---|---|
date | Tue, 12 Apr 2016 02:56:51 -0400 |
parents | |
children | 309fac5c91d8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bba4cafe21a8 |
---|---|
1 library('getopt') | |
2 | |
3 option_specification = matrix(c( | |
4 'input_file', 'a', 2, 'character', | |
5 'output_file', 'b', 2, 'character', | |
6 'column1_id', 'c', 2, 'integer', | |
7 'column2_id', 'd', 2, 'integer', | |
8 'alternative','e',2,'character', | |
9 'paired','f',2,'logical', | |
10 'exact','g',2,'logical', | |
11 'correct','h',2, 'logical', | |
12 'mu','i',2,'integer' | |
13 ), byrow=TRUE, ncol=4); | |
14 | |
15 options = getopt(option_specification); | |
16 | |
17 data = read.table(options$input_file, sep = '\t', h = T) | |
18 | |
19 column1_id = 1 | |
20 if(!is.null(options$column1_id)) column1_id = options$column1_id | |
21 x = data[,column1_id] | |
22 y = NULL | |
23 if(!is.null(options$column2_id)) y = data[,options$column2_id] | |
24 | |
25 alternative = 'two.sided' | |
26 if(!is.null(options$alternative)) alternative = options$alternative | |
27 | |
28 mu = 0 | |
29 if(!is.null(options$mu)) mu = options$mu | |
30 | |
31 paired = FALSE | |
32 if(!is.null(options$paired)) paired = options$paired | |
33 | |
34 exact = NULL | |
35 if(!is.null(options$exact)) exact = options$exact | |
36 | |
37 correct = TRUE | |
38 if(!is.null(options$correct)) correct = options$correct | |
39 | |
40 test = wilcox.test(x = x, y = y, alternative = alternative, mu = mu, | |
41 paired = paired, exact = exact, correct = correct) | |
42 | |
43 m = matrix(ncol = 2, nrow = 6) | |
44 m[1,] = c('statistic',test$statistic) | |
45 m[2,] = c('parameter',test$parameter) | |
46 m[3,] = c('p.value',test$p.value) | |
47 m[4,] = c('null.value',test$null.value) | |
48 m[5,] = c('alternative',test$alternative) | |
49 m[6,] = c('method',test$method) | |
50 write.table(m, file = options$output_file, sep = "\t", quote = FALSE, | |
51 row.names = FALSE, col.names = FALSE) |