comparison signac-subset.R @ 0:6e0b320d8b6a draft default tip

"planemo upload commit dc808171975d0012e25bd7b32adc7a5a5c56a145-dirty"
author gaelcge
date Tue, 02 Aug 2022 19:11:27 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:6e0b320d8b6a
1 #!/usr/bin/env Rscript
2
3 # Load optparse we need to check inputs
4
5 suppressPackageStartupMessages(require(optparse))
6
7 # Load common functions
8
9 suppressPackageStartupMessages(require(workflowscriptscommon))
10
11 # parse options
12
13 option_list = list(
14 make_option(
15 c("--signac-object"),
16 action = "store",
17 default = NA,
18 type = 'character',
19 help = ""
20 ),
21 make_option(
22 c("--peak-region-fragments-min"),
23 action = "store",
24 default = NA,
25 type = 'character',
26 help = "."
27 ),
28 make_option(
29 c("--peak-region-fragments-max"),
30 action = "store",
31 default = NA,
32 type = 'character',
33 help = "."
34 ),
35 make_option(
36 c("--pct-reads-in-peaks"),
37 action = "store",
38 default = NA,
39 type = 'character',
40 help = "."
41 ),
42 make_option(
43 c("--blacklist-ratio"),
44 action = "store",
45 default = NA,
46 type = 'character',
47 help = "."
48 ),
49 make_option(
50 c("--nucleosome-signal"),
51 action = "store",
52 default = NA,
53 type = 'character',
54 help = "."
55 ),
56 make_option(
57 c("--tss-enrichment"),
58 action = "store",
59 default = NA,
60 type = 'character',
61 help = "."
62 ),
63 make_option(
64 c("--output-object-file"),
65 action = "store",
66 default = NA,
67 type = 'character',
68 help = "File name in which to store serialized R matrix object."
69 )
70 )
71
72 opt <- wsc_parse_args(option_list)
73
74 suppressPackageStartupMessages(require(Signac))
75
76 # extract gene annotations from EnsDb
77 signac_object <- readRDS(file = opt$signac_object)
78
79
80 ## transform input parameters to numeric
81 peak_region_fragments_min <- as.numeric(opt$peak_region_fragments_min)
82 peak_region_fragments_max <- as.numeric(opt$peak_region_fragments_max)
83 pct_reads_in_peaks_var <- as.numeric(opt$pct_reads_in_peaks)
84 blacklist_ratio_var <- as.numeric(opt$blacklist_ratio)
85 nucleosome_signal_var <- as.numeric(opt$nucleosome_signal)
86 tss_enrichment_var <- as.numeric(opt$tss_enrichment)
87
88 print("Signac object before filtering:")
89
90 signac_object
91
92 signac_object <- subset(signac_object, peak_region_fragments > peak_region_fragments_min)
93 signac_object <- subset(signac_object, peak_region_fragments < peak_region_fragments_max)
94 signac_object <- subset(signac_object, pct_reads_in_peaks > pct_reads_in_peaks_var)
95 signac_object <- subset(signac_object, blacklist_ratio < blacklist_ratio_var)
96 signac_object <- subset(signac_object, nucleosome_signal < nucleosome_signal_var)
97 signac_object <- subset(signac_object, TSS.enrichment > tss_enrichment_var)
98
99 print("Signac object after filtering:")
100
101 signac_object
102
103 # Output to a serialized R object
104 saveRDS(signac_object, file = opt$output_object_file)