forked from porchard/2021-03-sn-muscle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-read-beds.nf
80 lines (52 loc) · 1.49 KB
/
make-read-beds.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
#!/usr/bin/env nextflow
ATAC_BAM_GLOB = params.atac_bam_glob
RNA_BAM_GLOB = params.rna_bam_glob
process make_bed_atac {
publishDir "${params.results}/beds/atac"
input:
file(bam) from Channel.fromPath(ATAC_BAM_GLOB)
output:
file("${library}.pruned.bed.gz") into atac_bed_out
script:
library = bam.getName().replaceAll('.pruned.bam', '')
"""
bedtools bamtobed -i $bam | awk '\$5="."' | perl -pe 's/ /\\t/g' | gzip -c > ${library}.pruned.bed.gz
"""
}
process add_barcodes_to_readname {
input:
file(bam) from Channel.fromPath(RNA_BAM_GLOB)
output:
file("${library}.with-barcodes.bam") into rna_in
script:
library = bam.getName().replaceAll('.before-dedup.bam', '')
"""
add-barcode-and-umi-to-readname.py $bam ${library}.with-barcodes.bam
"""
}
process make_bed_rna {
publishDir "${params.results}/beds/rna"
input:
file(bam) from rna_in
output:
file("${library}.pruned-no-dedup.bed.gz") into rna_bed_out
script:
library = bam.getName().replaceAll('.with-barcodes.bam', '')
"""
bedtools bamtobed -i $bam | awk '\$5="."' | perl -pe 's/ /\\t/g' | gzip -c > ${library}.pruned-no-dedup.bed.gz
"""
}
process update_read_names_and_starch {
publishDir "${params.results}/starch"
memory '150 GB'
errorStrategy 'ignore'
input:
file(bed) from atac_bed_out.mix(rna_bed_out)
output:
file("${pref}.starch")
script:
pref = bed.getName().replaceAll('.bed.gz', '')
"""
change-read-names.py $bed | cut -f1-4,6 | sort -k1,1 -k2n,2 -k3n,3 -S 70G | starch - > ${pref}.starch
"""
}