-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrate_taxa_phyloseq_for_BJ.R
98 lines (87 loc) · 3.12 KB
/
integrate_taxa_phyloseq_for_BJ.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
suppressPackageStartupMessages(library(optparse))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(phyloseq))
# rm(list = ls())
options(stringsAsFactors = F)
options(future.globals.maxSize = 1000 * 1024^2)
option_list <- list(
make_option(c("-p", "--phylum"),
type = "character",
help = "phylum phyloseq",
metavar = "character"),
make_option(c("-c", "--class"),
type = "character",
help = "class phyloseq",
metavar = "character"),
make_option(c("-o", "--order"),
type = "character",
help = "order phyloseq",
metavar = "character"),
make_option(c("-f", "--family"),
type = "character",
help = "family phyloseq",
metavar = "character"),
make_option(c("-g", "--genus"),
type = "character",
help = "genus phyloseq",
metavar = "character"),
make_option(c("-s", "--species"),
type = "character",
help = "species phyloseq",
metavar = "character"),
make_option(c("-n", "--name"),
type = "character",
help = "name of list file",
metavar = "character"),
make_option(c("-r", "--rounds"),
type = "character",
help = "name of rounds",
metavar = "character",
default = "all"),
make_option(c("-d", "--out"),
type = "character",
help = "output file path",
metavar = "character")
)
opt_parser <- OptionParser(option_list = option_list,
add_help_option = FALSE)
opt <- parse_args(opt_parser)
# input parameters
taxa_phylum <- readRDS(opt$phylum)
taxa_class <- readRDS(opt$class)
taxa_order <- readRDS(opt$order)
taxa_family <- readRDS(opt$family)
taxa_genus <- readRDS(opt$genus)
taxa_species <- readRDS(opt$species)
rounds <- opt$rounds
name <- opt$name
out <- opt$out
# rounds <- "all"
# name <- "metaphlan2"
# out <- "phyloseq_v2"
ps_list <- list(phylum = taxa_phylum,
class = taxa_class,
order = taxa_order,
family = taxa_family,
genus = taxa_genus,
species = taxa_species)
# output
if (!dir.exists(out)) {
dir.create(out, recursive = T)
}
round_names <- paste0("metaphlan2_BJ_", rounds, "_ps")
if (name == "total") {
ps_filename <- paste0(out, "/", round_names, "_total_list.RDS")
} else if (name == "filter") {
ps_filename <- paste0(out, "/", round_names, "_filter_list.RDS")
} else if (name == "baseR6") {
ps_filename <- paste0(out, "/", round_names, "_baseR6_list.RDS")
} else if (name == "total_norm") {
ps_filename <- paste0(out, "/", round_names, "_total_norm_list.RDS")
} else if (name == "filter_norm") {
ps_filename <- paste0(out, "/", round_names, "_filter_norm_list.RDS")
} else if (name == "baseR6_norm") {
ps_filename <- paste0(out, "/", round_names, "_baseR6_norm_list.RDS")
}
saveRDS(ps_list, ps_filename, compress = TRUE)
message('Congratulations, Program Ended Without Problem')