-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.nf
127 lines (110 loc) · 6.48 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
#!/usr/bin/env nextflow
/*
========================================================================================
scatacpipe
========================================================================================
Github : https://github.com/hukai916/scatacpipe
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
/*
========================================================================================
VALIDATE & PRINT PARAMETER SUMMARY
========================================================================================
*/
WorkflowMain.initialise(workflow, params, log)
// Check input path parameters to see if they exist:
def checkPathParamList = [ params.input_fragment, params.input_fastq, params.ref_bwa_index, params.ref_cellranger_index, params.ref_gtf, params.ref_fasta, params.whitelist_barcode, params.archr_genome_fasta, params.archr_blacklist, params.archr_scrnaseq, params.amulet_rmsk_bed, params.amulet_autosomes ]
for (param in checkPathParamList) { if (param) { file(param, checkIfExists: true) } }
////////////////////////////////////////////////////
/* -- RUN WORKFLOW(S) -- */
////////////////////////////////////////////////////
def modules = params.modules.clone()
log.info "Loading modules ..."
include { PREPROCESS_DEFAULT } from './workflows/preprocess_default'
include { PREPROCESS_10XGENOMICS } from './workflows/preprocess_10xgenomics'
include { PREPROCESS_CHROMAP } from './workflows/preprocess_chromap'
include { DOWNSTREAM_ARCHR } from './workflows/downstream_archr'
include { SPLIT_BED } from './modules/local/split_bed' addParams( options: modules['split_bed'] )
include { SPLIT_BAM } from './modules/local/split_bam' addParams( options: modules['split_bam'] )
include { MULTIQC } from './modules/local/multiqc' addParams( options: modules['multiqc'] )
include { INPUT_CHECK_FRAGMENT } from './subworkflows/local/input_check_fragment'
include { INPUT_CHECK_FASTQ } from './subworkflows/local/input_check_fastq'
log.info "Loading modules, done."
ch_multiqc_config = file("$projectDir/assets/multiqc_config.yaml", checkIfExists: true)
workflow SCATACPIPE {
take:
input_fragment
input_fastq
main:
if (input_fragment) {
log.info "DOWNSTREAM starts ... if exits, check .nextflow.log file."
INPUT_CHECK_FRAGMENT (Channel.fromPath(input_fragment))
DOWNSTREAM_ARCHR (INPUT_CHECK_FRAGMENT.out.fragment, "preprocess_null", "token1", "token2", "token3", "token4", "token5", "token6")
SPLIT_BED (DOWNSTREAM_ARCHR.out[1])
MULTIQC (DOWNSTREAM_ARCHR.out[0].ifEmpty([]).mix(Channel.from(ch_multiqc_config)).collect())
} else if (input_fastq) {
log.info "PREPROCESS + DOWNSTREAM start ... if exits, check .nextflow.log file."
INPUT_CHECK_FASTQ (Channel.fromPath(input_fastq))
if (params.preprocess == "default") {
// Determine if PREP_GENOME and PREP_GTF run or not_run:
//// PREP_GTF is always not_run
//// If index folder supplied: PREP_GENOME must not run
prep_genome_run = "run"
prep_gtf_run = "not_run"
if ((params.mapper == "bwa") && params.ref_bwa_index) {
prep_genome_run = "not_run"
}
// PREPROCESS_DEFAULT (ch_samplesheet)
PREPROCESS_DEFAULT (INPUT_CHECK_FASTQ.out.reads, INPUT_CHECK_FASTQ.out.sample_count)
DOWNSTREAM_ARCHR (PREPROCESS_DEFAULT.out[2], "preprocess_default", prep_genome_run, PREPROCESS_DEFAULT.out[5], PREPROCESS_DEFAULT.out[6], prep_gtf_run, PREPROCESS_DEFAULT.out[7], PREPROCESS_DEFAULT.out[8])
SPLIT_BED (DOWNSTREAM_ARCHR.out[1]) // take a tuple (sample_name, fragment_path, tsv_path) as input
SPLIT_BAM (PREPROCESS_DEFAULT.out[3], DOWNSTREAM_ARCHR.out[2].collect(), PREPROCESS_DEFAULT.out[4].collect())
MULTIQC(PREPROCESS_DEFAULT.out[0].mix(DOWNSTREAM_ARCHR.out[0].ifEmpty([])).mix(Channel.from(ch_multiqc_config)).collect())
} else if (params.preprocess == "10xgenomics") {
// Determine if PREP_GENOME and PREP_GTF run or not_run:
//// If index folder supplied: both PREP_GENOME and PREP_GTF must not_run
prep_genome_run = "run"
prep_gtf_run = "run"
if (params.ref_cellranger_index) {
prep_genome_run = "not_run"
prep_gtf_run = "not_run"
}
PREPROCESS_10XGENOMICS (INPUT_CHECK_FASTQ.out.reads, INPUT_CHECK_FASTQ.out.sample_count)
DOWNSTREAM_ARCHR (PREPROCESS_10XGENOMICS.out[2], "preprocess_10xgenomics", prep_genome_run, PREPROCESS_10XGENOMICS.out[5], PREPROCESS_10XGENOMICS.out[6], prep_gtf_run, PREPROCESS_10XGENOMICS.out[7], PREPROCESS_10XGENOMICS.out[8])
SPLIT_BED (DOWNSTREAM_ARCHR.out[1])
SPLIT_BAM (PREPROCESS_10XGENOMICS.out[3], DOWNSTREAM_ARCHR.out[2].collect(), PREPROCESS_10XGENOMICS.out[4].collect())
MULTIQC (DOWNSTREAM_ARCHR.out[0].ifEmpty([]).mix(Channel.from(ch_multiqc_config)).collect())
} else if (params.preprocess == "chromap") {
// Determine if PREP_GENOME and PREP_GTF run or not_run:
prep_genome_run = "run"
prep_gtf_run = "run"
PREPROCESS_CHROMAP (INPUT_CHECK_FASTQ.out.reads, INPUT_CHECK_FASTQ.out.sample_count)
DOWNSTREAM_ARCHR (PREPROCESS_CHROMAP.out[2], "preprocess_chromap", prep_genome_run, PREPROCESS_CHROMAP.out[5], PREPROCESS_CHROMAP.out[6], prep_gtf_run, PREPROCESS_CHROMAP.out[7], PREPROCESS_CHROMAP.out[8])
SPLIT_BED (DOWNSTREAM_ARCHR.out[1])
// SPLIT_BAM (PREPROCESS_10XGENOMICS.out[3], DOWNSTREAM_ARCHR.out[2].collect(), PREPROCESS_10XGENOMICS.out[4].collect(), "NA")
MULTIQC (PREPROCESS_CHROMAP.out[0].mix(DOWNSTREAM_ARCHR.out[0].ifEmpty([])).mix(Channel.from(ch_multiqc_config)).collect())
} else {
exit 1, "must supply valid --preprocess option"
}
} else {
exit 1, "Pls supply either --input_fragment or --input_fastq"
}
}
workflow {
SCATACPIPE (params.input_fragment, params.input_fastq)
}
/*
========================================================================================
COMPLETION EMAIL AND SUMMARY
========================================================================================
*/
workflow.onComplete {
if (params.email || params.email_on_fail) {
NfcoreTemplate.email(workflow, params, summary_params, projectDir, log, multiqc_report)
}
NfcoreTemplate.summary(workflow, params, log)
}
////////////////////////////////////////////////////
/* -- THE END -- */
////////////////////////////////////////////////////