-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.nf
More file actions
159 lines (133 loc) · 5.36 KB
/
main.nf
File metadata and controls
159 lines (133 loc) · 5.36 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
#!/usr/bin/env nextflow
params.help = false
if (params.help) {
log.info """
-----------------------------------------------------------------------
Required arguments
--indexes quoted file path with wildcard ('*.crai') to
cram or bam indexes
--fai file path to .fai reference index
Workflow Options
--outdir output directory for results
default: "./results"
--gff file path to gff matching genome build of
`--indexes`
--sexchroms sex chromosomes as they are in `--indexes`
default: "X,Y"
--exclude regular expression of chromosomes to skip
default: "^GL|^hs|^chrEBV\$|M\$|MT\$|^NC|_random\$|Un_|^HLA\\-|_alt\$|hap\\d+\$"
--zthreshold a sample must greater than this many standard
deviations in order to be found significant
default: 3.5
--distancethreshold consecutive significant points must span this
distance in order to pass this filter
default: 150000
--slop leading and trailing segments added to
significant regions to make them more visible
default: 500000
--ped custom metadata that will be merged with the
.ped output of indexcov
default: false
--samplecol the column header for sample IDs in your custom
ped file
default: "sample_id"
-----------------------------------------------------------------------
""".stripIndent()
exit 0
}
// required arguments
params.indexes = false
if( !params.indexes ) { exit 1, "--indexes is not defined" }
params.fai = false
if( !params.fai ) { exit 1, "--fai is not defined" }
params.gff = false
params.ped = false
project = params.project ?: 'NF'
log.info("\n")
log.info("====================================================================")
log.info("covviz - find large, coverage-based variations on chromosomes ")
log.info("====================================================================")
log.info("\n")
log.info("#### Homepage / Documentation")
log.info("https://github.com/brwnj/covviz")
log.info("#### Authors")
log.info("Joe Brown <brwnjm@gmail.com>")
log.info("\n")
log.info("====================================================================")
log.info("\n")
log.info("Alignment indexes --indexes : ${params.indexes}")
log.info("Reference index --fai : ${params.fai}")
if (params.gff) {
log.info("GFF --gff : ${params.gff}")
}
log.info("Sex chromosomes --sexchroms : ${params.sexchroms}")
log.info("Excluded chroms --exclude : ${params.exclude}")
log.info("Z threshold --zthreshold : ${params.zthreshold}")
log.info("Distance threshold --distancethreshold: ${params.distancethreshold}")
log.info("Significant region slop --slop : ${params.slop}")
log.info("\n")
log.info("====================================================================")
log.info("\n")
// instantiate files
fai = file(params.fai)
outdir = file(params.outdir)
custom_ped = false
if (params.ped) {
custom_ped = file(params.ped)
}
// check file existence
if( !fai.exists() ) { exit 1, "Reference FASTA [${fai}] index does not exist." }
Channel
.fromPath(params.indexes, checkIfExists: true)
.set { index_ch }
Channel
.from(params.gff ? file(params.gff) : false)
.set { gff_ch }
process run_indexcov {
publishDir path: "$outdir/indexcov", mode: "copy"
label 'indexcov'
input:
file idx from index_ch.collect()
file fai
output:
file("${project}*.png")
file("*.html")
file("${project}*.bed.gz") into bed_ch
file("${project}*.ped") into ped_ch
file("${project}*.roc") into roc_ch
script:
excludepatt = params.exclude ? "--excludepatt \"${params.exclude}\"" : ''
"""
goleft indexcov --sex ${params.sexchroms} $excludepatt --directory $project --fai $fai $idx
mv $project/* .
"""
}
// account for optional, custom ped and the need to merge that with indexcov output
(merge_ch, report_ch) = (params.ped ? [ped_ch, Channel.empty()]: [Channel.empty(), ped_ch])
process merge_peds {
input:
file ped from merge_ch
file custom_ped
output:
file 'merged.ped' into merged_ch
script:
template 'merge_peds.py'
}
process build_report {
publishDir path: "$outdir", mode: "copy", pattern: "*.html", overwrite: true
input:
file ped from report_ch.mix(merged_ch).collect()
file roc from roc_ch
file bed from bed_ch
file gff from gff_ch
output:
file("covviz_report.html")
script:
gff_opt = params.gff ? "--gff ${gff}" : ""
gff_attr = params.gffattr ? "--gff-attr ${params.gffattr}" : ""
"""
covviz --min-samples ${params.minsamples} --sex-chroms ${params.sexchroms} --exclude '${params.exclude}' \
--z-threshold ${params.zthreshold} --distance-threshold ${params.distancethreshold} \
--slop ${params.slop} --ped ${ped} ${gff_opt} ${gff_attr} --skip-norm ${bed}
"""
}