-
Notifications
You must be signed in to change notification settings - Fork 0
/
qc_batch_summary.r
123 lines (114 loc) · 4.45 KB
/
qc_batch_summary.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
library(optparse)
option_list <- list(
make_option(opt_str = c("-e","--experiment_id"),
type = "character",
default = NULL,
help = "Sample identifier",
metavar = "character"),
make_option(opt_str = c("-m","--in_method"),
type = "character",
default = NULL,
help = "Input batch pipeline modality string",
metavar = "character"),
make_option(opt_str = c("-i","--in_dir"),
type = "character",
default = NULL,
help = "Input directory containing h5 and json files",
metavar = "character"),
make_option(opt_str = c("-z","--cellrangers_dir"),
type = "character",
default = NULL,
help = "cellrangers out directory",
metavar = "character"),
make_option(opt_str = c("-f","--refdir"),
type = "character",
default = NULL,
help = "reference directory",
metavar = "character"),
make_option(opt_str = c("-k","--in_key"),
type = "character",
default = NULL,
help = "Input sample sheet",
metavar = "character"),
make_option(opt_str = c("-d","--out_dir"),
type = "character",
default = NULL,
help = "Output Directory",
metavar = "character"),
make_option(opt_str = c("-o","--out_html"),
type = "character",
default = NULL,
help = "Output HTML run summary file",
metavar = "character"),
make_option(opt_str = c("-j","--resolution"),
type = "character",
default = NULL,
help = "Resolution choice to set identity of Seurat Object",
metavar = "character"),
make_option(opt_str = c("-c","--percent_mito"),
type = "integer",
default = 10,
help = "Percent Mito Filter Value",
metavar = "integer"),
make_option(opt_str = c("-a","--percent_ribo"),
type = "integer",
default = 20,
help = "Percent Ribo Filter Value",
metavar = "integer"),
make_option(opt_str = c("-b","--filter_MALAT"),
type = "character",
default = FALSE,
help = "Filter MALAT Gene TRUE/FALSE",
metavar = "character"),
make_option(opt_str = c("-u","--filter_MITO"),
type = "character",
default = FALSE,
help = "Filter Mito Genes TRUE/FALSE",
metavar = "character"),
make_option(opt_str = c("-l","--species"),
type = "character",
default = NULL,
help = "Species of Experiment",
metavar = "character"),
make_option(opt_str = c("-q","--filter_RIBO"),
type = "character",
default = FALSE,
help = "Filter Ribo Genes TRUE/FALSE",
metavar = "character"))
opt_parser <- OptionParser(option_list = option_list)
args <- parse_args(opt_parser)
if(is.null(args$experiment_id)) {
print_help(opt_parser)
stop("No parameters supplied.")
}
if(!dir.exists(args$out_dir)) {
dir.create(args$out_dir)
}
rmd_path <- file.path(args$out_dir,
paste0(args$experiment_id,
"_ngs_sample_qc_report.rmd"))
file.copy(system.file("rmarkdown/ngs_sample_qc_report.rmd", package = "qcreporter"),
rmd_path,
overwrite = TRUE)
rmarkdown::render(
input = rmd_path,
params = list( experiment_id = args$experiment_id,
cellrangers_dir = args$cellrangers_dir,
outdir = args$out_dir,
refdir = args$refdir,
projectName = args$experiment_id,
in_method_string = args$in_method,
in_dir = args$in_dir,
in_key = args$in_key,
out_dir = args$out_dir,
species = args$species,
resolution = args$resolution,
percent_mito = args$percent_mito,
percent_ribo = args$percent_ribo,
filter_MALAT = args$filter_MALAT,
filter_MITO = args$filter_MITO,
filter_RIBO = args$filter_RIBO),
output_file = args$out_html,
quiet = TRUE
)
file.remove(rmd_path)