-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnakeABC_SE.smk
238 lines (191 loc) · 6.09 KB
/
snakeABC_SE.smk
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
import pandas as pd
container: "docker://continuumio/miniconda3:23.10.0-1"
workdir: config['WORKDIR']
locals().update(config)
config['UNINFORMATIVE_READ'] = 3 - int(INFORMATIVE_READ) # whether read 1 or read 2 is informative
manifest = pd.read_table(MANIFEST, index_col = False, sep = ',')
print(manifest)
barcode_df = pd.read_csv(config['barcode_csv'], header = None, sep = ':', names = ['barcode', 'RBP'])
# basic checking
assert not barcode_df['barcode'].duplicated().any()
assert not barcode_df['RBP'].duplicated().any() # cannot have any duplicated RBP names
assert not barcode_df['RBP'].str.contains(' ').any() # DO NOT CONTAIN white space lah
assert not manifest['fastq'].duplicated().any()
assert not manifest['libname'].str.contains(' ').any()
libnames = manifest['libname'].tolist()
config['libnames'] = libnames
experiments = manifest['experiment'].tolist()
config['experiments'] = experiments
rbps = barcode_df['RBP'].tolist()
config['rbps'] = rbps
print(f'RBPs: {rbps}',
f'experiments:{experiments}',
f'libnames:{libnames}')
try:
external_normalization = config['external_bam']
print(external_normalization)
print('External normalization libs:',list(external_normalization.keys()))
except:
external_normalization = None
if config['RBP_TO_RUN_MOTIF'] is None:
config['RBP_TO_RUN_MOTIF'] = []
if config['AS_INPUT'] is None:
config['AS_INPUT'] = []
if len(rbps)==1:
singleplex = True
else:
singleplex = False
# making the error files directory
try:
os.mkdir('error_files')
except:
pass
# making the stdout directory
try:
os.mkdir('stdout')
except:
pass
module preprocess:
snakefile:
"rules/se_preprocess.smk"
config: config
module QC:
snakefile:
"rules/QC.smk"
config:
config
module normalization:
snakefile:
"rules/skipper.smk"
config:
config
module DMN:
snakefile:
"rules/normalization_DMN.smk"
config:
config
module finemap:
snakefile:
"rules/finemap.smk"
config:
config
module repeat:
snakefile:
"rules/repeat.smk"
config:
config
module repeat_dmn:
snakefile:
"rules/repeat_DMN.smk"
config:
config
module make_track:
snakefile:
"rules/make_track.smk"
config:
config
module merge_bw:
snakefile:
"rules/merge_bw.smk"
config:
config
module analysis:
snakefile:
"rules/analysis.smk"
config:
config
module clipper:
snakefile:
"rules/clipper.smk"
config:
config
module clipper_analysis:
snakefile:
"rules/clipper_analysis.smk"
config:
config
module compare:
snakefile:
"rules/compare.smk"
config:
config
include: "generate_output.py"
rule all:
input:
get_output(config['run_clipper'], config['run_skipper'], config['run_comparison'])
############## PREPROCESS #################
use rule * from preprocess as pre_*
############## QUALITY CONTROL #################
use rule * from QC as qc_*
use rule gather_fastqc_report from QC as fastqc_gather with:
input:
expand("{libname}/fastqc/ultraplex_demux_{sample_label}.rev_fastqc/fastqc_data.txt",
libname = libnames,
sample_label = rbps)
use rule gather_fastqc_report from QC as fastqc_gather_initial with:
input:
expand("{libname}/fastqc/initial_{read}_fastqc/fastqc_data.txt",
libname = libnames,
read = ['r1'])
output:
basic='QC/fastQC_initial_basic_summary.csv',
passfail='QC/fastQC_initial_passfail.csv'
use rule count_demultiplex_ultraplex from QC with:
input:
fq1=expand("{libname}/fastqs/ultraplex_demux_{sample_label}.fastq.gz",
libname = libnames, sample_label = rbps)
############## SKIPPER: GENOME #################
use rule * from normalization as skipper_*
use rule * from finemap as fine_*
############## SKIPPER: REPEAT #################
use rule * from repeat as re_*
############## DMN #################
use rule * from DMN as dmn_*
use rule * from repeat_dmn as redmn_*
############## DMN #################
use rule * from clipper as clipper_*
use rule * from clipper_analysis as clipper_analysis_*
############## BIGWIGS #################
use rule CITS_bam_to_bedgraph from make_track as CITS_bedgraph with:
input:
bam="{libname}/bams/{sample_label}.rmDup.Aligned.sortedByCoord.out.bam"
output:
pos=temp("{libname}/bw/CITS/{sample_label}.pos.bedgraph"),
neg=temp("{libname}/bw/CITS/{sample_label}.neg.bedgraph")
use rule COV_bam_to_bedgraph from make_track as COV_bedgraph with:
input:
bam="{libname}/bams/{sample_label}.rmDup.Aligned.sortedByCoord.out.bam"
output:
pos=temp("{libname}/bw/COV/{sample_label}.pos.bedgraph"),
neg=temp("{libname}/bw/COV/{sample_label}.neg.bedgraph")
use rule CITS_bam_to_bedgraph from make_track as CITS_bedgraph_external with:
input:
bam=lambda wildcards: ancient(config['external_bam'][wildcards.external_label]['file'])
output:
pos=temp("external_bw/CITS/{external_label}.pos.bedgraph"),
neg=temp("external_bw/CITS/{external_label}.neg.bedgraph")
params:
run_time="1:00:00",
error_out_file = "error_files/CIT_bedgraph.{external_label}",
out_file = "stdout/CITS_bedgraph.{external_label}",
cores = 1,
memory = 40000,
use rule COV_bam_to_bedgraph from make_track as COV_bedgraph_external with:
input:
bam=lambda wildcards: ancient(config['external_bam'][wildcards.external_label]['file'])
output:
pos=temp("external_bw/COV/{external_label}.pos.bedgraph"),
neg=temp("external_bw/COV/{external_label}.neg.bedgraph")
params:
run_time="1:00:00",
error_out_file = "error_files/COV_bedgraph.{external_label}",
out_file = "stdout/COV_bedgraph.{external_label}",
cores = 1,
memory = 40000,
use rule bedgraph_to_bw from make_track
########## MERGE BW ############
use rule * from merge_bw
########## HOMER ############
use rule * from analysis
######## COMPARE ###########
use rule * from compare