-
Notifications
You must be signed in to change notification settings - Fork 0
/
getHaplotypeFrequencyFiles.nf
57 lines (43 loc) · 1.67 KB
/
getHaplotypeFrequencyFiles.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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include {
getInputVcf;
getAffectedSamples;
getUnaffectedSamples;
getVariantIdAndPositions;
getVariantIdFile;
getTagVariants;
getListOfPositionsFromTagVariants;
getHaplotypes;
getTransposedHaplotypes;
getHaplotypeFrequencies;
reformatHaplotypeFreqFiles;
} from "${projectDir}/modules/mutationAgeEstimate.nf"
workflow {
println "\nworkflow started. Getting haplotype frequencies...\n"
vcfFile = getInputVcf()
variantIdFile = getVariantIdFile( params.variantId )
rsidChrPosFile = getVariantIdAndPositions( vcfFile )
tagVariantsFile = getTagVariants( vcfFile, variantIdFile, rsidChrPosFile )
rsidChrPosFile
.combine( tagVariantsFile )
.set { positions_input }
tagVariantPositionsFile = getListOfPositionsFromTagVariants( positions_input )
// combine these channels because order matters
tagVariantPositionsFile
.combine( vcfFile )
.set { tagVariantsAndVcfFile }
affectedSampleIds = getAffectedSamples()
unaffectedSampleIds = getUnaffectedSamples()
// mix sample channels because order does not. But the mixed channel combine with
// tag_vcf channel since order matters when tag_vcf channels are involved
affectedSampleIds
.mix(unaffectedSampleIds)
.combine ( tagVariantsAndVcfFile )
.set { sampleTagVariantsAndVcfFile }
haplotypes = getHaplotypes( sampleTagVariantsAndVcfFile )
transposedHaplotypes = getTransposedHaplotypes( haplotypes ).flatten()
haplotypeFrequencies = getHaplotypeFrequencies( transposedHaplotypes )
reformattedHapFreqFiles = reformatHaplotypeFreqFiles( haplotypeFrequencies )
}
workflow.onComplete { println "\nHaplotype frequencies written to '${params.outputDir}' successfully!\n" }