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