comparison compute_wilcoxon_test.R @ 0:2a8acb4c0afc draft default tip

planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 450b58f2de19b05cd05c27ae77376fb1b71f5646
author bebatut
date Thu, 21 Apr 2016 04:21:13 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2a8acb4c0afc
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 'header','y',2,'logical'
14 ), byrow=TRUE, ncol=4);
15
16 options = getopt(option_specification);
17
18 header = TRUE
19 if(!is.null(options$header)) header = options$header
20
21 data = read.table(options$input_file, sep = '\t', h = header)
22
23 column1_id = 1
24 if(!is.null(options$column1_id)) column1_id = options$column1_id
25 x = data[,column1_id]
26 y = NULL
27 if(!is.null(options$column2_id)) y = data[,options$column2_id]
28
29 alternative = 'two.sided'
30 if(!is.null(options$alternative)) alternative = options$alternative
31
32 mu = 0
33 if(!is.null(options$mu)) mu = options$mu
34
35 paired = FALSE
36 if(!is.null(options$paired)) paired = options$paired
37
38 exact = NULL
39 if(!is.null(options$exact)) exact = options$exact
40
41 correct = TRUE
42 if(!is.null(options$correct)) correct = options$correct
43
44 test = wilcox.test(x = x, y = y, alternative = alternative, mu = mu,
45 paired = paired, exact = exact, correct = correct)
46
47 m = matrix(ncol = 2, nrow = 6)
48 m[1,] = c('statistic',test$statistic)
49 m[2,] = c('parameter',test$parameter)
50 m[3,] = c('p.value',test$p.value)
51 m[4,] = c('null.value',test$null.value)
52 m[5,] = c('alternative',test$alternative)
53 m[6,] = c('method',test$method)
54 write.table(m, file = options$output_file, sep = "\t", quote = FALSE,
55 row.names = FALSE, col.names = FALSE)