-
Notifications
You must be signed in to change notification settings - Fork 0
/
allele_plot_allelefreq.pop.R
executable file
·277 lines (241 loc) · 12.5 KB
/
allele_plot_allelefreq.pop.R
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
setwd("C:/Users/JM/thesis/mark_work/allele_specificity/allelefreq")
## data 382
ase.cou = read.table('counts.nonintHets.minN.merged.521777snps.382samples.agg.ase.maf.auto.bed',stringsAsFactors = F)
ase.int = read.table('interestingHets.min6.merged.144083snps.382samples.maf.auto.bed',stringsAsFactors = F)
asb.cou = read.table('counts.nonint.peaks.minN.merged.239500snps.agg.382samples.asb.auto.maf.bed',stringsAsFactors = F)
asb.int = read.table('interestingHets.peaks.min6.merged.169235snps.agg.asb.382samples.auto.maf.bed',stringsAsFactors = F)
asb.maf.pop.CEU.int = read.table('asb.maf.pop.CEU.bed.382',stringsAsFactors=F)
asb.maf.pop.CHB.int = read.table('asb.maf.pop.CHB.bed.382',stringsAsFactors=F)
asb.maf.pop.JPT.int = read.table('asb.maf.pop.JPT.bed.382',stringsAsFactors=F)
asb.maf.pop.YRI.int = read.table('asb.maf.pop.YRI.bed.382',stringsAsFactors=F)
ase.maf.pop.CEU.int = read.table('ase.maf.pop.CEU.bed.382',stringsAsFactors=F)
ase.maf.pop.CHB.int = read.table('ase.maf.pop.CHB.bed.382',stringsAsFactors=F)
ase.maf.pop.FIN.int = read.table('ase.maf.pop.FIN.bed.382',stringsAsFactors=F)
ase.maf.pop.GBR.int = read.table('ase.maf.pop.GBR.bed.382',stringsAsFactors=F)
ase.maf.pop.JPT.int = read.table('ase.maf.pop.JPT.bed.382',stringsAsFactors=F)
ase.maf.pop.TSI.int = read.table('ase.maf.pop.TSI.bed.382',stringsAsFactors=F)
ase.maf.pop.YRI.int = read.table('ase.maf.pop.YRI.bed.382',stringsAsFactors=F)
asb.maf.cou.pop.CEU.int = read.table('asb.maf.cou.pop.CEU.bed',stringsAsFactors=F)
asb.maf.cou.pop.CHB.int = read.table('asb.maf.cou.pop.CHB.bed',stringsAsFactors=F)
asb.maf.cou.pop.JPT.int = read.table('asb.maf.cou.pop.JPT.bed',stringsAsFactors=F)
asb.maf.cou.pop.YRI.int = read.table('asb.maf.cou.pop.YRI.bed',stringsAsFactors=F)
ase.maf.cou.pop.CEU.int = read.table('ase.maf.cou.pop.CEU.bed',stringsAsFactors=F)
ase.maf.cou.pop.CHB.int = read.table('ase.maf.cou.pop.CHB.bed',stringsAsFactors=F)
ase.maf.cou.pop.FIN.int = read.table('ase.maf.cou.pop.FIN.bed',stringsAsFactors=F)
ase.maf.cou.pop.GBR.int = read.table('ase.maf.cou.pop.GBR.bed',stringsAsFactors=F)
ase.maf.cou.pop.JPT.int = read.table('ase.maf.cou.pop.JPT.bed',stringsAsFactors=F)
ase.maf.cou.pop.TSI.int = read.table('ase.maf.cou.pop.TSI.bed',stringsAsFactors=F)
ase.maf.cou.pop.YRI.int = read.table('ase.maf.cou.pop.YRI.bed',stringsAsFactors=F)
## hist
numbins=100
ase.hist.cou <- hist(ase.cou$V5, numbins, prob=FALSE)
ase.hist.int <- hist(ase.int$V5, numbins, prob=FALSE)
asb.hist.cou <- hist(asb.cou$V5, numbins, prob=FALSE)
asb.hist.int <- hist(asb.int$V5, numbins, prob=FALSE)
hist.asb.maf.pop.CEU.int <- hist(asb.maf.pop.CEU.int$V5, numbins, prob=FALSE)
hist.asb.maf.pop.CHB.int <- hist(asb.maf.pop.CHB.int$V5, numbins, prob=FALSE)
hist.asb.maf.pop.JPT.int <- hist(asb.maf.pop.JPT.int$V5, numbins, prob=FALSE)
hist.asb.maf.pop.YRI.int <- hist(asb.maf.pop.YRI.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.CEU.int <- hist(ase.maf.pop.CEU.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.CHB.int <- hist(ase.maf.pop.CHB.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.FIN.int <- hist(ase.maf.pop.FIN.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.GBR.int <- hist(ase.maf.pop.GBR.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.JPT.int <- hist(ase.maf.pop.JPT.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.TSI.int <- hist(ase.maf.pop.TSI.int$V5, numbins, prob=FALSE)
hist.ase.maf.pop.YRI.int <- hist(ase.maf.pop.YRI.int$V5, numbins, prob=FALSE)
hist.asb.maf.cou.pop.CEU.int <- hist(asb.maf.cou.pop.CEU.int$V5, numbins, prob=FALSE)
hist.asb.maf.cou.pop.CHB.int <- hist(asb.maf.cou.pop.CHB.int$V5, numbins, prob=FALSE)
hist.asb.maf.cou.pop.JPT.int <- hist(asb.maf.cou.pop.JPT.int$V5, numbins, prob=FALSE)
hist.asb.maf.cou.pop.YRI.int <- hist(asb.maf.cou.pop.YRI.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.CEU.int <- hist(ase.maf.cou.pop.CEU.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.CHB.int <- hist(ase.maf.cou.pop.CHB.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.FIN.int <- hist(ase.maf.cou.pop.FIN.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.GBR.int <- hist(ase.maf.cou.pop.GBR.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.JPT.int <- hist(ase.maf.cou.pop.JPT.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.TSI.int <- hist(ase.maf.cou.pop.TSI.int$V5, numbins, prob=FALSE)
hist.ase.maf.cou.pop.YRI.int <- hist(ase.maf.cou.pop.YRI.int$V5, numbins, prob=FALSE)
## plot col5 AF spectra ASE
xbtmlm=0
xlimit=0.5
ylimit=0.25
x11()
par(mar=c(5,8,4,4),xpd=TRUE)
# par(cex.axis=2, cex.lab=1, cex.main=1.2, cex.sub=1)
par(cex.axis=1.5, cex.lab=1.5)
plot(ase.hist.cou$breaks[2:(numbins+1)], ase.hist.cou$counts/sum(ase.hist.cou$counts),
col="blue",
type="b", lty=2, xlab='minor allele frequency', ylab='fraction of SNVs',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit),
cex.lab=2, cex.axis=2)
par(new=TRUE)
plot(ase.hist.int$breaks[2:(numbins+1)], ase.hist.int$counts/sum(ase.hist.int$counts),
col="blue",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
# plot(ase.hist.cou$breaks[2:(numbins+1)], ase.hist.cou$density, col="blue",
# type="b", lty=2, xlab='allele frequency', ylab='percentage',
# xlim=c(0,xlimit))
# par(new=TRUE)
# plot(ase.hist.int$breaks[2:(numbins+1)], ase.hist.int$density, col="blue",
# type="b", pch=16, axes=FALSE, xlab='',ylab='',
# xlim=c(0,xlimit))
## ASB
par(new=TRUE)
plot(asb.hist.cou$breaks[2:(numbins+1)], asb.hist.cou$counts/sum(asb.hist.cou$counts),
col="limegreen",
type="b", lty=2, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(asb.hist.int$breaks[2:(numbins+1)], asb.hist.int$counts/sum(asb.hist.int$counts),
col="limegreen",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
# par(new=TRUE)
# plot(asb.hist.cou$breaks[2:(numbins+1)], asb.hist.cou$density, col="red",
# type="b", lty=2, axes=FALSE, xlab='',ylab='',
# xlim=c(0,xlimit))
# par(new=TRUE)
# plot(asb.hist.int$breaks[2:(numbins+1)], asb.hist.int$density, col="red",
# type="b", pch=16, axes=FALSE, xlab='',ylab='',
# xlim=c(0,xlimit))
# par(cex.axis=2, cex.lab=1, cex.main=1.2, cex.sub=1)
## pops
par(new=TRUE)
plot(hist.asb.maf.pop.CEU.int$breaks[2:(numbins+1)],
hist.asb.maf.pop.CEU.int$counts/sum(hist.asb.maf.pop.CEU.int$counts),
col="red",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.cou.pop.CEU.int$breaks[2:(numbins+1)],
hist.asb.maf.cou.pop.CEU.int$counts/sum(hist.ase.maf.cou.pop.CEU.int$counts),
col="red",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.pop.CHB.int$breaks[2:(numbins+1)],
hist.asb.maf.pop.CHB.int$counts/sum(hist.asb.maf.pop.CHB.int$counts),
col="magenta",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.cou.pop.CHB.int$breaks[2:(numbins+1)],
hist.asb.maf.cou.pop.CHB.int$counts/sum(hist.ase.maf.cou.pop.CHB.int$counts),
col="magenta",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.pop.JPT.int$breaks[2:(numbins+1)],
hist.asb.maf.pop.JPT.int$counts/sum(hist.asb.maf.pop.JPT.int$counts),
col="magenta4",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.cou.pop.JPT.int$breaks[2:(numbins+1)],
hist.asb.maf.cou.pop.JPT.int$counts/sum(hist.ase.maf.cou.pop.JPT.int$counts),
col="magenta4",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.pop.YRI.int$breaks[2:(numbins+1)],
hist.asb.maf.pop.YRI.int$counts/sum(hist.asb.maf.pop.YRI.int$counts),
col="black",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.asb.maf.cou.pop.YRI.int$breaks[2:(numbins+1)],
hist.asb.maf.cou.pop.YRI.int$counts/sum(hist.ase.maf.cou.pop.YRI.int$counts),
col="black",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.CEU.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.CEU.int$counts/sum(hist.ase.maf.pop.CEU.int$counts),
col="orange",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.CEU.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.CEU.int$counts/sum(hist.ase.maf.cou.pop.CEU.int$counts),
col="orange",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.CHB.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.CHB.int$counts/sum(hist.ase.maf.pop.CHB.int$counts),
col="orange3",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.CHB.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.CHB.int$counts/sum(hist.ase.maf.cou.pop.CHB.int$counts),
col="orange3",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.JPT.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.JPT.int$counts/sum(hist.ase.maf.pop.JPT.int$counts),
col="orange4",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.JPT.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.JPT.int$counts/sum(hist.ase.maf.cou.pop.JPT.int$counts),
col="orange4",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.FIN.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.FIN.int$counts/sum(hist.ase.maf.pop.FIN.int$counts),
col="lightsalmon",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.FIN.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.FIN.int$counts/sum(hist.ase.maf.cou.pop.FIN.int$counts),
col="lightsalmon",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.GBR.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.GBR.int$counts/sum(hist.ase.maf.pop.GBR.int$counts),
col="lightsalmon3",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.GBR.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.GBR.int$counts/sum(hist.ase.maf.cou.pop.GBR.int$counts),
col="lightsalmon3",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.TSI.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.TSI.int$counts/sum(hist.ase.maf.pop.TSI.int$counts),
col="lightsalmon4",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.TSI.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.TSI.int$counts/sum(hist.ase.maf.cou.pop.TSI.int$counts),
col="lightsalmon4",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.pop.YRI.int$breaks[2:(numbins+1)],
hist.ase.maf.pop.YRI.int$counts/sum(hist.ase.maf.pop.YRI.int$counts),
col="navajowhite4",
type="b", pch=16, axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
par(new=TRUE)
plot(hist.ase.maf.cou.pop.YRI.int$breaks[2:(numbins+1)],
hist.ase.maf.cou.pop.YRI.int$counts/sum(hist.ase.maf.cou.pop.YRI.int$counts),
col="navajowhite4",
type="b", axes=FALSE, xlab='',ylab='',
xlim=c(xbtmlm,xlimit),ylim=c(0,ylimit))
## legend
legend(0.015,0.2,
c('ASE-','ASE+','ASB-','ASB+','ASB+_CEU','ASB+_CHB','ASB+_JPT','ASB+_YRI',
'ASE+_CEU','ASE+_CHB','ASE+_JPT','ASE+_FIN','ASE+_GBR','ASE+_TSI','ASE+_YRI'),
col=c('blue','blue','limegreen','limegreen','red','magenta','magenta4','black',
'orange','orange3','orange4','lightsalmon','lightsalmon3','lightsalmon4','navajowhite4'),
text.col = "black", pch = c(21,16,21,16,21,21,21,21,21,21), bg = 'white',cex=2)