-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsnanalysis.py
210 lines (167 loc) · 9.44 KB
/
snanalysis.py
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
## A snakefile for snakemake
## Started 28 January 2016
## Want to make sure all figures are based on most up-to-date datasets
workdir: '/proj/julianog/users/ChristianP/cambodiaWGS/'
#######################
####### TARGETS #######
#######################
rule all:
#input: 'Fws/fws.svg'
#input: 'adegenet/grey_pca.svg'
#input: 'dadi/data/pv_all/dadi_output_afs/pv_all.afs'
#input: 'dadi/data/pv_mono/dadi_output_afs/pv_mono.afs'
#input: 'dadi/data/pf_all/dadi_output_afs/pf_all.afs'
#input: 'dadi/data/pf_cp2/dadi_output_afs/pf_cp2.afs'
#input: 'dadi/data/pfall_pvall.svg'
#input: 'dadi/modelFitting/pv_mono/pv_mono.bg.fit'
#input: 'dadi/modelFitting/pv_all/pv_all.bg.fit'
#input: 'dadi/modelFitting/pf_cp2/pf_cp2.bg.fit'
#input: 'dadi/modelFitting/pf_all/pf_all.bg.fit'
#input: 'geneticMap/pf_cp2/logfile'
## SELSCAN IHS
#input: 'selscan/ihs/pv_mono.svg'
#input: 'selscan/ihs/pv_all.svg'
#input: 'selscan/ihs/pf_cp2.svg'
#input: 'selscan/ihs/pf_all.svg'
## SELSCAN nSL
#input: 'selscan/nsl/pv_all.svg'
#input: 'selscan/nsl/pf_all.svg'
#input: 'selscan/nsl/pv_mono.svg'
#input: 'selscan/nsl/pf_cp2.svg'
## SELSCAN EHH
#input: 'selscan/ehh/pv_chr14_797870'
input: 'selscan/ehh/pf_chr11_1294584'
#######################
##### SELSCAN EHH #####
#######################
rule pv_mono_chr14_797870:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/selscan/nsl/pv_mono/chr14.vcf', map = '/proj/julianog/users/ChristianP/cambodiaWGS/selscan/ihs/pv_mono/14.map'
output: 'selscan/ehh/pv_chr14_797870'
shell: 'bash selscan/ehh/ehhRunner.sh locus1511 {input.vcf} {input.map} {output}'
rule pf_cp2_chr11_1294584:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/selscan/nsl/pf_cp2/chr11.vcf', map = '/proj/julianog/users/ChristianP/cambodiaWGS/selscan/ihs/pf_cp2/11.map'
output: 'selscan/ehh/pf_chr11_1294584'
shell: 'bash selscan/ehh/ehhRunner.sh locus214 {input.vcf} {input.map} {output}'
#######################
##### SELSCAN iHS #####
#######################
## RUN ONE-AT-A-TIME ##
#######################
rule iHS_pf_all:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/pf/variants/our_goods_UG.pass.vcf'
output: 'selscan/ihs/pf_all.svg'
shell: 'bash selscan/ihs/iHScalc.sh {input.vcf} pf_all pf 0.35'
rule iHS_pf_cp2:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/pf/variants/cp2.pass.recode.vcf'
output: 'selscan/ihs/pf_cp2.svg'
shell: 'bash selscan/ihs/iHScalc.sh {input.vcf} pf_cp2 pf 0.20' # guessing, but don't know that we want to minimize this cutoff
rule iHS_pv_all:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/pv/variants/our_goods_UG.pass.vcf'
output: 'selscan/ihs/pv_all.svg'
shell: 'bash selscan/ihs/iHScalc.sh {input.vcf} pv_all pv 0.05'
rule iHS_pv_mono:
input: vcf = '/proj/julianog/users/ChristianP/cambodiaWGS/pv/variants/mono.pass.recode.vcf'
output: 'selscan/ihs/pv_mono.svg'
shell: 'bash selscan/ihs/iHScalc.sh {input.vcf} pv_mono pv 0.05'
#######################
###### AFS PLOTS ######
#######################
rule plot_afs:
input: pf_all = 'dadi/data/pf_all/dadi_output_afs/pf_all.afs', pf_cp2 = 'dadi/data/pf_cp2/dadi_output_afs/pf_cp2.afs', pv_all = 'dadi/data/pv_all/dadi_output_afs/pv_all.afs', pv_mono = 'dadi/data/pv_mono/dadi_output_afs/pv_mono.afs'
output: full_datasets = 'dadi/data/pfall_pvall.svg', subset_datasets = 'dadi/data/pfcp2_pvmono.svg'
shell: 'Rscript dadi/afsPlotter.r {input.pf_all} {input.pf_cp2} {input.pv_all} {input.pv_mono} {output.full_datasets} {output.subset_datasets}'
#######################
##### DADI PF ALL #####
#######################
rule dadi_fit_1pop_models_pf_all:
input: afs = 'dadi/data/pf_all/dadi_input/pf_all.syn.dadi'
output: 'dadi/modelFitting/pf_all/pf_all.bg.fit'
shell: 'bash dadi/modelFitting-1pop.sh {input.afs} dadi/modelFitting/pf_all/ pf_all pf'
rule dadi_calc_afs_pf_all:
input: annovcf = 'dadi/data/pf_all/vcfs/pf_all.anno.vcf', syn = 'dadi/data/pf_all/dadi_input/pf_all.syn.dadi', nonsyn = 'dadi/data/pf_all/dadi_input/pf_all.nonsyn.dadi', genic = 'dadi/data/pf_all/dadi_input/pf_all.genic.dadi', intergenic = 'dadi/data/pf_all/dadi_input/pf_all.intergenic.dadi'
output: 'dadi/data/pf_all/dadi_output_afs/pf_all.afs'
shell: 'bash dadi/afsPrinter.sh {input.annovcf} {input.syn} {input.nonsyn} {input.genic} {input.intergenic} {output}'
rule dadi_format_pf_all:
input: vcf = 'pf/variants/our_goods_UG.pass.vcf'
output: syn = 'dadi/data/pf_all/dadi_input/pf_all.syn.dadi', nonsyn = 'dadi/data/pf_all/dadi_input/pf_all.nonsyn.dadi', genic = 'dadi/data/pf_all/dadi_input/pf_all.genic.dadi', intergenic = 'dadi/data/pf_all/dadi_input/pf_all.intergenic.dadi'
shell: 'bash dadi/vcf2dadi.sh {input.vcf} pf_all pf'
#######################
##### DADI PF CP2 #####
#######################
rule dadi_fit_1pop_models_pf_cp2:
input: afs = 'dadi/data/pf_cp2/dadi_input/pf_cp2.syn.dadi'
output: 'dadi/modelFitting/pf_cp2/pf_cp2.bg.fit'
shell: 'bash dadi/modelFitting-1pop.sh {input.afs} dadi/modelFitting/pf_cp2/ pf_cp2 pf'
rule dadi_calc_afs_pf_cp2:
input: annovcf = 'dadi/data/pf_cp2/vcfs/pf_cp2.anno.vcf', syn = 'dadi/data/pf_cp2/dadi_input/pf_cp2.syn.dadi', nonsyn = 'dadi/data/pf_cp2/dadi_input/pf_cp2.nonsyn.dadi', genic = 'dadi/data/pf_cp2/dadi_input/pf_cp2.genic.dadi', intergenic = 'dadi/data/pf_cp2/dadi_input/pf_cp2.intergenic.dadi'
output: 'dadi/data/pf_cp2/dadi_output_afs/pf_cp2.afs'
shell: 'bash dadi/afsPrinter.sh {input.annovcf} {input.syn} {input.nonsyn} {input.genic} {input.intergenic} {output}'
rule dadi_format_pf_cp2:
input: vcf = 'pf/variants/cp2.pass.recode.vcf'
output: syn = 'dadi/data/pf_cp2/dadi_input/pf_cp2.syn.dadi', nonsyn = 'dadi/data/pf_cp2/dadi_input/pf_cp2.nonsyn.dadi', genic = 'dadi/data/pf_cp2/dadi_input/pf_cp2.genic.dadi', intergenic = 'dadi/data/pf_cp2/dadi_input/pf_cp2.intergenic.dadi'
shell: 'bash dadi/vcf2dadi.sh {input.vcf} pf_cp2 pf'
#######################
##### DADI PV ALL #####
#######################
rule dadi_fit_1pop_models_pv_all:
input: afs = 'dadi/data/pv_all/dadi_input/pv_all.syn.dadi'
output: 'dadi/modelFitting/pv_all/pv_all.bg.fit'
shell: 'bash dadi/modelFitting-1pop.sh {input.afs} dadi/modelFitting/pv_all/ pv_all pv'
rule dadi_calc_afs_pv_all:
input: annovcf = 'dadi/data/pv_all/vcfs/pv_all.anno.vcf', syn = 'dadi/data/pv_all/dadi_input/pv_all.syn.dadi', nonsyn = 'dadi/data/pv_all/dadi_input/pv_all.nonsyn.dadi', genic = 'dadi/data/pv_all/dadi_input/pv_all.genic.dadi', intergenic = 'dadi/data/pv_all/dadi_input/pv_all.intergenic.dadi'
output: 'dadi/data/pv_all/dadi_output_afs/pv_all.afs'
shell: 'bash dadi/afsPrinter.sh {input.annovcf} {input.syn} {input.nonsyn} {input.genic} {input.intergenic} {output}'
rule dadi_format_pv_all:
input: vcf = 'pv/variants/our_goods_UG.pass.vcf'
output: syn = 'dadi/data/pv_all/dadi_input/pv_all.syn.dadi', nonsyn = 'dadi/data/pv_all/dadi_input/pv_all.nonsyn.dadi', genic = 'dadi/data/pv_all/dadi_input/pv_all.genic.dadi', intergenic = 'dadi/data/pv_all/dadi_input/pv_all.intergenic.dadi'
shell: 'bash dadi/vcf2dadi.sh {input.vcf} pv_all pv'
#######################
##### DADI PV MONO ####
#######################
rule dadi_fit_1pop_models_pv_mono:
input: afs = 'dadi/data/pv_mono/dadi_input/pv_mono.syn.dadi'
output: 'dadi/modelFitting/pv_mono/pv_mono.bg.fit'
shell: 'bash dadi/modelFitting-1pop.sh {input.afs} dadi/modelFitting/pv_mono/ pv_mono pv'
rule dadi_calc_afs_pv_mono:
input: annovcf = 'dadi/data/pv_mono/vcfs/pv_mono.anno.vcf', syn = 'dadi/data/pv_mono/dadi_input/pv_mono.syn.dadi', nonsyn = 'dadi/data/pv_mono/dadi_input/pv_mono.nonsyn.dadi', genic = 'dadi/data/pv_mono/dadi_input/pv_mono.genic.dadi', intergenic = 'dadi/data/pv_mono/dadi_input/pv_mono.intergenic.dadi'
output: 'dadi/data/pv_mono/dadi_output_afs/pv_mono.afs'
shell: 'bash dadi/afsPrinter.sh {input.annovcf} {input.syn} {input.nonsyn} {input.genic} {input.intergenic} {output}'
rule dadi_format_pv_mono:
input: vcf = 'pv/variants/mono.pass.recode.vcf'
output: syn = 'dadi/data/pv_mono/dadi_input/pv_mono.syn.dadi', nonsyn = 'dadi/data/pv_mono/dadi_input/pv_mono.nonsyn.dadi', genic = 'dadi/data/pv_mono/dadi_input/pv_mono.genic.dadi', intergenic = 'dadi/data/pv_mono/dadi_input/pv_mono.intergenic.dadi'
shell: 'bash dadi/vcf2dadi.sh {input.vcf} pv_mono pv'
#######################
##### SELSCAN NSL #####
#######################
## RUN ONE-AT-A-TIME ##
#######################
rule nsl_pf_cp2:
input: vcf = 'pf/variants/cp2.pass.recode.vcf'
output: 'selscan/nsl/pf_cp2.svg'
shell: 'bash selscan/nsl/nslRunner.sh {input.vcf} pf_cp2 pf'
rule nsl_pf_all:
input: vcf = 'pf/variants/our_goods_UG.pass.vcf'
output: 'selscan/nsl/pf_all.svg'
shell: 'bash selscan/nsl/nslRunner.sh {input.vcf} pf_all pf'
rule nsl_pv_mono:
input: vcf = 'pv/variants/mono.pass.recode.vcf'
output: 'selscan/nsl/pv_mono.svg'
shell: 'bash selscan/nsl/nslRunner.sh {input.vcf} pv_mono pv'
rule nsl_pv_all:
input: vcf = 'pv/variants/our_goods_UG.pass.vcf'
output: 'selscan/nsl/pv_all.svg'
shell: 'bash selscan/nsl/nslRunner.sh {input.vcf} pv_all pv'
#######################
##### ADEGENET PCA ####
#######################
rule adegenet_pca:
input: pv = 'adegenet/our_goods_pv.pass.sansAAKM.vcf', pf = 'adegenet/our_goods_pf.pass.vcf'
output: grey = 'adegenet/grey_pca.svg', color = 'adegenet/color_pca.svg'
shell: 'Rscript adegenet/adegenet.r {input.pv} {input.pf} {output.grey} {output.color}'
#######################
####### FWS ###########
#######################
rule calc_fws_boot:
input: pv = 'pv/variants/our_goods_UG.pass.vcf', pf = 'pf/variants/our_goods_UG.pass.vcf'
output: 'Fws/plot.svg'
shell: 'Rscript Fws/fws.r {input.pv} {input.pf} {output}'