annotate phyloseq_plot_ordination.R @ 2:b6a38f6222af draft

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