-
Notifications
You must be signed in to change notification settings - Fork 4
/
ichorCNA_offtarget.snakefile
executable file
·240 lines (227 loc) · 13.5 KB
/
ichorCNA_offtarget.snakefile
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
"""
#must first check to make sure target bed file is compatible with this code in
#code/ichorCNA_offtarget.R (might have to change 'skip' and 'colnames'):
#baits <- fread(baitFile.tum, skip=0)
#colnames(baits) <- c("chr", "start", "end", "name", "strands")
#before running snakemake, do in tmux terminal:
ml snakemake/5.2.4-foss-2016b-Python-3.6.6
ml R/3.6.1-foss-2016b-fh1
ml Python/3.6.6-foss-2016b
#command to run snakemake (remove -np at end when done validating):
snakemake -s ichorCNA_offtarget.snakefile --latency-wait 60 --restart-times 3 --keep-going --cluster-config config/cluster_slurm.yaml --cluster "sbatch -p {cluster.partition} --mem={cluster.mem} -t {cluster.time} -c {cluster.ncpus} -n {cluster.ntasks} -o {cluster.output}" -j 50 -np
"""
configfile: "config/config.yaml"
configfile: "config/samples.yaml"
rule all:
input:
expand("results/readDepth/{samples}.bin{binSize}.wig", samples=config["samples"], binSize=str(config["binSize"])),
expand("results/normalizeOfftarget/{tumor}/{tumor}_offTarget_cor.txt", tumor=config["pairings"]),
expand("results/normalizeOfftarget/{tumor}/{tumor}_onTarget_cor.txt", tumor=config["pairings"]),
expand("results/normalizeOfftarget/{tumor}/{tumor}_allTarget_cor.txt", tumor=config["pairings"]),
expand("results/normalizeOfftarget/{tumor}/{tumor}_readStats.txt", tumor=config["pairings"]),
expand("results/ichorCNA/{tumor}/offTarget/{tumor}.cna.seg", tumor=config["pairings"]),
expand("results/ichorCNA/{tumor}/onTarget/{tumor}.cna.seg", tumor=config["pairings"]),
expand("results/ichorCNA/{tumor}/allTarget/{tumor}.cna.seg", tumor=config["pairings"])
rule read_counter:
input:
lambda wildcards: config["samples"][wildcards.samples]
output:
"results/readDepth/{samples}.bin{binSize}.wig"
params:
readCounter=config["readCounterScript"],
binSize=config["binSize"],
qual="20",
chrs=config["chrs"]
resources:
mem=4
log:
"logs/readDepth/{samples}.bin{binSize}.log"
shell:
"{params.readCounter} {input} -c {params.chrs} -w {params.binSize} -q {params.qual} > {output} 2> {log}"
rule normalizeOffTarget:
input:
tum="results/readDepth/{tumor}.bin" + str(config["binSize"]) + ".wig",
norm=lambda wildcards: "results/readDepth/" + config["pairings"][wildcards.tumor] + ".bin" + str(config["binSize"]) + ".wig"
output:
offNorm="results/normalizeOfftarget/{tumor}/{tumor}_offTarget_cor.txt",
onNorm="results/normalizeOfftarget/{tumor}/{tumor}_onTarget_cor.txt",
allNorm="results/normalizeOfftarget/{tumor}/{tumor}_allTarget_cor.txt",
stats="results/normalizeOfftarget/{tumor}/{tumor}_readStats.txt"
params:
outDir="results/normalizeOfftarget/{tumor}/",
rscript=config["offTarget_script"],
offTargetFuncs=config["offTarget_utils_script"],
id="{tumor}",
chrs=config["ichorCNA_chrs"],
baitBedTum=config["ichorCNA_exons"],
gcWig=config["ichorCNA_gcWig"],
mapWig=config["ichorCNA_mapWig"],
minMapScore=config["ichorCNA_minMapScore"],
centromere=config["ichorCNA_centromere"],
genomeBuild=config["ichorCNA_genomeBuild"],
genomeStyle=config["ichorCNA_genomeStyle"],
fracReadsChrYMale=config["ichorCNA_fracReadsInChrYForMale"],
plotFileType=config["ichorCNA_plotFileType"],
plotYlim=config["ichorCNA_plotYlim"],
libdir=config["ichorCNA_libdir"],
sex=config["ichorCNA_sex"]
log:
"logs/normalizeOfftarget/{tumor}.log"
shell:
"Rscript {params.rscript} --id {params.id} --libdir {params.libdir} --offTargetFuncs {params.offTargetFuncs} --TUMWIG {input.tum} --NORMWIG {input.norm} --baitBedTum {params.baitBedTum} --gcWig {params.gcWig} --mapWig {params.mapWig} --mapScoreThres {params.minMapScore} --centromere {params.centromere} --genomeStyle {params.genomeStyle} --genomeBuild {params.genomeBuild} --fracReadsInChrYForMale {params.fracReadsChrYMale} --plotFileType {params.plotFileType} --plotYLim \"{params.plotYlim}\" --outDir {params.outDir} --sex {params.sex} > {log} 2> {log}"
rule ichorCNA_OffTarget:
input:
logR="results/normalizeOfftarget/{tumor}/{tumor}_offTarget_cor.txt",
stats="results/normalizeOfftarget/{tumor}/{tumor}_readStats.txt"
output:
#corrDepth="results/ichorCNA/{tumor}/offTarget/{tumor}.correctedDepth.txt",
#param="results/ichorCNA/{tumor}/offTarget/{tumor}.params.txt",
cna="results/ichorCNA/{tumor}/offTarget/{tumor}.cna.seg",
#segTxt="results/ichorCNA/{tumor}/offTarget/{tumor}.seg.txt",
#seg="results/ichorCNA/{tumor}/offTarget/{tumor}.seg",
#rdata="results/ichorCNA/{tumor}/offTarget/{tumor}.RData"
params:
outDir="results/ichorCNA/{tumor}/offTarget/",
rscript=config["ichorCNA_rscript"],
id="{tumor}",
ploidy=config["ichorCNA_ploidy"],
normal=config["ichorCNA_normal"],
sex=config["ichorCNA_sex"],
gcwig=config["ichorCNA_gcWig"],
mapwig=config["ichorCNA_mapWig"],
repTimeWig=config["ichorCNA_repTimeWig"],
normalpanel=config["ichorCNA_normalPanel"],
estimateNormal=config["ichorCNA_estimateNormal"],
estimatePloidy=config["ichorCNA_estimatePloidy"],
estimateClonality=config["ichorCNA_estimateClonality"],
scStates=config["ichorCNA_scStates"],
maxCN=config["ichorCNA_maxCN"],
includeHOMD=config["ichorCNA_includeHOMD"],
chrs=config["ichorCNA_chrs"],
chrTrain=config["ichorCNA_chrTrain"],
likModel=config["ichorCNA_likModel"],
genomeBuild=config["ichorCNA_genomeBuild"],
genomeStyle=config["ichorCNA_genomeStyle"],
centromere=config["ichorCNA_centromere"],
fracReadsChrYMale=config["ichorCNA_fracReadsInChrYForMale"],
minMapScore=config["ichorCNA_minMapScore"],
maxFracGenomeSubclone=config["ichorCNA_maxFracGenomeSubclone"],
maxFracCNASubclone=config["ichorCNA_maxFracCNASubclone"],
normal2IgnoreSC=config["ichorCNA_normal2IgnoreSC"],
scPenalty=config["ichorCNA_scPenalty"],
exons=config["ichorCNA_exons"],
txnE=config["ichorCNA_txnE"],
txnStrength=config["ichorCNA_txnStrength"],
plotFileType=config["ichorCNA_plotFileType"],
plotYlim=config["ichorCNA_plotYlim"],
libdir=config["ichorCNA_libdir"]
resources:
mem=4
log:
"logs/ichorCNA/offTarget/{tumor}.log"
shell:
"Rscript {params.rscript} --id {params.id} --libdir {params.libdir} --logRFile {input.logR} --statsFile {input.stats} --gcWig {params.gcwig} --mapWig {params.mapwig} --repTimeWig {params.repTimeWig} --sex {params.sex} --normalPanel {params.normalpanel} --ploidy \"{params.ploidy}\" --normal \"{params.normal}\" --maxCN {params.maxCN} --includeHOMD {params.includeHOMD} --chrs \"{params.chrs}\" --chrTrain \"{params.chrTrain}\" --genomeStyle {params.genomeStyle} --genomeBuild {params.genomeBuild} --estimateNormal {params.estimateNormal} --estimatePloidy {params.estimatePloidy} --estimateScPrevalence {params.estimateClonality} --scStates \"{params.scStates}\" --likModel {params.likModel} --centromere {params.centromere} --exons.bed {params.exons} --txnE {params.txnE} --txnStrength {params.txnStrength} --minMapScore {params.minMapScore} --fracReadsInChrYForMale {params.fracReadsChrYMale} --maxFracGenomeSubclone {params.maxFracGenomeSubclone} --maxFracCNASubclone {params.maxFracCNASubclone} --normal2IgnoreSC {params.normal2IgnoreSC} --scPenalty {params.scPenalty} --plotFileType {params.plotFileType} --plotYLim \"{params.plotYlim}\" --outDir {params.outDir} > {log} 2> {log}"
rule ichorCNA_OnTarget:
input:
logR="results/normalizeOfftarget/{tumor}/{tumor}_onTarget_cor.txt",
stats="results/normalizeOfftarget/{tumor}/{tumor}_readStats.txt"
output:
#corrDepth="results/ichorCNA/{tumor}/onTarget/{tumor}.correctedDepth.txt",
#param="results/ichorCNA/{tumor}/onTarget/{tumor}.params.txt",
cna="results/ichorCNA/{tumor}/onTarget/{tumor}.cna.seg",
#segTxt="results/ichorCNA/{tumor}/onTarget/{tumor}.seg.txt",
#seg="results/ichorCNA/{tumor}/onTarget/{tumor}.seg",
#rdata="results/ichorCNA/{tumor}/onTarget/{tumor}.RData"
params:
outDir="results/ichorCNA/{tumor}/onTarget/",
rscript=config["ichorCNA_rscript"],
id="{tumor}",
ploidy=config["ichorCNA_ploidy"],
normal=config["ichorCNA_normal"],
sex=config["ichorCNA_sex"],
gcwig=config["ichorCNA_gcWig"],
mapwig=config["ichorCNA_mapWig"],
repTimeWig=config["ichorCNA_repTimeWig"],
normalpanel=config["ichorCNA_normalPanel"],
estimateNormal=config["ichorCNA_estimateNormal"],
estimatePloidy=config["ichorCNA_estimatePloidy"],
estimateClonality=config["ichorCNA_estimateClonality"],
scStates=config["ichorCNA_scStates"],
maxCN=config["ichorCNA_maxCN"],
includeHOMD=config["ichorCNA_includeHOMD"],
chrs=config["ichorCNA_chrs"],
chrTrain=config["ichorCNA_chrTrain"],
likModel=config["ichorCNA_likModel"],
genomeBuild=config["ichorCNA_genomeBuild"],
genomeStyle=config["ichorCNA_genomeStyle"],
centromere=config["ichorCNA_centromere"],
fracReadsChrYMale=config["ichorCNA_fracReadsInChrYForMale"],
minMapScore=config["ichorCNA_minMapScore"],
maxFracGenomeSubclone=config["ichorCNA_maxFracGenomeSubclone"],
maxFracCNASubclone=config["ichorCNA_maxFracCNASubclone"],
normal2IgnoreSC=config["ichorCNA_normal2IgnoreSC"],
scPenalty=config["ichorCNA_scPenalty"],
exons=config["ichorCNA_exons"],
txnE=config["ichorCNA_txnE"],
txnStrength=config["ichorCNA_txnStrength"],
plotFileType=config["ichorCNA_plotFileType"],
plotYlim=config["ichorCNA_plotYlim"],
libdir=config["ichorCNA_libdir"]
resources:
mem=4
log:
"logs/ichorCNA/onTarget/{tumor}.log"
shell:
"Rscript {params.rscript} --id {params.id} --libdir {params.libdir} --logRFile {input.logR} --statsFile {input.stats} --gcWig {params.gcwig} --mapWig {params.mapwig} --repTimeWig {params.repTimeWig} --sex {params.sex} --normalPanel {params.normalpanel} --ploidy \"{params.ploidy}\" --normal \"{params.normal}\" --maxCN {params.maxCN} --includeHOMD {params.includeHOMD} --chrs \"{params.chrs}\" --chrTrain \"{params.chrTrain}\" --genomeStyle {params.genomeStyle} --genomeBuild {params.genomeBuild} --estimateNormal {params.estimateNormal} --estimatePloidy {params.estimatePloidy} --estimateScPrevalence {params.estimateClonality} --scStates \"{params.scStates}\" --likModel {params.likModel} --centromere {params.centromere} --exons.bed {params.exons} --txnE {params.txnE} --txnStrength {params.txnStrength} --minMapScore {params.minMapScore} --fracReadsInChrYForMale {params.fracReadsChrYMale} --maxFracGenomeSubclone {params.maxFracGenomeSubclone} --maxFracCNASubclone {params.maxFracCNASubclone} --normal2IgnoreSC {params.normal2IgnoreSC} --scPenalty {params.scPenalty} --plotFileType {params.plotFileType} --plotYLim \"{params.plotYlim}\" --outDir {params.outDir} > {log} 2> {log}"
rule ichorCNA_AllTarget:
input:
logR="results/normalizeOfftarget/{tumor}/{tumor}_allTarget_cor.txt",
stats="results/normalizeOfftarget/{tumor}/{tumor}_readStats.txt"
output:
#corrDepth="results/ichorCNA/{tumor}/onTarget/{tumor}.correctedDepth.txt",
#param="results/ichorCNA/{tumor}/onTarget/{tumor}.params.txt",
cna="results/ichorCNA/{tumor}/allTarget/{tumor}.cna.seg",
#segTxt="results/ichorCNA/{tumor}/onTarget/{tumor}.seg.txt",
#seg="results/ichorCNA/{tumor}/onTarget/{tumor}.seg",
#rdata="results/ichorCNA/{tumor}/onTarget/{tumor}.RData"
params:
outDir="results/ichorCNA/{tumor}/allTarget/",
rscript=config["ichorCNA_rscript"],
id="{tumor}",
ploidy=config["ichorCNA_ploidy"],
normal=config["ichorCNA_normal"],
sex=config["ichorCNA_sex"],
gcwig=config["ichorCNA_gcWig"],
mapwig=config["ichorCNA_mapWig"],
repTimeWig=config["ichorCNA_repTimeWig"],
normalpanel=config["ichorCNA_normalPanel"],
estimateNormal=config["ichorCNA_estimateNormal"],
estimatePloidy=config["ichorCNA_estimatePloidy"],
estimateClonality=config["ichorCNA_estimateClonality"],
scStates=config["ichorCNA_scStates"],
maxCN=config["ichorCNA_maxCN"],
includeHOMD=config["ichorCNA_includeHOMD"],
chrs=config["ichorCNA_chrs"],
chrTrain=config["ichorCNA_chrTrain"],
likModel=config["ichorCNA_likModel"],
genomeBuild=config["ichorCNA_genomeBuild"],
genomeStyle=config["ichorCNA_genomeStyle"],
centromere=config["ichorCNA_centromere"],
fracReadsChrYMale=config["ichorCNA_fracReadsInChrYForMale"],
minMapScore=config["ichorCNA_minMapScore"],
maxFracGenomeSubclone=config["ichorCNA_maxFracGenomeSubclone"],
maxFracCNASubclone=config["ichorCNA_maxFracCNASubclone"],
normal2IgnoreSC=config["ichorCNA_normal2IgnoreSC"],
scPenalty=config["ichorCNA_scPenalty"],
exons=config["ichorCNA_exons"],
txnE=config["ichorCNA_txnE"],
txnStrength=config["ichorCNA_txnStrength"],
plotFileType=config["ichorCNA_plotFileType"],
plotYlim=config["ichorCNA_plotYlim"],
libdir=config["ichorCNA_libdir"]
resources:
mem=4
log:
"logs/ichorCNA/allTarget/{tumor}.log"
shell:
"Rscript {params.rscript} --id {params.id} --libdir {params.libdir} --logRFile {input.logR} --statsFile {input.stats} --gcWig {params.gcwig} --mapWig {params.mapwig} --repTimeWig {params.repTimeWig} --sex {params.sex} --normalPanel {params.normalpanel} --ploidy \"{params.ploidy}\" --normal \"{params.normal}\" --maxCN {params.maxCN} --includeHOMD {params.includeHOMD} --chrs \"{params.chrs}\" --chrTrain \"{params.chrTrain}\" --genomeStyle {params.genomeStyle} --genomeBuild {params.genomeBuild} --estimateNormal {params.estimateNormal} --estimatePloidy {params.estimatePloidy} --estimateScPrevalence {params.estimateClonality} --scStates \"{params.scStates}\" --likModel {params.likModel} --centromere {params.centromere} --exons.bed {params.exons} --txnE {params.txnE} --txnStrength {params.txnStrength} --minMapScore {params.minMapScore} --fracReadsInChrYForMale {params.fracReadsChrYMale} --maxFracGenomeSubclone {params.maxFracGenomeSubclone} --maxFracCNASubclone {params.maxFracCNASubclone} --normal2IgnoreSC {params.normal2IgnoreSC} --scPenalty {params.scPenalty} --plotFileType {params.plotFileType} --plotYLim \"{params.plotYlim}\" --outDir {params.outDir} > {log} 2> {log}"