Mercurial > repos > artbio > gsc_mannwhitney_de
annotate MannWhitney_DE.R @ 4:6916ac5a9ef0 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
author | artbio |
---|---|
date | Thu, 30 Nov 2023 02:03:53 +0000 |
parents | 3d86c89f15bf |
children | a7eb04240b8b |
rev | line source |
---|---|
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
1 # Perform a differential analysis between 2 groups of cells. |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
2 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
3 # Example of command |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
4 # Rscript MannWhitney_DE.R --input <input.tsv> --sep <tab> --colnames <TRUE> --metadata <signature.tsv> --column_name <rate> --fdr <0.01> --output <diff_analysis.tsv> |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
5 |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
6 options(show.error.messages = FALSE, |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
7 error = function() { |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
8 cat(geterrmessage(), file = stderr()) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
9 q("no", 1, FALSE) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
10 } |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
11 ) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
12 |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
13 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
14 |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
15 suppressPackageStartupMessages({ |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
16 library(optparse) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
17 }) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
18 |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
19 sessionInfo() |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
20 |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
21 option_list <- list( |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
22 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
23 "--input", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
24 default = NA, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
25 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
26 help = "Input file that contains log2(CPM +1) values" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
27 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
28 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
29 "--sep", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
30 default = "\t", |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
31 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
32 help = "File separator [default : '%default' ]" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
33 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
34 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
35 "--colnames", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
36 default = TRUE, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
37 type = "logical", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
38 help = "Consider first line as header ? [default : '%default' ]" |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
39 ), |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
40 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
41 "--comparison_factor_file", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
42 default = NA, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
43 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
44 help = " A two column table : cell identifiers and a comparison factor that split cells in two categories (high/low, HOM/HET,...)" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
45 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
46 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
47 "--factor1", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
48 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
49 help = "level associated to the control condition in the factor file" |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
50 ), |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
51 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
52 "--factor2", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
53 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
54 help = "level associated to the test condition in the factor file" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
55 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
56 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
57 "--fdr", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
58 default = 0.01, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
59 type = "numeric", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
60 help = "FDR threshold [default : '%default' ]" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
61 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
62 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
63 "--log", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
64 default = FALSE, |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
65 action = "store_true", |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
66 type = "logical", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
67 help = "Expression data are log-transformed [default : '%default' ]" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
68 ), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
69 make_option( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
70 "--output", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
71 default = "results.tsv", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
72 type = "character", |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
73 help = "Output name [default : '%default' ]" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
74 ) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
75 ) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
76 |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
77 opt <- parse_args(OptionParser(option_list = option_list), |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
78 args = commandArgs(trailingOnly = TRUE)) |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
79 |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
80 if (opt$sep == "tab") { |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
81 opt$sep <- "\t" |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
82 } |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
83 if (opt$sep == "comma") { |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
84 opt$sep <- "," |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
85 } |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
86 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
87 #Open files |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
88 data.counts <- read.table( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
89 opt$input, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
90 h = opt$colnames, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
91 row.names = 1, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
92 sep = opt$sep, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
93 check.names = FALSE |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
94 ) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
95 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
96 metadata <- read.table( |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
97 opt$comparison_factor_file, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
98 header = TRUE, |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
99 stringsAsFactors = FALSE, |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
100 sep = "\t", |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
101 check.names = FALSE, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
102 row.names = 1 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
103 ) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
104 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
105 metadata <- subset(metadata, rownames(metadata) %in% colnames(data.counts)) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
106 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
107 # Create two logical named vectors for each factor level of cell signature |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
108 factor1_cells <- setNames(metadata[, 1] == opt$factor1, rownames(metadata)) |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
109 factor2_cells <- setNames(metadata[, 1] == opt$factor2, rownames(metadata)) |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
110 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
111 ## Mann-Whitney test (Two-sample Wilcoxon test) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
112 MW_test <- data.frame(t(apply(data.counts, 1, function(x) { |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
113 do.call("cbind", wilcox.test(x[names(factor1_cells)[factor1_cells]], x[names(factor2_cells)[factor2_cells]]))[, 1:2] |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
114 })), stringsAsFactors = FALSE) |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
115 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
116 # Benjamini-Hochberg correction and significativity |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
117 MW_test$p.adjust <- p.adjust(as.numeric(MW_test$p.value), method = "BH", n = nrow(MW_test)) |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
118 MW_test$Significant <- MW_test$p.adjust < opt$fdr |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
119 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
120 ## Descriptive Statistics Function |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
121 descriptive_stats <- function(InputData) { |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
122 SummaryData <- data.frame( |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
123 mean = rowMeans(InputData), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
124 SD = apply(InputData, 1, sd), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
125 Variance = apply(InputData, 1, var), |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
126 Percentage_Detection = apply(InputData, 1, function(x, y = InputData) { |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
127 (sum(x != 0) / ncol(y)) * 100 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
128 }), |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
129 mean_condition2 = rowMeans(InputData[, factor2_cells]), |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
130 mean_condition1 = rowMeans(InputData[, factor1_cells]) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
131 ) |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
132 if (opt$log) { |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
133 SummaryData$log2FC <- SummaryData$mean_condition2 - SummaryData$mean_condition1 |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
134 } else { |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
135 SummaryData$log2FC <- log2(SummaryData$mean_condition2 / SummaryData$mean_condition1) |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
136 } |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
137 return(SummaryData) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
138 } |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
139 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
140 gene_stats <- descriptive_stats(data.counts) |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
141 |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
142 results <- merge(gene_stats, MW_test, by = "row.names") |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
143 colnames(results)[1] <- "genes" |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
144 |
3
3d86c89f15bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit fab41058cef186159d746c55808d0e69f252af2f"
artbio
parents:
0
diff
changeset
|
145 ## Annotate Significant column |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
146 results$Significant[results$Significant == TRUE & !is.na(results$Significant)] <- ifelse(subset(results, Significant == TRUE)$log2FC > 0, "UP", "DOWN") |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
147 results$Significant[results$Significant == FALSE & !is.na(results$Significant)] <- "NS" |
3
3d86c89f15bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit fab41058cef186159d746c55808d0e69f252af2f"
artbio
parents:
0
diff
changeset
|
148 |
3d86c89f15bf
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit fab41058cef186159d746c55808d0e69f252af2f"
artbio
parents:
0
diff
changeset
|
149 |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
150 # Save files |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
151 write.table( |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
152 results[order(results$p.adjust), ], |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
153 opt$output, |
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
154 sep = "\t", |
4
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
155 quote = FALSE, |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
156 col.names = TRUE, |
6916ac5a9ef0
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_mannwhitney_de commit c394391dcf541d91ee1dfdc0c3d80cd7a21942ff
artbio
parents:
3
diff
changeset
|
157 row.names = FALSE |
0
c67dba545a37
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/gsc_mannwhitney_de commit 09dcd74dbc01f448518cf3db3e646afb0675a6fe
artbio
parents:
diff
changeset
|
158 ) |