Mercurial > repos > iuc > phyloseq_plot_ordination
annotate phyloseq_plot_ordination.R @ 0:11d43fa12aab draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
author | iuc |
---|---|
date | Thu, 03 Mar 2022 13:28:30 +0000 |
parents | |
children | 92e77800ef2c |
rev | line source |
---|---|
0
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
2 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
3 suppressPackageStartupMessages(library("optparse")) |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
4 suppressPackageStartupMessages(library("phyloseq")) |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
5 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
6 option_list <- list( |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
7 make_option(c("--input"), action = "store", dest = "input", help = "Input file containing a phyloseq object"), |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
8 make_option(c("--method"), action = "store", dest = "method", help = "Ordination method"), |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
9 make_option(c("--distance"), action = "store", dest = "distance", help = "Distance method"), |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
10 make_option(c("--type"), action = "store", dest = "type", help = "Plot type"), |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
11 make_option(c("--output"), action = "store", dest = "output", help = "Output") |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
12 ) |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
13 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
14 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
15 args <- parse_args(parser, positional_arguments = TRUE); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
16 opt <- args$options; |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
17 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
18 # Construct a phyloseq object. |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
19 phyloseq_obj <- readRDS(opt$input); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
20 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
21 # Transform data to proportions as appropriate for |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
22 # Bray-Curtis distances. |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
23 proportions_obj <- transform_sample_counts(phyloseq_obj, function(otu) otu / sum(otu)); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
24 ordination_obj <- ordinate(proportions_obj, method = opt$method, distance = opt$distance); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
25 |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
26 # Start PDF device driver and generate the plot. |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
27 dev.new(); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
28 pdf(file = opt$output); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
29 plot_ordination(proportions_obj, ordination_obj, type = opt$type); |
11d43fa12aab
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff
changeset
|
30 dev.off(); |