/
MeshDeformAndView.py
78 lines (50 loc) · 1.68 KB
/
MeshDeformAndView.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
# coding: utf-8
import sys
sys.path.append("./src/")
from pypointcloud import *
from spline_tools import ParametricSpline
import scipy as S
results = None
with open("./D_mel_wt__atlas_r2.vpc") as infile:
results = read_vpc(infile)
d = results[1]
x = d[:,0]
y = d[:,1]
z = d[:,2]
ap_line = None
x_min = x.min()
x_max = x.max()
z_min = z.min()
z_max = z.max()
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.widgets import Button
N_SPLINES = 9
points_per_spline = 5
from scipy.interpolate import griddata
mesh_x = S.loadtxt("mesh_x.txt")
mesh_y = S.loadtxt("mesh_y.txt")
the_splines = list()
for i in range(mesh_x.shape[0]):
the_splines.append(ParametricSpline(mesh_x[i],mesh_y[i]))
SAMPLE_NUMBER = 100
ts = S.linspace(0.0,1.0,SAMPLE_NUMBER)
old_xy = S.vstack([aspline(ts) for aspline in the_splines])
new_xy = S.vstack([S.hstack([i*S.ones((SAMPLE_NUMBER,1)), ts.reshape(-1,1)]) for i in range(len(the_splines))])
new_xs = griddata(old_xy, new_xy[:,0], (x, z), method='linear')
new_ys = griddata(old_xy, new_xy[:,1], (x, z), method='linear')
disp_genes = ["kni__3","D__3","hbP__3","bcdP__3","KrP__3","gt__3","eve__3","odd__3","rho__3","sna__3"]
#disp_genes = ["eve__3"]
for one_gene_name in disp_genes:
colnum = results[0]["column"].index(one_gene_name)-1
colors = S.vstack([d[:,colnum],S.zeros(d.shape[0]),S.zeros(d.shape[0])]).T
colors -= colors.min()
colors*=S.power(colors.max(),-1.0)
fig = plt.figure(figsize=(4,2))
ax = fig.add_subplot(1,1,1)
ax.set_title(one_gene_name)
ax.scatter(new_xs,new_ys,s=45.0,c=colors,alpha=0.75)
for i in range(8):
ax.axvline(float(i),c="g")
fig.tight_layout()
plt.show()