-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
181 lines (146 loc) · 4.71 KB
/
main.nf
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
run = "${params.datain}".split("/")
run = run[run.size()-1]
launchDir = "${launchDir}/${run}"
process FASTQC {
tag "FASTQC on $name using $task.cpus CPUs and $task.memory memory"
//publishDir "${launchDir}/fastQC", mode:'copy'
input:
tuple val(type), val(name), path(reads)
output:
path '*'
//path "fastqc_out/*"
script:
"""
fastqc $reads -o ./
rm -r ?
"""
}
process ALIGN_CPU {
tag "CPU align on $name using $task.cpus CPUs and $task.memory memory"
// publishDir "${launchDir}/mapped/", mode:'copy'
input:
tuple val(type), val(name), path(reads)
output:
tuple val(type), val(name), path("${name}.bam")
script:
rg = "\"@RG\\tID:${name}\\tSM:${name}\\tLB:${name}\\tPL:ILLUMINA\""
"""
#minimap2 -a ${params.refgpu} $reads > ${name}.sam
bwa mem -R ${rg} -t 4*${task.cpus} ${params.refindex} $reads > ${name}.sam
samtools view -Sb ${name}.sam -o ${name}.bam
"""
}
process ALIGN_GPU {
tag "GPU align on $name using $task.cpus CPUs and $task.memory memory"
publishDir "${launchDir}/mapped/", mode:'copy'
accelerator 1
container "cerit.io/ceitec/clara-parabricks:3.8.0-1.ampere"
memory 20.GB
input:
tuple val(name), path(reads)
output:
tuple val(name), path("${name}.bam")
script:
"""
# echo $PATH
/parabricks/run_pipeline.py fq2bam --ref ${params.refgpu} \
--in-fq $reads \
--out-bam ${name}.bam \
--tmp-dir .
"""
}
process SORT_INDEX {
tag "Sort index on $name using $task.cpus CPUs and $task.memory memory"
publishDir "${launchDir}/mapped/", mode:'copy'
input:
tuple val(type), val(name), path(bam)
output:
tuple val(type), val(name), path("${name}.sorted.bam")
tuple val(type), val(name), path("${name}.sorted.bai")
script:
"""
samtools sort ${name}.bam -o ${name}.sorted.bam
samtools index ${name}.sorted.bam ${name}.sorted.bai
"""
}
process COVERAGE_STATS {
tag "Creating coverage stats on $name using $task.cpus CPUs and $task.memory memory"
publishDir "${launchDir}/coverage/", mode:'copy', pattern: "*PBcoverage.txt"
input:
tuple val(type), val(name), path(bam), val(specific_bed)
//val ('specific_bed')
output:
path "*"
script:
"""
bedtools coverage -abam ${specific_bed} -b $bam -d > ${name}.PBcoverage.txt
qualimap bamqc -bam $bam -gff ${params.covbed} -outdir ${name} -outfile ${name}.qualimap -outformat HTML
samtools flagstat $bam > ${name}.flagstat
samtools stats $bam > ${name}.samstats
picard BedToIntervalList -I ${params.covbed} -O ${name}.interval_list -SD ${params.ref}/GRCh38-p10.dict
picard CollectHsMetrics -I $bam -BAIT_INTERVALS ${name}.interval_list -TARGET_INTERVALS ${name}.interval_list -R ${params.ref}/GRCh38-p10.fa -O ${name}.aln_metrics
rm -r ?
"""
}
process MULTIQC {
tag "first QC on $name using $task.cpus CPUs and $task.memory memory"
publishDir "${launchDir}/multiqc/", mode:'copy'
input:
path ("QC_results/*")
output:
path "*"
script:
"""
Rscript --vanilla ${params.coverstat} ${launchDir}/coverage $run
Rscript --vanilla ${params.covcompare} $run ${params.seqstats}
cat PerExon.html | perl -pe 's/[^[:ascii:]]//g;' > PerExon_mqc.html
echo "log_filesize_limit: 30000000" > multiqc_config.yaml
multiqc . -n report_coverage.html
cp report_coverage.html ${params.datain}
"""
}
workflow {
Atero = Channel
.fromFilePairs("${params.datain}/raw_fastq/a*R{1,2}*" )
.map {it -> [ "Atero", it[0], it[1]]}
Hemato = Channel
.fromFilePairs("${params.datain}/raw_fastq/h*R{1,2}*" )
.map {it -> [ "Hemato", it[0], it[1]]}
Fialka = Channel
.fromFilePairs("${params.datain}/raw_fastq/f*R{1,2}*" )
.map {it -> [ "Fialka", it[0], it[1]]}
Pank = Channel
.fromFilePairs("${params.datain}/raw_fastq/p*R{1,2}*" )
.map {it -> [ "Pank", it[0], it[1]]}
Concat = Atero.mix(Hemato,Pank,Fialka)
Concat.view()
fastqced = FASTQC(Concat)
bam = ALIGN_CPU(Concat)
sortedbam = SORT_INDEX(bam)
sortedbam[0].view()
sortedbam[0].branch {
Atero: it[0] == "Atero"
return [it[0], it[1], it[2], params.Atero23_re]
Hemato: it[0] == "Hemato"
return [it[0], it[1], it[2], params.Hemato23_re]
Pank: it[0] == "Pank"
return [it[0], it[1], it[2], params.Pank23]
Fialka: it[0] == "Fialka"
return [it[0], it[1], it[2], params.Fialka23]
}
.set{sorted}
// sortedbam[0].map({
// if it[0] == "Atero"
// return [it, params.Atero23_re]
// if it[0] == "Hemato"
// return [it, params.Hemato23_re]
// }).view()
sorted.Atero.view { "$it is Atero" }
sorted.Hemato.view {"$it is Hemato"}
sorted.Pank.view {"$it is Pank"}
sorted.Fialka.view {"$it is Fialka"}
sorted = sorted.Atero.mix(sorted.Hemato,sorted.Pank,sorted.Fialka)
//.view{"$it is merged"}
stats = COVERAGE_STATS(sorted)
MULTIQC(stats[0].mix(fastqced).collect())
}