view phyloseq_from_biom.R @ 2:b6a38f6222af draft default tip

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
line wrap: on
line source

#!/usr/bin/env Rscript

suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("phyloseq"))
suppressPackageStartupMessages(library("tidyverse"))

option_list <- list(
    make_option(c("--BIOMfilename"), action = "store", dest = "biom", help = "Input BIOM file"),
    make_option(c("--treefilename"), action = "store", dest = "tree", default = NULL, help = "Input Tree newick/nexus file"),
    make_option(c("--parseFunction"), action = "store", dest = "parsefoo", default = "parse_taxonomy_default", help = "Parse function parse_taxonomy_default/read_tree_greengenes"),
    make_option(c("--refseqfilename"), action = "store", dest = "sequences", default = NULL, help = "Input Sequence fasta file"),
    make_option(c("--output"), action = "store", dest = "output", help = "RDS output")
)

parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
args <- parse_args(parser, positional_arguments = TRUE)
opt <- args$options

parsefoo <- get(opt$parsefoo)
phyloseq_obj <- import_biom(
    BIOMfilename = opt$biom,
    treefilename = opt$tree,
    refseqfilename = opt$sequences,
    parseFunction = parsefoo
)

print(phyloseq_obj)

# save R object to file
saveRDS(phyloseq_obj, file = opt$output, compress = TRUE)