annotate dpmix_plot.py @ 28:184d14e4270d

Update to Miller Lab devshed revision 4ede22dd5500
author Richard Burhans <burhans@bx.psu.edu>
date Wed, 17 Jul 2013 12:46:46 -0400
parents 8997f2ca8c7a
children a631c2f6d913
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
1 #!/usr/bin/env python
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
2
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
3 import os
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
4 import sys
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
5 import math
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
6 import matplotlib as mpl
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
7 mpl.use('PDF')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
8 import matplotlib.pyplot as plt
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
9 from matplotlib.path import Path
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
10 import matplotlib.patches as patches
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
11
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
12 ################################################################################
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
13
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
14 def build_chrom_len_dict(dbkey, galaxy_data_index_dir):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
15 chrom_len_root = os.path.join(galaxy_data_index_dir, 'shared/ucsc/chrom')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
16 chrom_len_file = '{0}.len'.format(dbkey)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
17 chrom_len_path = os.path.join(chrom_len_root, chrom_len_file)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
18
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
19 chrom_len = {}
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
20
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
21 try:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
22 with open(chrom_len_path) as fh:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
23 for line in fh:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
24 line = line.rstrip('\r\n')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
25 elems = line.split()
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
26 if len(elems) == 2:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
27 chrom = elems[0]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
28 length = int(elems[1])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
29 chrom_len[chrom] = length
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
30 except:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
31 pass
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
32
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
33 return chrom_len
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
34
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
35 def parse_input_file(input_file):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
36 chroms = []
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
37 individuals = []
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
38 data = {}
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
39 chrom_len = {}
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
40 used_states = []
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
41
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
42 with open(input_file) as fh:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
43 for line in fh:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
44 line = line.strip()
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
45 if line:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
46 elems = line.split()
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
47 chrom = elems[0]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
48 p1, p2, state = map(int, elems[1:4])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
49 id = elems[4]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
50
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
51 if state not in used_states:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
52 used_states.append(state)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
53
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
54 if chrom not in chroms:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
55 chroms.append(chrom)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
56
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
57 if id not in individuals:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
58 individuals.append(id)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
59
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
60 data.setdefault(chrom, {})
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
61 data[chrom].setdefault(id, [])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
62 data[chrom][id].append((p1, p2, state))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
63
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
64 if p2 > chrom_len.setdefault(chrom, 0):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
65 chrom_len[chrom] = p2
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
66
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
67 return chroms, individuals, data, chrom_len, used_states
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
68
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
69 def check_chroms(chroms, chrom_len, dbkey):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
70 error = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
71 for chrom in chroms:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
72 if chrom not in chrom_len:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
73 print >> sys.stderr, "Can't find length for {0} chromosome {1}".format(dbkey, chrom)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
74 error = 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
75 if error:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
76 sys.exit(1)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
77
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
78 def check_data(data, chrom_len, dbkey):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
79 error = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
80 for chrom in data:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
81 chrom_beg = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
82 chrom_end = chrom_len[chrom]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
83 for individual in data[chrom]:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
84 for p1, p2, state in data[chrom][individual]:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
85 if p1 >= p2:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
86 print >> sys.stderr, "Bad data line: begin >= end: {0} {1} {2} {3}".format(chrom, p1, p2, state, individual)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
87 error = 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
88 if p1 < chrom_beg or p2 > chrom_end:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
89 print >> sys.stderr, "Bad data line: outside {0} boundaries[{1} - {2}]: {3} {4} {5} {6}".format(dbkey, chrom_beg, chrom_end, chrom, p1, p2, state, individual)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
90 error = 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
91 if error:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
92 sys.exit(1)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
93
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
94 def make_rectangle(p1, p2, color, bottom=0.0, top=1.0):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
95 verts = [
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
96 (p1, bottom), # left, bottom
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
97 (p1, top), # left, top
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
98 (p2, top), # right, top
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
99 (p2, bottom), # right, bottom
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
100 (0.0, 0.0) # ignored
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
101 ]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
102
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
103 codes = [
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
104 Path.MOVETO,
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
105 Path.LINETO,
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
106 Path.LINETO,
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
107 Path.LINETO,
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
108 Path.CLOSEPOLY
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
109 ]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
110
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
111 path = Path(verts, codes)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
112 return patches.PathPatch(path, facecolor=color, lw=0)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
113
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
114 def make_split_rectangle(p1, p2, top_color, bottom_color):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
115 patch1 = make_rectangle(p1, p2, bottom_color, top=0.5)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
116 patch2 = make_rectangle(p1, p2, top_color, bottom=0.5)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
117 return [patch1, patch2]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
118
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
119 def make_state_rectangle_2pop(p1, p2, state, chrom, individual):
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
120 p1_color = 'r'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
121 p2_color = 'g'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
122 heterochromatin_color = '#c7c7c7'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
123
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
124 if state == 0:
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
125 return [ make_rectangle(p1, p2, heterochromatin_color) ]
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
126 elif state == 1:
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
127 return [ make_rectangle(p1, p2, p1_color) ]
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
128 elif state == 2:
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
129 return [ make_rectangle(p1, p2, p2_color) ]
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
130 elif state == 3:
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
131 return make_split_rectangle(p1, p2, p1_color, p2_color)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
132 else:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
133 print >> sys.stderr, "Unknown state: {0}: {1} {2} {3} {4}".format(state, chrom, p1, p2, state, individual)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
134 sys.exit(1)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
135
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
136 def make_state_rectangle_3pop(p1, p2, state, chrom, individual):
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
137 p1_color = 'r'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
138 p2_color = 'g'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
139 p3_color = 'b'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
140 heterochromatin_color = '#c7c7c7'
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
141
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
142 if state == 0:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
143 return [ make_rectangle(p1, p2, heterochromatin_color) ]
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
144 if state == 1:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
145 return [ make_rectangle(p1, p2, p1_color) ]
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
146 if state == 2:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
147 return [ make_rectangle(p1, p2, p2_color) ]
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
148 if state == 3:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
149 return [ make_rectangle(p1, p2, p3_color) ]
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
150 if state == 4:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
151 return make_split_rectangle(p1, p2, p1_color, p2_color)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
152 if state == 5:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
153 return make_split_rectangle(p1, p2, p1_color, p3_color)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
154 if state == 6:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
155 return make_split_rectangle(p1, p2, p2_color, p3_color)
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
156 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
157 print >> sys.stderr, "Unknown state: {0}: {1} {2} {3} {4}".format(state, chrom, p1, p2, state, individual)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
158 sys.exit(1)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
159
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
160 def nicenum(num, round=False):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
161 if num == 0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
162 return 0.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
163
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
164 exp = int(math.floor(math.log10(num)))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
165 f = num / math.pow(10, exp)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
166
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
167 if round:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
168 if f < 1.5:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
169 nf = 1.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
170 elif f < 3.0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
171 nf = 2.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
172 elif f < 7.0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
173 nf = 5.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
174 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
175 nf = 10.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
176 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
177 if f <= 1.0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
178 nf = 1.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
179 elif f <= 2.0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
180 nf = 2.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
181 elif f <= 5.0:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
182 nf = 5.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
183 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
184 nf = 10.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
185
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
186 return nf * pow(10, exp)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
187
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
188 def tick_foo(beg, end, loose=False):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
189 ntick = 10
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
190
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
191 range = nicenum(end - beg, round=False)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
192 d = nicenum(range/(ntick - 1), round=True)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
193 digits = int(math.floor(math.log10(d)))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
194
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
195 if loose:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
196 graph_min = math.floor(beg/d) * d
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
197 graph_max = math.ceil(end/d) * d
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
198 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
199 graph_min = beg
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
200 graph_max = end
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
201
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
202 nfrac = max([-1 * digits, 0])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
203 vals = []
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
204
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
205 stop = graph_max
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
206 if loose:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
207 stop = graph_max + (0.5 * d)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
208
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
209 x = graph_min
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
210 while x <= stop:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
211 vals.append(int(x))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
212 x += d
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
213
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
214 vals = vals[1:]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
215
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
216 # if not loose:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
217 # if vals[-1] < graph_max:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
218 # vals.append(int(graph_max))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
219
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
220 labels = []
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
221 for val in vals:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
222 labels.append('{0}'.format(int(val/math.pow(10, digits))))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
223
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
224 # labels.append('{0:.1f}'.format(vals[-1]/math.pow(10, digits)))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
225
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
226 return vals, labels
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
227
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
228 ################################################################################
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
229
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
230 def make_dpmix_plot(input_dbkey, input_file, output_file, galaxy_data_index_dir, state2name=None, populations=3):
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
231 fs_chrom_len = build_chrom_len_dict(input_dbkey, galaxy_data_index_dir)
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
232 chroms, individuals, data, chrom_len, used_states = parse_input_file(input_file)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
233
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
234 if populations == 3:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
235 make_state_rectangle = make_state_rectangle_3pop
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
236 elif populations == 2:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
237 make_state_rectangle = make_state_rectangle_2pop
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
238 else:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
239 pass
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
240
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
241 for chrom in chrom_len.keys():
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
242 if chrom in fs_chrom_len:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
243 chrom_len[chrom] = fs_chrom_len[chrom]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
244
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
245 #check_chroms(chroms, chrom_len, input_dbkey)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
246 check_data(data, chrom_len, input_dbkey)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
247
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
248 ## units below are inches
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
249 top_space = 0.10
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
250 chrom_space = 0.25
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
251 chrom_height = 0.25
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
252 ind_space = 0.10
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
253 ind_height = 0.25
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
254
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
255 total_height = 0.0
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
256
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
257 ## make a legend
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
258 ## only print out states that are
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
259 ## 1) in the data
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
260 ## - AND -
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
261 ## 2) in the state2name map
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
262 ## here, we only calculate the space needed
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
263 legend_states = []
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
264 if state2name is not None:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
265 for state in used_states:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
266 if state in state2name:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
267 legend_states.append(state)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
268
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
269 if legend_states:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
270 total_height += len(legend_states) * (ind_space + ind_height)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
271 total_height += (top_space - ind_space)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
272 at_top = False
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
273 else:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
274 at_top = True
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
275
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
276 for chrom in chroms:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
277 if at_top:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
278 total_height += (top_space + chrom_height)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
279 at_top = False
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
280 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
281 total_height += (top_space + chrom_space + chrom_height)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
282
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
283 individual_count = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
284 for individual in individuals:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
285 if individual in data[chrom]:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
286 individual_count += 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
287 total_height += individual_count * (ind_space + ind_height)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
288
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
289 width = 7.5
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
290 height = math.ceil(total_height)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
291
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
292 bottom = 1.0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
293
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
294 fig = plt.figure(figsize=(width, height))
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
295
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
296 if legend_states:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
297 at_top = True
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
298 for state in sorted(legend_states):
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
299 if at_top:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
300 bottom -= (top_space + ind_height)/height
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
301 at_top = False
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
302 else:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
303 bottom -= (ind_space + ind_height)/height
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
304 ## add code here to draw legend
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
305 # [left, bottom, width, height]
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
306 ax1 = fig.add_axes([0.0, bottom, 0.09, ind_height/height])
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
307 plt.axis('off')
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
308 ax1.set_xlim(0, 1)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
309 ax1.set_ylim(0, 1)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
310 for patch in make_state_rectangle(0, 1, state, 'legend', state2name[state]):
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
311 ax1.add_patch(patch)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
312
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
313 ax2 = fig.add_axes([0.10, bottom, 0.88, ind_height/height], frame_on=False)
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
314 plt.axis('off')
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
315 plt.text(0.0, 0.5, state2name[state], fontsize=10, ha='left', va='center')
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
316 else:
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
317 at_top = True
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
318
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
319 for_webb = False
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
320
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
321 for chrom in chroms:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
322 length = chrom_len[chrom]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
323 vals, labels = tick_foo(0, length)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
324
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
325 if at_top:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
326 bottom -= (top_space + chrom_height)/height
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
327 at_top = False
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
328 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
329 bottom -= (top_space + chrom_space + chrom_height)/height
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
330
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
331 if not for_webb:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
332 ax = fig.add_axes([0.0, bottom, 1.0, chrom_height/height])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
333 plt.axis('off')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
334 plt.text(0.5, 0.5, chrom, fontsize=14, ha='center')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
335
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
336 individual_count = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
337 for individual in individuals:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
338 if individual in data[chrom]:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
339 individual_count += 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
340
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
341 i = 0
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
342 for individual in individuals:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
343 if individual in data[chrom]:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
344 i += 1
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
345
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
346 bottom -= (ind_space + ind_height)/height
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
347 if not for_webb:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
348 # [left, bottom, width, height]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
349 ax1 = fig.add_axes([0.0, bottom, 0.09, ind_height/height])
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
350 plt.axis('off')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
351 plt.text(1.0, 0.5, individual, fontsize=10, ha='right', va='center')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
352 # [left, bottom, width, height]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
353 ax2 = fig.add_axes([0.10, bottom, 0.88, ind_height/height], frame_on=False)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
354 ax2.set_xlim(0, length)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
355 ax2.set_ylim(0, 1)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
356 if i != individual_count:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
357 plt.axis('off')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
358 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
359 if not for_webb:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
360 ax2.tick_params(top=False, left=False, right=False, labelleft=False)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
361 ax2.set_xticks(vals)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
362 ax2.set_xticklabels(labels)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
363 else:
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
364 plt.axis('off')
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
365 for p1, p2, state in sorted(data[chrom][individual]):
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
366 #for patch in make_state_rectangle(p1, p2, state, chrom, individual):
12
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
367 for patch in make_state_rectangle(p1, p2, state, chrom, individual):
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
368 ax2.add_patch(patch)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
369
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
370 plt.savefig(output_file)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
371
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
372 ################################################################################
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
373
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
374 if __name__ == '__main__':
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
375 input_dbkey, input_file, output_file, galaxy_data_index_dir = sys.argv[1:5]
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
376 make_dpmix_plot(input_dbkey, input_file, output_file, galaxy_data_index_dir)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
377 sys.exit(0)
4b6590dd7250 Uploaded
miller-lab
parents:
diff changeset
378
27
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
379 ## notes
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
380 # 1) pass in a state to name mapping
8997f2ca8c7a Update to Miller Lab devshed revision bae0d3306d3b
Richard Burhans <burhans@bx.psu.edu>
parents: 12
diff changeset
381 # 2) only print out names for states which exist in the data, and are in the state to name mapping