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