-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
94 lines (85 loc) · 2.47 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
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Nextflow - QC, Filtering and Association Analysis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { SUMMARISE } from './workflows/summarise'
include { FILTER } from './workflows/filter'
include { PLOT_STATS } from './workflows/plot_stats'
include { ASSOCIATION } from './workflows/association'
include { PLINK_CONVERT } from './modules/plink_convert'
include { FIX_PHENO } from './modules/fix_pheno'
include { PLINK_UPDATE_PHENO } from './modules/plink_update_pheno'
workflow {
// Validate mandatory parameters
params.each{ k, v -> if (v==null) { exit 1, "ERROR: parameter '$k' not set." } }
// Recode to PLINK binary format if required
if (!params.binary_format) {
plink = Channel
.fromPath( "${params.plink}.{ped,map}", checkIfExists: true)
.collect()
.map{ check_size(it, 2) }
.map{ [it[0].simpleName, it ] }
PLINK_CONVERT(plink)
plink = PLINK_CONVERT.out
} else {
plink = Channel
.fromPath( "${params.plink}.{bed,bim,fam}", checkIfExists: true)
.collect()
.map{ check_size(it, 3) }
.map{ [it[0].simpleName, it ] }
}
// Update phenotype if required
if (params.pheno_file) {
pheno = Channel
.fromPath(params.pheno_file, checkIfExists: true)
if (params.pheno_name == '' ) {
exit 1, "ERROR: No pheno name provided for: ${params.pheno_file}"
}
// Fix pheno format for compatibility
FIX_PHENO(pheno)
// Update phenotype
PLINK_UPDATE_PHENO(plink, FIX_PHENO.out, params.pheno_name)
plink = PLINK_UPDATE_PHENO.out
}
// Generate general summary of variants
SUMMARISE(plink)
// QC filtering steps
FILTER(
plink,
params.missing_geno,
params.missing_indi,
params.maf,
params.hwe_control,
params.hwe_case,
params.het_sd,
params.pihat
)
// Plot summary stats
PLOT_STATS(
SUMMARISE.out.imiss,
SUMMARISE.out.lmiss,
SUMMARISE.out.hwe,
SUMMARISE.out.maf,
FILTER.out.heterozygosity,
params.het_sd
)
// Read GFF3 file
gff3 = Channel
.fromPath(params.gff3, checkIfExists: true)
// Perform association alaysis summary stats
ASSOCIATION(
FILTER.out.plink,
gff3,
params.key,
params.covar_file,
params.covar_name
)
}
// Validate input file count
def check_size(List samples, n) {
if (samples.size() != n) {
exit 1, "ERROR: Expected ${n} PLINK files."
}
return samples
}