-
Notifications
You must be signed in to change notification settings - Fork 2
/
af-rna.nf
101 lines (88 loc) · 2.54 KB
/
af-rna.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
// generates RAD file using alevin
process alevin_rad{
container params.SALMON_CONTAINER
label 'cpus_12'
tag "${meta.run_id}-rna"
input:
tuple val(meta),
path(read1), path(read2)
path index
output:
tuple val(meta), path(run_dir)
script:
// label the run-dir
run_dir = "${meta.run_id}-rna"
// choose flag by technology
tech_flag = ['10Xv2': '--chromium',
'10Xv3': '--chromiumV3',
'10Xv3.1': '--chromiumV3']
// run alevin like normal with the --rad flag
// creates output directory with RAD file needed for alevin-fry
"""
mkdir -p ${run_dir}
salmon alevin \
-l ISR \
${tech_flag[meta.technology]} \
-1 ${read1} \
-2 ${read2} \
-i ${index} \
-o ${run_dir} \
-p ${task.cpus} \
--dumpFeatures \
--rad
"""
}
// quantify rna from RAD input
process fry_quant_rna{
container params.ALEVINFRY_CONTAINER
label 'cpus_8'
tag "${meta.run_id}-rna"
publishDir "${params.outdir}/${meta.sample_id}/${meta.library_id}"
input:
tuple val(meta), path(run_dir)
path barcode_file
path tx2gene_3col
output:
tuple val(meta), path(run_dir)
script:
"""
alevin-fry generate-permit-list \
-i ${run_dir} \
--expected-ori fw \
-o ${run_dir} \
--unfiltered-pl ${barcode_file}
alevin-fry collate \
--input-dir ${run_dir} \
--rad-dir ${run_dir} \
-t ${task.cpus}
alevin-fry quant \
--input-dir ${run_dir} \
--tg-map ${tx2gene_3col} \
--resolution ${params.resolution} \
-o ${run_dir} \
--use-mtx \
-t ${task.cpus} \
# remove large files
rm ${run_dir}/*.rad ${run_dir}/*.bin
"""
}
workflow map_quant_rna {
take: rna_channel
// a channel with a map of metadata for each rna library to process
main:
// create tuple of (metadata map, [Read1 files], [Read2 files])
// for rnaseq runs
rna_reads_ch = rna_channel
.map{meta -> tuple(meta,
file("s3://${meta.s3_prefix}/*_R1_*.fastq.gz"),
file("s3://${meta.s3_prefix}/*_R2_*.fastq.gz")
)}
cellbarcodes_ch = rna_channel
.map{file("${params.barcode_dir}/${params.cell_barcodes[it.technology]}")}
// run Alevin for mapping
alevin_rad(rna_reads_ch, params.index_path)
// quantify with alevin-fry
fry_quant_rna(alevin_rad.out, cellbarcodes_ch, params.t2g_3col_path)
emit: fry_quant_rna.out
// a tuple of meta and the alevin-fry output directory
}