/
intra_region_snp.py
56 lines (35 loc) · 1.77 KB
/
intra_region_snp.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
import matplotlib
matplotlib.rcParams.update({'font.size': 8})
from matplotlib import pyplot as plt
import numpy as np
from matplotlib_venn import venn2, venn3
from sample_code_file_maps import snps, indels, ethnicity_code
from sample_code_file_maps import north, centre, peninsula, admixed
from sample_code_file_maps import mayas, nahuas, tarahumaras, tepehuanos, totonacas, zapotecas
# load indels into a dictionary of sets
tarahumaras_sets = {}
for s in tarahumaras:
tarahumaras_sets[s] = set([v.strip() for v in open( "%s_snp.map" % ethnicity_code[s]).readlines()])
tepehuanos_sets = {}
for s in tepehuanos:
tepehuanos_sets[s] = set([v.strip() for v in open( "%s_snp.map" % ethnicity_code[s]).readlines()])
nahuas_sets = {}
for s in nahuas:
nahuas_sets[s] = set([v.strip() for v in open( "%s_snp.map" % ethnicity_code[s]).readlines()])
totonacas_sets = {}
for s in totonacas:
totonacas_sets[s] = set([v.strip() for v in open( "%s_snp.map" % ethnicity_code[s]).readlines()])
zapotecas_sets = {}
for s in zapotecas:
zapotecas_sets[s] = set([v.strip() for v in open( "%s_snp.map" % ethnicity_code[s]).readlines()])
tarahumaras_u = set.union(*[tarahumaras_sets[n] for n in tarahumaras])
tepehuanos_u = set.union(*[tepehuanos_sets[n] for n in tepehuanos])
nahuas_u = set.union(*[nahuas_sets[n] for n in nahuas])
totonacas_u = set.union(*[totonacas_sets[n] for n in totonacas])
zapotecas_u = set.union(*[zapotecas_sets[n] for n in zapotecas])
figure, axes = plt.subplots(1,2)
venn2([tarahumaras_u, tepehuanos_u], set_labels=('Tarahumara', 'Tepehuano'),ax=axes[0])
venn3([nahuas_u, totonacas_u, zapotecas_u], set_labels=('Nahua', 'Totonaca', 'Zapoteca'),ax=axes[1])
figure.set_size_inches(9,3)
figure.set_dpi(300)
plt.savefig('centro_norte_intraregion_snp.svg')