Mercurial > repos > iuc > aldex2
annotate aldex2.R @ 1:75214276e2b7 draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
author | iuc |
---|---|
date | Fri, 14 Jun 2024 21:21:29 +0000 |
parents | f4d0bd4b4d6d |
children |
rev | line source |
---|---|
0
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
2 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
3 suppressPackageStartupMessages(library("ALDEx2")) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
4 suppressPackageStartupMessages(library("data.table")) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
5 suppressPackageStartupMessages(library("qgraph")) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
6 suppressPackageStartupMessages(library("optparse")) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
7 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
8 option_list <- list( |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
9 make_option(c("--aldex_test"), action = "store", dest = "aldex_test", default = NULL, help = "Indicates which analysis to perform"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
10 make_option(c("--analysis_type"), action = "store", dest = "analysis_type", help = "Indicates which analysis to perform"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
11 make_option(c("--cutoff_effect"), action = "store", dest = "cutoff_effect", type = "integer", default = NULL, help = "Effect size cutoff for plotting"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
12 make_option(c("--cutoff_pval"), action = "store", dest = "cutoff_pval", type = "double", default = NULL, help = "Benjamini-Hochberg fdr cutoff"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
13 make_option(c("--denom"), action = "store", dest = "denom", help = "Indicates which features to retain as the denominator for the Geometric Mean calculation"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
14 make_option(c("--effect"), action = "store", dest = "effect", default = "false", help = "Calculate abundances and effect sizes"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
15 make_option(c("--feature_name"), action = "store", dest = "feature_name", default = NULL, help = "Name of the feature from the input data to be plotted"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
16 make_option(c("--group_names"), action = "store", dest = "group_names", help = "Group names vector"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
17 make_option(c("--group_nums"), action = "store", dest = "group_nums", default = NULL, help = "Group number for continuous numeric vector"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
18 make_option(c("--hist_plot"), action = "store", dest = "hist_plot", default = "false", help = "Indicates whether to plot a histogram of p-values for the first Dirichlet Monte Carlo instance"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
19 make_option(c("--include_sample_summary"), action = "store", dest = "include_sample_summary", default = "false", help = "Include median clr values for each sample"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
20 make_option(c("--iterate"), action = "store", dest = "iterate", default = "false", help = "Indicates whether to iteratively perform a test"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
21 make_option(c("--num_cols"), action = "store", dest = "num_cols", help = "Number of columns in group vector"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
22 make_option(c("--num_cols_in_groups"), action = "store", dest = "num_cols_in_groups", default = NULL, help = "Number of columns in each group dewfining the continuous numeric vector"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
23 make_option(c("--num_mc_samples"), action = "store", dest = "num_mc_samples", type = "integer", help = "Number of Monte Carlo samples"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
24 make_option(c("--output"), action = "store", dest = "output", help = "output file"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
25 make_option(c("--paired_test"), action = "store", dest = "paired_test", default = "false", help = "Indicates whether to do paired-sample tests"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
26 make_option(c("--plot_test"), action = "store", dest = "plot_test", default = NULL, help = "The method of calculating significance"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
27 make_option(c("--plot_type"), action = "store", dest = "plot_type", default = NULL, help = "The type of plot to be produced"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
28 make_option(c("--reads"), action = "store", dest = "reads", help = "Input reads table"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
29 make_option(c("--xlab"), action = "store", dest = "xlab", default = NULL, help = "x lable for the plot"), |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
30 make_option(c("--ylab"), action = "store", dest = "ylab", default = NULL, help = "y lable for the plot") |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
31 ) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
32 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
33 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
34 args <- parse_args(parser, positional_arguments = TRUE) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
35 opt <- args$options |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
36 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
37 get_boolean_value <- function(val) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
38 if (val == "true") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
39 return(TRUE) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
40 } else { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
41 return(FALSE) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
42 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
43 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
44 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
45 # Read the input reads file into a data frame. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
46 reads_df <- read.table(file = opt$reads, header = TRUE, sep = "\t", row.names = 1, dec = ".", as.is = FALSE) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
47 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
48 # Split the group_names and num_cols into lists of strings. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
49 group_names_str <- as.character(opt$group_names) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
50 group_names_list <- strsplit(group_names_str, ",")[[1]] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
51 num_cols_str <- as.character(opt$num_cols) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
52 num_cols_list <- strsplit(num_cols_str, ",")[[1]] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
53 # Construct conditions vector. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
54 conditions_vector <- c() |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
55 for (i in seq_along(num_cols_list)) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
56 num_cols <- as.integer(num_cols_list[i]) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
57 group_name <- group_names_list[i] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
58 for (j in 1:num_cols) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
59 conditions_vector <- cbind(conditions_vector, group_name) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
60 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
61 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
62 # The conditions_vector is now a matrix, |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
63 # so coerce it back to a vector. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
64 conditions_vector <- as.vector(conditions_vector) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
65 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
66 # Convert boolean values to boolean. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
67 effect <- get_boolean_value(opt$effect) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
68 include_sample_summary <- get_boolean_value(opt$include_sample_summary) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
69 iterate <- get_boolean_value(opt$iterate) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
70 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
71 if (opt$analysis_type == "aldex") { |
1
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
72 aldex_obj <- aldex( |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
73 reads = reads_df, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
74 conditions_vector, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
75 mc.samples = opt$num_mc_samples, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
76 test = opt$aldex_test, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
77 effect = effect, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
78 include.sample.summary = include_sample_summary, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
79 denom = opt$denom, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
80 iterate = iterate |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
81 ) |
0
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
82 } else { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
83 # Generate Monte Carlo samples of the Dirichlet distribution for each sample. Convert each |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
84 # instance using a log-ratio transform. This is the input for all further analyses. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
85 aldex_clr_obj <- aldex.clr(reads_df, conditions_vector, mc.samples = opt$num_mc_samples, denom = opt$denom) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
86 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
87 if (opt$analysis_type == "aldex_corr") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
88 if (!is.null(opt$cont_var)) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
89 # Read the input cont_var vector. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
90 cont_var <- as.numeric(read.table(file = opt$cont_var, header = FALSE, sep = "\t")) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
91 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
92 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
93 # Split the group_names and num_cols into lists of strings. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
94 group_nums_str <- as.character(opt$group_nums) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
95 group_nums_list <- strsplit(group_nums_str, ",")[[1]] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
96 num_cols_in_groups_str <- as.character(opt$num_cols_in_groups) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
97 num_cols_in_groups_list <- strsplit(num_cols_in_groups_str, ",")[[1]] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
98 # Construct continuous numeric vector. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
99 cont_var_vector <- c() |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
100 for (i in seq_along(num_cols_in_groups_list)) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
101 num_cols_in_group <- as.integer(num_cols_in_groups_list[i]) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
102 group_num <- group_nums_list[i] |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
103 for (j in 1:num_cols_in_group) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
104 cont_var_vector <- cbind(cont_var_vector, group_num) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
105 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
106 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
107 # The cont_var_vector is now a matrix, |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
108 # so coerce it back to a vector. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
109 cont_var_vector <- as.numeric(as.vector(cont_var_vector)) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
110 |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
111 aldex_obj <- aldex.corr(aldex_clr_obj, cont.var = cont_var_vector) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
112 } else if (opt$analysis_type == "aldex_effect") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
113 aldex_obj <- aldex.effect(aldex_clr_obj, include_sample_summary) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
114 } else if (opt$analysis_type == "aldex_expected_distance") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
115 dist <- aldex.expectedDistance(aldex_clr_obj) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
116 png(filename = opt$output) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
117 qgraph(dist, layout = "spring", vsize = 1) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
118 dev.off() |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
119 } else if (opt$analysis_type == "aldex_kw") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
120 aldex_obj <- aldex.kw(aldex_clr_obj) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
121 } else if (opt$analysis_type == "aldex_plot") { |
1
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
122 aldex_obj <- aldex( |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
123 reads = reads_df, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
124 conditions_vector, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
125 mc.samples = opt$num_mc_samples, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
126 test = opt$aldex_test, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
127 effect = effect, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
128 include.sample.summary = include_sample_summary, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
129 denom = opt$denom, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
130 iterate = iterate |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
131 ) |
0
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
132 png(filename = opt$output) |
1
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
133 aldex.plot( |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
134 x = aldex_obj, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
135 type = opt$plot_type, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
136 test = opt$plot_test, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
137 cutoff.pval = opt$cutoff_pval, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
138 cutoff.effect = opt$cutoff_effect, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
139 xlab = opt$xlab, |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
140 ylab = opt$ylab |
75214276e2b7
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit f9acc7c5710d6eb99a883cb83b7967e6af972f1b
iuc
parents:
0
diff
changeset
|
141 ) |
0
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
142 dev.off() |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
143 } else if (opt$analysis_type == "aldex_plot_feature") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
144 png(filename = opt$output) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
145 aldex.plotFeature(aldex_clr_obj, opt$feature_name) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
146 dev.off() |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
147 } else if (opt$analysis_type == "aldex_ttest") { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
148 paired_test <- get_boolean_value(opt$paired_test) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
149 hist_plot <- get_boolean_value(opt$hist_plot) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
150 aldex_obj <- aldex.ttest(aldex_clr_obj, paired.test = paired_test, hist.plot = hist_plot) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
151 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
152 } |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
153 if ((opt$analysis_type != "aldex_expected_distance") && (opt$analysis_type != "aldex_plot") && (opt$analysis_type != "aldex_plot_feature")) { |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
154 # Output the ALDEx object. |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
155 write.table(aldex_obj, file = opt$output, append = FALSE, sep = "\t", dec = ".", row.names = FALSE, col.names = TRUE) |
f4d0bd4b4d6d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/aldex2 commit b99f09cf03f075a6881d192b0f1233233289fa60
iuc
parents:
diff
changeset
|
156 } |