annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
1 library('getopt')
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
2
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
3 option_specification = matrix(c(
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
4 'input_file', 'a', 2, 'character',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
5 'output_file', 'b', 2, 'character',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
6 'column1_id', 'c', 2, 'integer',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
7 'column2_id', 'd', 2, 'integer',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
8 'alternative','e',2,'character',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
9 'paired','f',2,'logical',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
10 'exact','g',2,'logical',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
11 'correct','h',2, 'logical',
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
12 'mu','i',2,'integer'
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
13 ), byrow=TRUE, ncol=4);
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
14
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
15 options = getopt(option_specification);
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
16
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
17 data = read.table(options$input_file, sep = '\t', h = T)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
18
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
19 column1_id = 1
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
20 if(!is.null(options$column1_id)) column1_id = options$column1_id
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
21 x = data[,column1_id]
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
22 y = NULL
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
23 if(!is.null(options$column2_id)) y = data[,options$column2_id]
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
24
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
25 alternative = 'two.sided'
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
26 if(!is.null(options$alternative)) alternative = options$alternative
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
27
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
28 mu = 0
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
29 if(!is.null(options$mu)) mu = options$mu
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
30
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
31 paired = FALSE
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
32 if(!is.null(options$paired)) paired = options$paired
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
33
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
34 exact = NULL
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
35 if(!is.null(options$exact)) exact = options$exact
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
36
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
37 correct = TRUE
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
38 if(!is.null(options$correct)) correct = options$correct
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
39
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
40 test = wilcox.test(x = x, y = y, alternative = alternative, mu = mu,
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
41 paired = paired, exact = exact, correct = correct)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
42
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
43 m = matrix(ncol = 2, nrow = 6)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
44 m[1,] = c('statistic',test$statistic)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
45 m[2,] = c('parameter',test$parameter)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
46 m[3,] = c('p.value',test$p.value)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
47 m[4,] = c('null.value',test$null.value)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
48 m[5,] = c('alternative',test$alternative)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
49 m[6,] = c('method',test$method)
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
50 write.table(m, file = options$output_file, sep = "\t", quote = FALSE,
bba4cafe21a8 planemo upload for repository https://github.com/asaim/galaxytools/tree/master/tools/compute_wilcoxon_test commit 5c45ed58045ce1686aa069403f8a9426ea20bac5-dirty
bebatut
parents:
diff changeset
51 row.names = FALSE, col.names = FALSE)