-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnakefile_no_report
executable file
·173 lines (149 loc) · 7.21 KB
/
Snakefile_no_report
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/usr/bin/python
#import glob
import sys
import os
from glob import glob
from glob import iglob
configfile: "modules/config.yaml"
outName = os.path.basename(os.path.dirname(config['project']))
ensemble_vcf = config['ensemble_vcf']
bam_location = config['bam_location']
ensemble_dir = config['ensemble_dir']
project = config['project']
manifest = config['manifest']
refFile = config['ref']
populationFile = config['population_file']
bedFile = config['capturekit']
precallingReport = config['precalling_report']
#exomeCQAgeneReport = config['exomCQA_gene']
#exomeCQAexonReport = config['exomCQA_exon']
sex_check_dir = 'sex_check'
postcalling_qc_dir = 'postcalling_qc'
coverage_dir = 'coverage'
contamination_dir = 'bamContamination'
ancestry_check_dir = 'laser'
exomeCQA_dir = 'exomeCQA'
hgdpDir = 'modules/HGDP'
deduplication_dir = 'deduplication'
precalling_dir = 'precalling_qc'
relatedness_dir = 'relatedness'
fastqc_dir = 'fastqc'
GROUPS=[]
SAMPLES = []
sampleGroupDict = {}
CONTROLS = ['PLCO', 'ACS', 'LC_IGC', 'EAGLE_IGC', 'CTRL', '_Normal']
include: "modules/Snakemake_utils"
########################
#Germline call
with open(manifest) as f:
next(f)
for line in f:
(group, analysisid) = [line.split(',')[i] for i in [6,12]] #with list index [6,11,12], it will throw error "list indices must be integers or slices, not tuple". Need to explicitly specify by the loop, because you cannot index list
sample = group + "_" + analysisid
if (sample not in SAMPLES):
SAMPLES.append(sample)
sampleGroupDict[sample] = group
if group not in GROUPS:
GROUPS.append(group)
def getBam(wildcards):
(group) = sampleGroupDict[wildcards.sample]
return (glob(bam_location + '/' + group + '/' + wildcards.sample + '.bam')) #Why have to use glob instead of using the string
#print(GROUPS)
def getReport(wildcards):
return glob(project + '/*coverage_report*.txt')
#for bam_subdir in glob(bam_location + '/*/'):
# GROUPS.append(os.path.basename(bam_subdir.strip('/')))
########################
#Somatic pair call
if config['MODE'] == 'somatic':
pair_manifest = config['pairs']
bamMatcher_dir = 'bamMatcher'
bamMatcherExe = config['BamMatcher']
PAIRS = []
tumorDict = {}
normalDict = {}
with open(pair_manifest) as f:
for line in f:
(tumor, normal, vcf) = line.split()
sample = os.path.basename(vcf)[:-4]
PAIRS.append(os.path.basename(vcf)[:-4])
tumorName = os.path.basename(tumor)[:-4]
normalName = os.path.basename(normal)[:-4]
tumorDict[sample] = (tumor)
normalDict[sample] = (normal)
def get_tumor(wildcards):
(file) = tumorDict[wildcards.sample]
return file
def get_normal(wildcards):
(file) = normalDict[wildcards.sample]
return file
if config['ancestry_check']:
include: 'modules/Snakefile_ancestry_plot'
if config['bam-matcher_check']:
include: 'modules/Snakefile_bam_matcher'
if config['contamination_check']:
include: 'modules/Snakefile_contamination_plot'
if config['coverage_check']:
include: 'modules/Snakefile_coverage_plot'
if config['duplication_check']:
include: 'modules/Snakefile_duplication_plot'
if config['exomeCQA_check']:
include: 'modules/Snakefile_exomeCQA_plot'
if config['fastqc_check']:
include: 'modules/Snakefile_fastqc'
if config['sex_check']:
include: 'modules/Snakefile_sex_plot'
if config['pre_calling_check']:
include: 'modules/Snakefile_pre_calling_plot'
if config['post_calling_check']:
include: 'modules/Snakefile_postcalling_plot_somatic'
else:
if config['ancestry_check']:
include: 'modules/Snakefile_ancestry_plot'
if config['contamination_check']:
include: 'modules/Snakefile_contamination_plot'
if config['coverage_check']:
include: 'modules/Snakefile_coverage_plot'
if config['duplication_check']:
include: 'modules/Snakefile_duplication_plot'
if (config['MODE'] == 'wes' and config['exomeCQA_check']):
include: 'modules/Snakefile_exomeCQA_plot'
if config['fastqc_check']:
include: 'modules/Snakefile_fastqc'
if config['sex_check']:
include: 'modules/Snakefile_sex_plot'
if config['pre_calling_check']:
include: 'modules/Snakefile_pre_calling_plot'
if config['post_calling_check']:
include: 'modules/Snakefile_postcalling_plot'
if config['relatedness_check']:
include: 'modules/Snakefile_relatedness'
# include: 'modules/Snakefile_ancestry_plot'
# #include: 'modules/Snakefile_ancestry_plot_by_group'
# include: 'modules/Snakefile_contamination_plot'
# include: 'modules/Snakefile_coverage_plot'
# include: 'modules/Snakefile_duplication_plot'
# include: 'modules/Snakefile_exomeCQA_plot'
# include: 'modules/Snakefile_sex_plot'
# include: 'modules/Snakefile_pre_calling_plot'
rule all:
input:
ancestry_check_dir + '/procrustesPCASamples.png' if config['ancestry_check'] else [],
bamMatcher_dir + '/bam_matcher_check.png' if ( config['MODE'] == 'somatic' and config['bam-matcher_check'] ) else [],
contamination_dir + '/bam_contamination_rate.png' if config['contamination_check'] else [],
coverage_dir + '/Average_Coverage_caco.png' if config['coverage_check'] else [],
deduplication_dir + '/subject_dup_rate.png' if config['duplication_check'] else [],
exomeCQA_dir + '/cohort_coverage_sparseness.png' if ( not config['MODE'] == 'wgs' and config['exomeCQA_check']) else [],
exomeCQA_dir + '/unevenness.png' if ( not config['MODE'] == 'wgs' and config['exomeCQA_check']) else [],
sex_check_dir + '/sex_check.png' if config['sex_check'] else [],
precalling_dir + '/fold80.png' if (config['pre_calling_check'] and not config['MODE'] == 'wgs') else [],
precalling_dir + '/insertSize.png' if config['pre_calling_check'] else [],
precalling_dir + '/seq_artifact.png' if config['pre_calling_check'] else [],
precalling_dir + '/oxidation.png' if config['pre_calling_check'] else [],
postcalling_qc_dir + '/basechange_all.png' if ( config['post_calling_check'] and not config['MODE'] == 'somatic' ) else [],
postcalling_qc_dir + '/variant_count.png' if ( config['post_calling_check'] and not config['MODE'] == 'somatic' ) else [],
postcalling_qc_dir + '/titv_ratio.png' if ( config['post_calling_check'] and not config['MODE'] == 'somatic' ) else [],
postcalling_qc_dir + '/basechange_3d.png' if ( config['post_calling_check'] and config['MODE'] == 'somatic' ) else [],
postcalling_qc_dir + '/basechange_distribution.png' if ( config['post_calling_check'] and config['MODE'] == 'somatic' ) else [],
'relatedness/relatedness.png' if ( config['relatedness_check'] and not config['MODE'] == 'somatic' ) else [],
'fastqc/multiqc_report.html' if config['fastqc_check'] else []