-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.nf
141 lines (118 loc) · 4.79 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
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
params.help = false
if (params.help) {
log.info"""
------------------------------------------------------
cellranger_count-nf: a workflow for CellRanger count
======================================================
Required arguments:
-------------------
--reference Path to reference files in 10X format.
Allowed: "mouse", "human", or FULL path.
--ncells The number of cells to expect. Int.
--fastq Directory that contains the fastqs. FULL path.
Optional arguments:
-------------------
--out Directory to publish results.
Default is directory where workflow is started.
--mode Run count for standard libraries, ATAC or VDJ. Default is standard.
Allowed: atac, vjd
--chemistry 10X library chemistry version. Str. Default is auto.
Allowed: threeprime, fiveprime, SC3Pv2, SC3Pv3, SC5P-PE, SC5P-R2, SC3Pv1
------------------------------------------------------
""".stripIndent()
exit 0
}
// set default run mode
params.mode = 'standard'
// Required arguments
params.ncells = false
if ( !params.ncells && params.mode == 'standard' ) { exit 1, "--ncells is not defined" }
params.reference = false
if ( !params.reference ) { exit 1, "--reference is not defined" }
// convert reference keywords to paths in group space
if ( params.reference == "mouse" ) {
if ( params.mode == "standard" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Mouse/GRCm38/10x_star/refdata-gex-mm10-2020-A"
} else if ( params.mode == "atac" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Mouse/GRCm38/10x_star/refdata-cellranger-atac-mm10-1.2.0"
} else if ( params.mode == "vdj" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Mouse/GRCm38/10x_star/refdata-cellranger-vdj-GRCm38-alts-ensembl-5.0.0"
} else {
exit 1, "keywords for mode and species do not match"
}
} else if ( params.reference == "human" ) {
if ( params.mode == "standard" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Human/GRCh38/10x_star/refdata-gex-GRCh38-2020-A"
} else if ( params.mode == "atac" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Human/GRCh38/10x_atac/refdata-cellranger-arc-GRCh38-2020-A-2.0.0"
} else if ( params.mode == "vdj" ) {
reference = "/uufs/chpc.utah.edu/common/PE/hci-bioinformatics1/atlatl/data/Human/GRCh38/10x_star/refdata-cellranger-vdj-GRCh38-alts-ensembl-5.0.0"
} else {
exit 1, "keywords for mode and species do not match"
}
} else {
reference = "${params.reference}"
}
// Optional arguments
params.out = "./"
params.chemistry = 'auto'
// Logging
log.info("\n")
log.info("Input directory (--fastq) :${params.fastq}")
log.info("Reference (--reference) :$reference")
log.info("Expect cells (--ncells) :${params.ncells}")
log.info("Chemistry (--chemistry) :${params.chemistry}")
log.info("Run mode (--mode) :${params.mode}")
log.info("Output dir (--out) :${params.out}")
// Input channel: each directory is output of cellranger mkfastq
Channel
.fromPath("${params.fastq}/*", type: 'dir')
.map { tuple(it.getName(), it) }
.set { fastqs }
// Run CellRanger Count
process cellranger_count {
module 'singularity/3.6.4'
publishDir path: "${params.out}/$id", mode: "copy", saveAs: { "${file(it).getName()}"}
input:
path(reference)
tuple val(id), path('fastq')
output:
path("$id/outs/*")
path("$id/_cmdline")
path("$id/_versions")
path("$id/_log")
script:
if( params.mode == 'standard' ) {
"""
cellranger count --id=$id \
--fastqs=$fastq \
--transcriptome=${reference} \
--expect-cells=${params.ncells} \
--chemistry=${params.chemistry} \
--localcores=28 \
--localmem=95
"""
} else if( params.mode == 'atac' ) {
"""
cellranger-atac count --id=$id \
--fastqs=$fastq \
--reference=$reference \
--localcores=28 \
--localmem=95
} else if( params.mode == 'vdj' ) {
"""
cellranger vdj --id=$id \
--fastqs=$fastq\
--reference=${reference} \
--localcores=28 \
--localmem=95
"""
} else {
exit 1, "run mode not assigned correctly. Try --atac, --vdj, or omit"
}
}
workflow {
cellranger_count(reference, fastqs)
}