forked from nebiolabs/EM-seq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bins.nf
63 lines (49 loc) · 1.42 KB
/
bins.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
Channel.fromPath(params.inputdir + "*.methylKit.gz").into{methylkit_files; for_bins}
ref = params.reference_fasta
annotation = params.annotation
ref_len = params.reference_lengths
process make_bed {
cpus 5
conda "bioconda::deeptools"
errorStrategy 'finish'
input:
file methylkit from methylkit_files
output:
file('*.bed') into for_bigwig
shell:
'''
lib=$(basename !{methylkit} .methylKit.gz)
zcat !{methylkit} | tail -n +2 | awk '{ if ($5 >= 8) { print } }' \
| awk '{ printf("%s\\t%s\\t%s\\t%s\\n", $2, $3 - 1, $3, $6); }' \
| LC_COLLATE=C sort -k1,1 -k2,2n > ${lib}.bed
'''
}
process make_bigwig {
cpus 1
conda "bioconda::ucsc-bedgraphtobigwig"
publishDir "/mnt/home/mcampbell/20200317_new_emseq_figure", mode: "copy"
errorStrategy 'finish'
input:
file bed from for_bigwig
output:
file ('*.bw') into _bigwig
shell:
'''
lib=$(basename !{bed} .bed)
bedGraphToBigWig !{bed} !{ref_len} ${lib}.bw
'''
}
process binned_figure {
cpus 1
publishDir "/mnt/home/mcampbell/20200317_new_emseq_figure", mode: "copy"
errorStrategy 'finish'
input:
file methylkit from for_bins
output:
file ('*.tab') into _bins
shell:
'''
lib=$(basename !{methylkit} .methylKit.gz)
TSS_cpg_bins.py --methylkit !{methylkit} --fasta !{ref} --prefix ${lib} --annotation !{annotation}
'''
}