-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cwl
More file actions
285 lines (252 loc) · 7.32 KB
/
main.cwl
File metadata and controls
285 lines (252 loc) · 7.32 KB
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
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: Workflow
label: "chipseq - ChIP-seq peak calling pipeline"
doc: |
ChIP-seq analysis pipeline. Performs QC, trimming, BWA-MEM2 alignment,
duplicate marking, BAM filtering, MACS2 peak calling, and bigWig
generation. Supports optional control/input samples for background
subtraction during peak calling.
Part of the pa-cwl (Pretty Agentic CWL) collection.
requirements:
SubworkflowFeatureRequirement: {}
ScatterFeatureRequirement: {}
InlineJavascriptRequirement: {}
MultipleInputFeatureRequirement: {}
StepInputExpressionRequirement: {}
inputs:
# === Treatment samples ===
fastq_fwd:
type: File[]
doc: "Forward read FASTQ files (one per treatment sample)"
fastq_rev:
type: File[]?
doc: "Reverse read FASTQ files (one per treatment sample, omit for single-end)"
sample_ids:
type: string[]
doc: "Treatment sample identifiers (same order as FASTQ files)"
# === Control/input sample (optional) ===
control_fastq_fwd:
type: File?
doc: "Control/input forward read FASTQ"
control_fastq_rev:
type: File?
doc: "Control/input reverse read FASTQ"
control_id:
type: string?
default: "control"
doc: "Control sample identifier"
# === Reference genome ===
genome_fasta:
type: File
doc: "Reference genome FASTA"
gtf:
type: File?
doc: "Gene annotation GTF (for featureCounts on peaks)"
# === Pre-built index (optional) ===
bwa_index:
type: File?
secondaryFiles:
- pattern: ".0123"
- pattern: .amb
- pattern: .ann
- pattern: .bwt.2bit.64
- pattern: .pac
doc: "Pre-built BWA-MEM2 indexed genome FASTA (with .0123 .amb .ann .bwt.2bit.64 .pac)"
# === Tool options ===
trimmer:
type:
type: enum
symbols: [fastp, trim_galore, skip]
default: fastp
doc: "Read trimming tool"
peak_type:
type:
type: enum
symbols: [narrow, broad]
default: narrow
doc: "Peak calling mode (narrow for TFs, broad for histone marks)"
genome_size:
type: string
doc: "Effective genome size for MACS2 (hs, mm, ce, dm, or number like 1.2e7)"
steps:
# =====================
# BWA-MEM2 index building (conditional)
# =====================
build_bwa_index:
run: ../../tools/bwa-mem2-index.cwl
when: $(inputs.bwa_index == null)
in:
genome_fasta: genome_fasta
bwa_index: bwa_index
out: [genome_with_index]
# =====================
# QC + Trimming (treatment samples)
# =====================
qc_trim:
run: steps/qc-trim.cwl
scatter: [fastq_fwd, fastq_rev, sample_id]
scatterMethod: dotproduct
in:
fastq_fwd: fastq_fwd
fastq_rev: fastq_rev
sample_id: sample_ids
trimmer: trimmer
out: [trimmed_fwd, trimmed_rev, fastqc_raw_zip, fastp_json]
# =====================
# QC + Trimming (control sample, conditional)
# =====================
qc_trim_control:
run: steps/qc-trim.cwl
when: $(inputs.fastq_fwd != null)
in:
fastq_fwd: control_fastq_fwd
fastq_rev: control_fastq_rev
sample_id: control_id
trimmer: trimmer
out: [trimmed_fwd, trimmed_rev, fastqc_raw_zip, fastp_json]
# =====================
# Alignment: treatment samples
# =====================
align_treatment:
run: steps/align-bwa.cwl
scatter: [fastq_fwd, fastq_rev, sample_id]
scatterMethod: dotproduct
in:
fastq_fwd: qc_trim/trimmed_fwd
fastq_rev: qc_trim/trimmed_rev
sample_id: sample_ids
genome_fasta:
source:
- bwa_index
- build_bwa_index/genome_with_index
pickValue: first_non_null
out: [aligned_bam, markdup_metrics]
# =====================
# Alignment: control sample (conditional)
# =====================
align_control:
run: steps/align-bwa.cwl
when: $(inputs.fastq_fwd != null)
in:
fastq_fwd: qc_trim_control/trimmed_fwd
fastq_rev: qc_trim_control/trimmed_rev
sample_id: control_id
genome_fasta:
source:
- bwa_index
- build_bwa_index/genome_with_index
pickValue: first_non_null
out: [aligned_bam, markdup_metrics]
# =====================
# BAM filtering: treatment samples
# =====================
filter_treatment:
run: ../../tools/samtools-filter.cwl
scatter: [bam, sample_id]
scatterMethod: dotproduct
in:
bam: align_treatment/aligned_bam
sample_id: sample_ids
out: [filtered_bam]
# =====================
# BAM filtering: control sample (conditional)
# =====================
filter_control:
run: ../../tools/samtools-filter.cwl
when: $(inputs.bam != null)
in:
bam: align_control/aligned_bam
sample_id: control_id
out: [filtered_bam]
# =====================
# Index filtered BAMs (treatment)
# =====================
index_filtered_treatment:
run: ../../tools/samtools-index.cwl
scatter: sorted_bam
in:
sorted_bam: filter_treatment/filtered_bam
out: [indexed_bam]
# =====================
# Index filtered BAM (control, conditional)
# =====================
index_filtered_control:
run: ../../tools/samtools-index.cwl
when: $(inputs.sorted_bam != null)
in:
sorted_bam: filter_control/filtered_bam
out: [indexed_bam]
# =====================
# MACS2 peak calling (per treatment sample)
# =====================
macs2_callpeak:
run: ../../tools/macs2-callpeak.cwl
scatter: [treatment_bam, sample_id]
scatterMethod: dotproduct
in:
treatment_bam: index_filtered_treatment/indexed_bam
control_bam: index_filtered_control/indexed_bam
sample_id: sample_ids
genome_size: genome_size
broad:
source: peak_type
valueFrom: $(self == "broad")
out: [narrow_peaks, broad_peaks, summits, xls, treat_pileup, control_lambda]
# =====================
# BigWig generation (per treatment sample)
# =====================
bamcoverage:
run: ../../tools/deeptools-bamcoverage.cwl
scatter: [bam, sample_id]
scatterMethod: dotproduct
in:
bam: index_filtered_treatment/indexed_bam
sample_id: sample_ids
out: [bigwig]
# =====================
# MultiQC reporting
# =====================
multiqc:
run: ../../tools/multiqc.cwl
in:
report_files:
source:
- qc_trim/fastqc_raw_zip
- qc_trim/fastp_json
- align_treatment/markdup_metrics
linkMerge: merge_flattened
pickValue: all_non_null
title:
default: "pa-cwl chipseq"
out: [html_report, data_dir]
outputs:
peaks:
type: File[]
outputSource:
- macs2_callpeak/narrow_peaks
- macs2_callpeak/broad_peaks
linkMerge: merge_flattened
pickValue: all_non_null
doc: "Peak files (narrowPeak or broadPeak)"
peak_summits:
type: File[]?
outputSource: macs2_callpeak/summits
pickValue: all_non_null
doc: "Peak summit BED files (narrow peaks only)"
peak_xls:
type: File[]
outputSource: macs2_callpeak/xls
doc: "MACS2 peak statistics"
bigwigs:
type: File[]
outputSource: bamcoverage/bigwig
doc: "Normalized bigWig coverage tracks"
filtered_bams:
type: File[]
outputSource: index_filtered_treatment/indexed_bam
doc: "Filtered, deduplicated BAM files"
multiqc_report:
type: File
outputSource: multiqc/html_report
doc: "MultiQC HTML report"