annotate phyloseq_from_dada2.R @ 1:1ff178d1757e 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:16 +0000
parents 92b82deaaed1
children fb7c4bbe8994
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
92b82deaaed1 "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
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
2
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
3 suppressPackageStartupMessages(library("optparse"))
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
4 suppressPackageStartupMessages(library("phyloseq"))
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
5 suppressPackageStartupMessages(library("tidyverse"))
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
6
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
7 option_list <- list(
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
8 make_option(c("--sequence_table"), action = "store", dest = "sequence_table", help = "Input sequence table"),
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
9 make_option(c("--taxonomy_table"), action = "store", dest = "taxonomy_table", help = "Input taxonomy table"),
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
10 make_option(c("--output"), action = "store", dest = "output", help = "RDS output")
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
11 )
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
12
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
13 parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
14 args <- parse_args(parser, positional_arguments = TRUE)
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
15 opt <- args$options
0
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
16 # The input sequence_table is an integer matrix
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
17 # stored as tabular (rows = samples, columns = ASVs).
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
18 seq_table_numeric_matrix <- data.matrix(read.table(opt$sequence_table, sep = "\t"))
0
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
19 # The input taxonomy_table is a table containing
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
20 # the assigned taxonomies exceeding the minBoot
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
21 # level of bootstrapping confidence. Rows correspond
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
22 # to sequences, columns to taxonomic levels. NA
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
23 # indicates that the sequence was not consistently
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
24 # classified at that level at the minBoot threshold.
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
25 tax_table_matrix <- as.matrix(read.table(opt$taxonomy_table, header = FALSE, sep = "\t"))
0
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
26 # Construct a tax_table object. The rownames of
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
27 # tax_tab must match the OTU names (taxa_names)
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
28 # of the otu_table defined below.
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
29 tax_tab <- tax_table(tax_table_matrix)
0
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
30 # Construct an otu_table object.
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
31 otu_tab <- otu_table(seq_table_numeric_matrix, taxa_are_rows = TRUE)
0
92b82deaaed1 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit d1004c06207be773c278e12745aada276b63172e"
iuc
parents:
diff changeset
32 # Construct a phyloseq object.
1
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
33 phyloseq_obj <- phyloseq(otu_tab, tax_tab)
1ff178d1757e planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/phyloseq commit 7df921baa7aa8680421b9440a1cd6eaab1a15ce2
iuc
parents: 0
diff changeset
34 saveRDS(phyloseq_obj, file = opt$output, compress = TRUE)