comparison phyloseq_plot_ordination.R @ 1:92e77800ef2c draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
author iuc
date Fri, 09 Feb 2024 21:42:09 +0000
parents 11d43fa12aab
children
comparison
equal deleted inserted replaced
0:11d43fa12aab 1:92e77800ef2c
9 make_option(c("--distance"), action = "store", dest = "distance", help = "Distance 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"), 10 make_option(c("--type"), action = "store", dest = "type", help = "Plot type"),
11 make_option(c("--output"), action = "store", dest = "output", help = "Output") 11 make_option(c("--output"), action = "store", dest = "output", help = "Output")
12 ) 12 )
13 13
14 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list); 14 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
15 args <- parse_args(parser, positional_arguments = TRUE); 15 args <- parse_args(parser, positional_arguments = TRUE)
16 opt <- args$options; 16 opt <- args$options
17
18 # Construct a phyloseq object. 17 # Construct a phyloseq object.
19 phyloseq_obj <- readRDS(opt$input); 18 phyloseq_obj <- readRDS(opt$input)
20
21 # Transform data to proportions as appropriate for 19 # Transform data to proportions as appropriate for
22 # Bray-Curtis distances. 20 # Bray-Curtis distances.
23 proportions_obj <- transform_sample_counts(phyloseq_obj, function(otu) otu / sum(otu)); 21 proportions_obj <- transform_sample_counts(phyloseq_obj, function(otu) otu / sum(otu))
24 ordination_obj <- ordinate(proportions_obj, method = opt$method, distance = opt$distance); 22 ordination_obj <- ordinate(proportions_obj, method = opt$method, distance = opt$distance)
25
26 # Start PDF device driver and generate the plot. 23 # Start PDF device driver and generate the plot.
27 dev.new(); 24 dev.new()
28 pdf(file = opt$output); 25 pdf(file = opt$output)
29 plot_ordination(proportions_obj, ordination_obj, type = opt$type); 26 plot_ordination(proportions_obj, ordination_obj, type = opt$type)
30 dev.off(); 27 dev.off()