-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_pyCHiC_pipeline.py
334 lines (283 loc) · 12.9 KB
/
run_pyCHiC_pipeline.py
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import os
import argparse
import sys
from basic_modules.metadata import Metadata
from process_CHiC import process_CHiC
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=
"""
This script runs the CHi-C pipeline using pyCHiC
to normalize and call chromatin interactions.
""")
OPTIONAL = parser._action_groups.pop()
REQUIRED = parser.add_argument_group('required arguments')
#Inputs
REQUIRED.add_argument("--genome_fa",
help=" Reference genome in FASTA format",
required=True
)
REQUIRED.add_argument("--probes_fa",
help=" FASTA format containing the DNA probes"
" used to capture the baits",
required=True)
REQUIRED.add_argument("--fastq1", help=" FASTQ forward reads",
required=True)
REQUIRED.add_argument("--fastq2", help=" FASTQ reverse reads",
required=True)
REQUIRED.add_argument("--bowtie_idx",
help=" TAR folder containing all files from a"
" bowtie2 indexing of the reference genome",
required=True)
#Arguments
REQUIRED.add_argument("--RE_name",
help="Restriction enzyme name used to perform the "
"experiment (case sensitive). Example: HindIII",
required=True)
REQUIRED.add_argument("--RE_sequence",
help="Restriction enzyme target sequence, "
"using a pipe '^' indicating the cutting place."
" Example A^AGCTT",
required=True)
OPTIONAL.add_argument("--execution",
help=" execution directory",
default=".")
OPTIONAL.add_argument("--minFragLen",
help=" The minimum fragment length. If there is any "
"fragment shorter than this length, this would be eliminated.",
default="150")
OPTIONAL.add_argument("--maxFragLen",
help=" The maximum fragment length. If there is any "
"fragment larger than this length, this would be eliminated.",
default="40000")
OPTIONAL.add_argument("--maxLBrownEst",
help=" Maximum distance to calculate the Brownian noise",
default="1500000")
OPTIONAL.add_argument("--binsize",
help="The size of the bins (in bps) for pooling restriction fragments. ",
default="20000")
OPTIONAL.add_argument("--hicup_longest",
help=" Parameter passed to HiCUP. "
"Maximum size from the start of "
"the read to the restriction size target. ",
default="800")
OPTIONAL.add_argument("--hicup_shortest",
help=" Parameter passed to HiCUP. "
"Minimum size from the start of the "
"read to the restriction size target. ",
default="150")
OPTIONAL.add_argument("--cutoff",
help=" significant cutoff for chromatin interactions",
default="5")
OPTIONAL.add_argument("--export_format",
help=" pyCHiC export format: seqMonk, interBed, washU_text",
default="washU_text")
OPTIONAL.add_argument("--order",
help=" Order of the output interactions: 'position' or 'score'",
default="score")
OPTIONAL.add_argument("--minNPerBait",
help=" Minimum number of interactions per bait",
default="250")
OPTIONAL.add_argument("--filterTopPercent",
help="Top percentile of trans interactions that are going to be removed"\
"durint the estimation of 'other end' bias factor",
default="0.01")
OPTIONAL.add_argument("--minProxOEPerBin",
help="Minimum number of trans interactions for every bin during "\
"normalisation of other ends",
default="150")
OPTIONAL.add_argument("--minProxB2BPerBin",
help="Minimum number of trans interactions for every bin during "\
"normalisation of bait to bait in other ends",
default="15")
OPTIONAL.add_argument("--techNoise_minBaitsPerBin",
help="Minimum number of trans interactions for every "\
"bin during normalisation of baits",
default="150")
OPTIONAL.add_argument("--brownianNoise_samples",
help=" Number of times to estimate the brownian noise",
default="1")
OPTIONAL.add_argument("--brownianNoise_subset",
help=" Number of samples to take for the estimation "\
"of the brownian noise",
default="500")
OPTIONAL.add_argument("--brownianNoise_seed",
help=" Seed to control the samples subseting for the "\
"brownian estimation",
default=None
)
OPTIONAL.add_argument("--weightAlpha",
help=" Alpha parameter for the p value weighting",
default="34.1157346557331")
OPTIONAL.add_argument("--weightBeta",
help=" Beta parameter for the p value weighting",
default="-2.58688050486759")
OPTIONAL.add_argument("--weightGamma",
help=" Gamma parameter for the p value weighting",
default="-17.1347845819659")
OPTIONAL.add_argument("--weightDelta",
help=" Delta parameter for the p value weighting",
default="-7.07609245521541")
OPTIONAL.add_argument("--plot_baits",
help=" coma separated list of features from baits to plot",
default="None")
OPTIONAL.add_argument("--output_file",
help="output name of the interactions file",
default="washU_text.txt")
OPTIONAL.add_argument("--output_pdf",
help="output name for the pdf containing the bait plots",
default="pdf_examples.pdf")
OPTIONAL.add_argument("--output_parameters",
help="output name for parameter file",
default="parameters.txt")
OPTIONAL.add_argument("--output_chinput",
help="output name for the chinput file",
default="output_chinput.chinput")
OPTIONAL.add_argument("--output_hicup",
help="output name for hicup file",
default="output.tar")
OPTIONAL.add_argument("--cpu",
default="1")
parser._action_groups.append(OPTIONAL) # pylint: disable=protected-access
ARGS = parser.parse_args()
GENOME_FA = ARGS.genome_fa
PROBES_FA = ARGS.probes_fa
FASTQ1 = ARGS.fastq1
FASTQ2 = ARGS.fastq2
BOWTIE = ARGS.bowtie_idx
EXECUTION = ARGS.execution
RE_NAME = ARGS.RE_name
RE_SEQUENCE = ARGS.RE_sequence
MINFRAGLEN = ARGS.minFragLen
MAXFRAGLEN = ARGS.maxFragLen
MAXLBROWNEST = ARGS.maxLBrownEst
BINSIZE = ARGS.binsize
HICUP_LONGEST = ARGS.hicup_longest
HICUP_SHORTEST = ARGS.hicup_shortest
CUTOFF = ARGS.cutoff
EXPORT_FORMAT = ARGS.export_format
ORDER = ARGS.order
MINNPERBAIT = ARGS.minNPerBait
FILTERTOPPERCENT = ARGS.filterTopPercent
MINPROXOEPERBIN = ARGS.minProxOEPerBin
MINPROXB2BPERBIN = ARGS.minProxB2BPerBin
TECHNOISE_MINBAITSPERBIN = ARGS.techNoise_minBaitsPerBin
BROWNIANNOISE_SAMPLES = ARGS.brownianNoise_samples
BROWNIANNOISE_SUBSET = ARGS.brownianNoise_subset
BROWNIANNOISE_SEED = ARGS.brownianNoise_seed
WEIGHTALPHA = ARGS.weightAlpha
WEIGHTBETA = ARGS.weightBeta
WEIGHTGAMMA = ARGS.weightGamma
WEIGHTDELTA = ARGS.weightDelta
PLOTBAITS = ARGS.plot_baits
WASHU = ARGS.output_file
PDF = ARGS.output_pdf
PARAMETERS = ARGS.output_parameters
CHINPUT = ARGS.output_chinput
HICUP = ARGS.output_hicup
CPU = ARGS.cpu
RE_SEQUENCE = RE_SEQUENCE.replace("^", "|")
INPUT_FILES = {
"genome_fa" : GENOME_FA,
"probes_fa" : PROBES_FA,
"fastq1" : FASTQ1,
"fastq2" : FASTQ2,
"bowtie_gen_idx" : BOWTIE
}
CONFIGURATION = {
"execution" : EXECUTION,
"chic_RE_name" : RE_NAME,
"chic_RE_sequence" : RE_SEQUENCE,
"makeDesignFiles_minFragLen" : MINFRAGLEN,
"makeDesignFiles_maxFragLen" : MAXFRAGLEN,
"makeDesignFiles_maxLBrownEst" : MAXLBROWNEST,
"makeDesignFiles_binsize" : BINSIZE,
"hicup_longest" : HICUP_LONGEST,
"hicup_shortest": HICUP_SHORTEST,
"pychic_cutoff" : CUTOFF,
"pychic_export_format": EXPORT_FORMAT,
"pychic_order" : ORDER,
"pychic_minNPerBait" : MINNPERBAIT,
"pychic_tlb_filterTopPercent" : FILTERTOPPERCENT,
"pychic_tlb_minProxOEPerBin" : MINPROXOEPERBIN,
"pychic_tlb_minProxB2BPerBin" : MINPROXB2BPERBIN,
"pychic_techNoise_minBaitsPerBin": TECHNOISE_MINBAITSPERBIN,
"pychic_brownianNoise_samples" : BROWNIANNOISE_SAMPLES,
"pychic_brownianNoise_subset" : BROWNIANNOISE_SUBSET,
"pychic_brownianNoise_seed": BROWNIANNOISE_SEED,
"pychic_weightAlpha" : WEIGHTALPHA,
"pychic_weightBeta" : WEIGHTBETA,
"pychic_weightGamma" : WEIGHTGAMMA,
"pychic_weightDelta" : WEIGHTDELTA,
"pychic_features_plot": PLOTBAITS,
"pychic_cpu": CPU
}
OUTPUT_FILES = {
"hicup_outdir_tar": EXECUTION + "/" + HICUP,
"chinput": EXECUTION + "/" + CHINPUT,
"washU_text" : EXECUTION + "/" + WASHU,
"pdf_examples": EXECUTION + "/" + PDF,
"params_out": EXECUTION + "/" + PARAMETERS
}
INPUT_METADATA = {
"fastq1": Metadata(
data_type="text",
file_type="fastq",
file_path=INPUT_FILES["fastq1"],
sources="",
taxon_id=9606,
meta_data=""
),
"fastq2": Metadata(
data_type="text",
file_type="fastq",
file_path=INPUT_FILES["fastq2"],
sources="",
taxon_id=9606,
meta_data=""
),
"genome_fa" : Metadata(
data_type="text",
file_type="fasta",
file_path=INPUT_FILES["genome_fa"],
sources="",
taxon_id=9606,
meta_data={
"assembly" : "GRCh38"
},
),
"bowtie_gen_idx" : Metadata(
"index_bwa", "", INPUT_FILES["genome_fa"],
{
"assembly": "test",
"tool": "bwa_indexer"
}
),
"probes_fa" : Metadata(
"C-HiC probes", "fasta", "tests/data/test_baitmap/baits.fa",
None, None, 9606),
"hicup_outdir_tar" : Metadata(
"TAR", "CHiC_data", "tests/data/SRR3535023_1_2.hicup.bam",
{"fastq1" : "SRR3535023_1.fastq",
"fastq2" : "SRR3535023_2.fastq", "genome" : "human_hg19"},
9606),
"chinput" : Metadata(
"data_chicago", "chinput", [], None, None, 9606)
}
sys._run_from_cmdl = True # pylint: disable=protected-access
if not os.path.isdir(CONFIGURATION["execution"]):
os.makedirs(CONFIGURATION["execution"])
CHIC_HDL = process_CHiC(CONFIGURATION)
CHIC_HDL.run(INPUT_FILES, INPUT_METADATA, OUTPUT_FILES)