%load_ext autoreload
%autoreload 2
%matplotlib inline
%run nb_init.py
/home/guillaume/anaconda/envs/python3/lib/python3.4/site-packages/graph_tool/draw/cairo_draw.py:1340: RuntimeWarning: Error importing Gtk module: No module named 'gi'; GTK+ drawing will not work. warnings.warn(msg, RuntimeWarning)
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) /home/guillaume/Python/leg-joint/notebooks/nb_init.py in <module>() 20 import graph_tool.all as gt 21 #import matplotlib.pyplot as plt ---> 22 import leg_joint as lj 23 import numpy as np 24 /home/guillaume/Python/leg-joint/leg_joint/__init__.py in <module>() 24 import matplotlib.pylab as plt 25 ---> 26 from .epithelium import Epithelium 27 from .optimizers import find_energy_min, isotropic_optimum 28 from .optimizers import approx_grad, check_local_grad, running_local_optimum ImportError: bad magic number in 'leg_joint.epithelium': b'\x03\xf3\r\n'
all_kwargs = {'seq_kwargs': {'num_cells': 30, ## The number of apoptotice cells
'width_apopto':60., ## The width of the apoptotic region
'amp': 0., ## The importance of the ventral bias
'seed': 10, ## Seed for the random process
'num_steps': 10, ## The number of step to perform apoptosis
'ventral_bias': True,
'random': True,
'gamma': 1,
'theta_sorted': False},
'apopto_kwargs': {'vol_reduction':0.5,
'contractility': 1.,
'radial_tension': 0.},
'post_kwargs': {'max_ci':3.,
'rate_ci':1.4,
'span_ci':2}
}
eptm = lj.Epithelium(graphXMLfile='../saved_graphs/xml/before_apoptosis.xml',
identifier='joint', copy=True)
2014-04-30 12:32:08,160 -leg_joint.epithelium -INFO -Instanciating epithelium joint 2014-04-30 12:32:09,373 -leg_joint.epithelium -INFO -Initial cells 2014-04-30 12:32:09,374 -leg_joint.epithelium -INFO -Initial junctions 2014-04-30 12:32:21,013 -leg_joint.epithelium -INFO -Update geometry
eptm.isotropic_relax()
ax = lj.plot_avg_rho(eptm, bin_width=20)
/home/guillaume/python3/lib/python3.3/site-packages/matplotlib-1.4.x-py3.3-linux-x86_64.egg/matplotlib/figure.py:1617: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect. warnings.warn("This figure includes Axes that are not "
seq_kwargs = all_kwargs['seq_kwargs']
apopto_kwargs = all_kwargs['apopto_kwargs']
post_kwargs = all_kwargs['post_kwargs']
apopto_cells, fold_cells, apopto_sequence = lj.get_apoptotic_cells(eptm, **seq_kwargs)
print('%i apoptotic cell(s)' % len(apopto_cells))
print('surrounded by %i fold cells' % len(fold_cells))
30 apoptotic cell(s) surrounded by 157 fold cells
eptm.set_local_mask(None)
lj.local_slice(eptm, theta_amp=2*np.pi,
zed_amp=seq_kwargs['width_apopto'])
eptm.update_rhotheta()
d_theta = 0.
z_angle = np.pi / 6
pseudo_x = eptm.ixs.copy()
pseudo_y = eptm.ixs.copy()
pseudo_x.a = eptm.zeds.a * np.cos(z_angle) - eptm.rhos.a * np.sin(
eptm.thetas.a + d_theta) * np.sin(z_angle)
pseudo_y.a = eptm.rhos.a * np.cos(eptm.thetas.a + d_theta)
is_apopto = eptm.is_cell_vert.copy()
is_apopto.a[:] = 0
color_dead = eptm.zeds.copy()
color_dead.a[:] = 0.
for cell in apopto_cells:
color_dead[cell] = 1.
is_apopto[cell] = 1
for jv in cell.out_neighbours():
is_apopto[jv] = 1
ax = lj.plot_eptm_generic(eptm,
pseudo_x, pseudo_y, local=True,
cell_kwargs={'cell_colors':color_dead, 'cmap': 'Reds', 'alpha':0.8},
edge_kwargs={'c':'g', 'lw':1, 'alpha':0.4})
plt.savefig('../doc/imgs/apoptosis_repartition.svg')
mean_rho = eptm.rhos.a.mean()
thetas = np.linspace(0, 2 * np.pi, 60)
fig, ax = plt.subplots(figsize=(8, 4))
num_rows = 12
delta = 60.
for n, cells in enumerate(apopto_sequence[1:]):
if len(cells) == 0: break
dx = + (n % num_rows) * delta
dy = - (n // num_rows) * delta
ax.plot(mean_rho * np.cos(thetas) + dx,
mean_rho * np.sin(thetas) + dy, 'k-', alpha=0.4)
ax.text(dx, dy, str(n + 1), fontsize=10)
for cell in cells:
ax.plot(eptm.wys[cell] + dx, eptm.ixs[cell] + dy, 'ro', alpha=0.5)
ax.set_aspect('equal')
ax.set_xticks([])
ax.set_yticks([])
dx = + ((n + 1) % num_rows) * delta
dy = - ((n + 1) // num_rows) * delta
ax.plot(mean_rho * np.cos(thetas) + dx,
mean_rho * np.sin(thetas) + dy, 'k-', alpha=0.4)
ax.text(dx, dy, 'all', fontsize=10)
for cell in apopto_cells:
ax.plot(eptm.wys[cell] + dx, eptm.ixs[cell] + dy, 'ko', alpha=0.7)
ax.set_title('Sequence of apoptoses around the joint')
plt.show()
lj.gradual_apoptosis(eptm, seq_kwargs,
apopto_kwargs, post_kwargs)
eptm.graph
<Graph object, undirected, with 73 vertices and 186 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x7fbb22b98310, at 0x7fbb22b2f110>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x7fbb22b98310, at 0x7fbb22b98bd0>, False) at 0x7fbb22b98310>
(eptm.is_local_vert.a * (eptm.is_cell_vert.a)).sum()
19
eptm.zeds.fa.size
5131
fig, ax = plt.subplots()
ax.plot(eptm.zeds.fa, eptm.ixs.fa, 'o', alpha=0.5)
[<matplotlib.lines.Line2D at 0x7fbb1c15b7d0>]
for je in eptm.graph.edges():
print(je.source(), je.target(),
eptm.zeds[je.source()], eptm.zeds[je.target()],
eptm.is_cell_vert[je.source()], eptm.is_cell_vert[je.target()])
273 3610 nan -14.099431991577148 1 0 273 3609 nan nan 1 0 273 1512 nan -1.3159493207931519 1 0 273 1456 nan 4.452213287353516 1 0 273 4761 nan -4.5094112572008065 1 0 273 1511 nan -3.888937105216203 1 0 275 1460 -1.1418145533121804 -0.5534912504719165 1 0 275 4083 -1.1418145533121804 -1.6618512875358082 1 0 275 4084 -1.1418145533121804 -0.6352377008984207 1 0 275 1461 -1.1418145533121804 -1.1426801230372607 1 0 275 1514 -1.1418145533121804 -1.7158124046174956 1 0 276 3258 -0.08757383100483672 1.448652506582386 1 0 276 1459 -0.08757383100483672 1.3655196568138508 1 0 276 3259 -0.08757383100483672 1.8804058651499787 1 0 276 3708 -0.08757383100483672 -1.7423645724171335 1 0 276 1460 -0.08757383100483672 -0.5534912504719165 1 0 276 4084 -0.08757383100483672 -0.6352377008984207 1 0 276 1515 -0.08757383100483672 -2.3765013217926025 1 0 301 3294 nan -5.775954246520996 1 0 301 3589 nan -14.522082328796387 1 0 301 1566 nan -4.885640621185303 1 0 301 4027 nan -11.061452865600586 1 0 301 1513 nan nan 1 0 301 3588 nan -3.3918087482452393 1 0 301 1510 nan -2.773810625076294 1 0 302 1569 nan nan 1 0 302 1568 nan nan 1 0 302 1566 nan -4.885640621185303 1 0 302 4026 nan -1.8206626176834106 1 0 302 4027 nan -11.061452865600586 1 0 303 1511 nan -3.888937105216203 1 0 303 1514 nan -1.7158124046174956 1 0 303 1512 nan -1.3159493207931519 1 0 303 4083 nan -1.6618512875358082 1 0 303 5082 nan nan 1 0 303 5083 nan -2.371620018901476 1 0 304 4011 nan -3.1514766216278076 1 0 304 4012 nan nan 1 0 304 1516 nan -3.3551583290100098 1 0 304 1517 nan -2.3676369462852653 1 0 304 1570 nan -2.8544053084248553 1 0 332 1623 nan -4.627558513397251 1 0 332 3745 nan -2.8426042806686733 1 0 332 1568 nan nan 1 0 332 4026 nan -1.8206626176834106 1 0 332 3744 nan -2.8544053084248553 1 0 332 1567 nan nan 1 0 1457 1510 -2.762709856033325 -2.773810625076294 0 0 1459 1460 1.3655196568138508 -0.5534912504719165 0 0 1460 1461 -0.5534912504719165 -1.1426801230372607 0 0 1461 1514 -1.1426801230372607 -1.7158124046174956 0 0 1510 1513 -2.773810625076294 nan 0 0 1511 1512 -3.888937105216203 -1.3159493207931519 0 0 1511 1514 -3.888937105216203 -1.7158124046174956 0 0 1515 1516 -2.3765013217926025 -3.3551583290100098 0 0 1516 1517 -3.3551583290100098 -2.3676369462852653 0 0 1517 1570 -2.3676369462852653 -2.8544053084248553 0 0 1521 1574 13.181417465209961 -3.8302853107452393 0 0 1566 1569 -4.885640621185303 nan 0 0 1568 1569 nan nan 0 0 1568 1623 nan -4.627558513397251 0 0 1571 1574 nan -3.8302853107452393 0 0 1571 1572 nan nan 0 0 1572 1573 nan nan 0 0 1573 1626 nan nan 0 0 2822 1568 nan nan 1 0 2822 1569 nan nan 1 0 2822 2823 nan nan 1 0 2822 2824 nan -1.1941092014312744 1 0 2822 3696 nan nan 1 0 2822 1623 nan -4.627558513397251 1 0 2823 1569 nan nan 0 0 2823 2824 nan -1.1941092014312744 0 0 3182 3183 nan nan 1 0 3182 3184 nan 1.5334751605987549 1 0 3182 1626 nan nan 1 0 3182 1572 nan nan 1 0 3182 1573 nan nan 1 0 3183 3184 nan 1.5334751605987549 0 0 3183 1572 nan nan 0 0 3184 1626 1.5334751605987549 nan 0 0 3258 3259 1.448652506582386 1.8804058651499787 0 0 3258 1459 1.448652506582386 1.3655196568138508 0 0 3294 1566 -5.775954246520996 -4.885640621185303 0 0 3307 1457 -15.780364036560059 -2.762709856033325 0 0 3339 1461 -2.1269224633805144 -1.1426801230372607 0 0 3588 3589 -3.3918087482452393 -14.522082328796387 0 0 3588 1510 -3.3918087482452393 -2.773810625076294 0 0 3589 3294 -14.522082328796387 -5.775954246520996 0 0 3608 3307 nan -15.780364036560059 1 0 3608 3610 nan -14.099431991577148 1 0 3608 3609 nan nan 1 0 3608 1513 nan nan 1 0 3608 1457 nan -2.762709856033325 1 0 3608 1510 nan -2.773810625076294 1 0 3609 3610 nan -14.099431991577148 0 0 3609 1512 nan -1.3159493207931519 0 0 3609 1513 nan nan 0 0 3610 1456 -14.099431991577148 4.452213287353516 0 0 3610 3307 -14.099431991577148 -15.780364036560059 0 0 3695 3184 nan 1.5334751605987549 1 0 3695 3696 nan nan 1 0 3695 3697 nan nan 1 0 3695 1623 nan -4.627558513397251 1 0 3695 3745 nan -2.8426042806686733 1 0 3695 1626 nan nan 1 0 3696 2824 nan -1.1941092014312744 0 0 3696 1623 nan -4.627558513397251 0 0 3696 3697 nan nan 0 0 3697 3184 nan 1.5334751605987549 0 0 3707 1521 nan 13.181417465209961 1 0 3707 1574 nan -3.8302853107452393 1 0 3707 3708 nan -1.7423645724171335 1 0 3707 3709 nan -0.46027876140157564 1 0 3707 4011 nan -3.1514766216278076 1 0 3707 1571 nan nan 1 0 3707 1515 nan -2.3765013217926025 1 0 3707 1516 nan -3.3551583290100098 1 0 3708 3259 -1.7423645724171335 1.8804058651499787 0 0 3708 1515 -1.7423645724171335 -2.3765013217926025 0 0 3708 3709 -1.7423645724171335 -0.46027876140157564 0 0 3709 1521 -0.46027876140157564 13.181417465209961 0 0 3743 1626 nan nan 1 0 3743 3745 nan -2.8426042806686733 1 0 3743 4012 nan nan 1 0 3743 1573 nan nan 1 0 3743 3744 nan -2.8544053084248553 1 0 3743 1570 nan -2.8544053084248553 1 0 3744 3745 -2.8544053084248553 -2.8426042806686733 0 0 3744 1570 -2.8544053084248553 -2.8544053084248553 0 0 3744 1567 -2.8544053084248553 nan 0 0 3745 1623 -2.8426042806686733 -4.627558513397251 0 0 3745 1626 -2.8426042806686733 nan 0 0 4010 1571 nan nan 1 0 4010 1572 nan nan 1 0 4010 1573 nan nan 1 0 4010 4011 nan -3.1514766216278076 1 0 4010 4012 nan nan 1 0 4011 1516 -3.1514766216278076 -3.3551583290100098 0 0 4011 1571 -3.1514766216278076 nan 0 0 4011 4012 -3.1514766216278076 nan 0 0 4012 1570 nan -2.8544053084248553 0 0 4012 1573 nan nan 0 0 4025 3609 nan nan 1 0 4025 1513 nan nan 1 0 4025 4026 nan -1.8206626176834106 1 0 4025 4027 nan -11.061452865600586 1 0 4025 1512 nan -1.3159493207931519 1 0 4025 5082 nan nan 1 0 4025 1567 nan nan 1 0 4026 1568 -1.8206626176834106 nan 0 0 4026 1567 -1.8206626176834106 nan 0 0 4026 4027 -1.8206626176834106 -11.061452865600586 0 0 4027 1566 -11.061452865600586 -4.885640621185303 0 0 4027 1513 -11.061452865600586 nan 0 0 4082 1515 -2.128000934070597 -2.3765013217926025 1 0 4082 1516 -2.128000934070597 -3.3551583290100098 1 0 4082 4084 -2.128000934070597 -0.6352377008984207 1 0 4082 4083 -2.128000934070597 -1.6618512875358082 1 0 4082 5083 -2.128000934070597 -2.371620018901476 1 0 4082 1517 -2.128000934070597 -2.3676369462852653 1 0 4083 1514 -1.6618512875358082 -1.7158124046174956 0 0 4083 4084 -1.6618512875358082 -0.6352377008984207 0 0 4084 1460 -0.6352377008984207 -0.5534912504719165 0 0 4084 1515 -0.6352377008984207 -2.3765013217926025 0 0 4760 1511 -2.814428690336451 -3.888937105216203 1 0 4760 3339 -2.814428690336451 -2.1269224633805144 1 0 4760 1461 -2.814428690336451 -1.1426801230372607 1 0 4760 1514 -2.814428690336451 -1.7158124046174956 1 0 4760 4761 -2.814428690336451 -4.5094112572008065 1 0 4760 4762 -2.814428690336451 -3.502808788566427 1 0 4761 1456 -4.5094112572008065 4.452213287353516 0 0 4761 1511 -4.5094112572008065 -3.888937105216203 0 0 4761 4762 -4.5094112572008065 -3.502808788566427 0 0 4762 3339 -3.502808788566427 -2.1269224633805144 0 0 5081 3744 nan -2.8544053084248553 1 0 5081 1567 nan nan 1 0 5081 1517 nan -2.3676369462852653 1 0 5081 1570 nan -2.8544053084248553 1 0 5081 5082 nan nan 1 0 5081 5083 nan -2.371620018901476 1 0 5082 1512 nan -1.3159493207931519 0 0 5082 1567 nan nan 0 0 5082 5083 nan -2.371620018901476 0 0 5083 4083 -2.371620018901476 -1.6618512875358082 0 0 5083 1517 -2.371620018901476 -2.3676369462852653 0 0
eptm.update_geometry()
np.all(np.isfinite(eptm.ixs.fa))
False
eptm.stamp
6747
import hdfgraph
latest = hdfgraph.graph_from_hdf(eptm.paths['hdf'], stamp=6746)
/home/guillaume/python3/lib/python3.3/site-packages/numexpr/necompiler.py:742: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return compiled_ex(*arguments, **kwargs) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/numexpr/necompiler.py:742: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return compiled_ex(*arguments, **kwargs) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args)
latest
<Graph object, directed, with 15381 vertices and 45615 edges at 0x7fbb1ddded10>
eptm.graph
<Graph object, undirected, with 73 vertices and 186 edges, edges filtered by (<PropertyMap object with key type 'Edge' and value type 'bool', for Graph 0x7fbb22b98310, at 0x7fbb22b2f110>, False), vertices filtered by (<PropertyMap object with key type 'Vertex' and value type 'bool', for Graph 0x7fbb22b98310, at 0x7fbb22b98bd0>, False) at 0x7fbb22b98310>
vertex_df, edge_df = hdfgraph.frames_from_hdf(eptm.paths['hdf'], stamp=6746)
/home/guillaume/python3/lib/python3.3/site-packages/numexpr/necompiler.py:742: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return compiled_ex(*arguments, **kwargs) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/numexpr/necompiler.py:742: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return compiled_ex(*arguments, **kwargs) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args) /home/guillaume/python3/lib/python3.3/site-packages/tables/conditions.py:447: DeprecationWarning: using `oa_ndim == 0` when `op_axes` is NULL is deprecated. Use `oa_ndim == -1` or the MultiNew iterator for NumPy <1.8 compatibility return func(*args)
vertex_df.drop_duplicates().xs(0, level='vertex_index')
ages | areas | contractile_grad | contractilities | elastic_grad | grad_ix | grad_radial | grad_sigma | grad_wy | grad_zed | is_active_vert | is_alive | is_cell_vert | is_local_vert | ixs | perimeters | prefered_vol | radial_tensions | rhos | sigmas | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
stamp | |||||||||||||||||||||
6746 | 0 | 12 | 0 | 276.48 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 26.401755 | 0 | 288 | 0 | 26.463649 | 1.810293 | ... |
1 rows × 28 columns
eptm.graph.set_vertex_filter(None)
eptm.graph.set_edge_filter(None)
eptm.graph.set_vertex_filter(eptm.is_local_vert)
eptm.graph.set_edge_filter(eptm.is_local_edge)
ax = lj.plot_avg_rho(eptm, bin_width=20)
eptm = lj.Epithelium(graphXMLfile='../saved_graphs/joint_2014-03-04T14_02_13/xml/post_optimize.xml',
identifier='joint')
eptm.identifier
'joint_2014-03-06T09_25_05'
lj.draw(eptm,
output3d=os.path.join(eptm.paths['png'],
'post_apopto_3d.png'),
output2d=os.path.join(eptm.paths['png'],
'post_apopto_2d.png'))
import IPython.core.display as disp
disp.Image(os.path.join(eptm.paths['png'],
'post_apopto_3d.png'))
disp.Image(os.path.join(eptm.paths['png'],
'post_apopto_2d.png'))
ax = lj.plot_avg_rho(eptm, bin_width=20)
anisotropies, alignments = eptm.cells.get_anisotropies()
rel_c = anisotropies #alignments
lj.local_slice(eptm, zed_amp=15, theta_amp=np.pi)
ax_zs, ax_xy = lj.plot_2pannels(eptm,
cell_kwargs={'c_text':False,
'cell_colors':rel_c,
'alpha':0.4},
edge_kwargs={'j_text':False,
'c':'k',
'lw':0.5,
'alpha':0.8})
lj.local_slice(eptm, zed_amp=15, theta_amp=np.pi/2., theta_c=0)
ax_zs = lj.plot_eptm_generic(eptm, eptm.zeds, eptm.ixs, cell_kwargs={'c_text':False,
'cell_colors':eptm.zeds,
'alpha':0.4},
edge_kwargs={'j_text':False,
'c':'k',
'lw':0.5,
'alpha':0.8})
fig, axes = plt.subplots(2, 1, sharex=True)
eptm.graph.set_vertex_filter(eptm.is_cell_vert)
axes[0].plot(eptm.zeds.fa, anisotropies.fa, 'o', alpha=0.4)
axes[0].set_ylim(0.8, 2)
axes[1].plot(eptm.zeds.fa, alignments.fa, 'o', alpha=0.4)
axes[1].set_ylim(-0.1, 1.1)
eptm.graph.set_vertex_filter(None)
disp.Image('../saved_graphs/joint_2014-03-04T14_02_13/png/eptm3d_4649.png')
disp.Image('../saved_graphs/joint_2014-03-04T14_02_13/png/eptm2d_4649.png')
import pandas as pd
store_path = os.path.join(eptm.paths['hdf'])
with pd.get_store(store_path) as store:
print(store)
all_areas = store.select('vertices',
columns=['areas', 'zeds',
'is_cell_vert',
'is_alive'])
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-27-84b0eb0ef8aa> in <module>() 7 columns=['areas', 'zeds', 8 'is_cell_vert', ----> 9 'is_alive']) /home/guillaume/python3/lib/python3.3/site-packages/pandas-0.12.0_1089_g3737372-py3.3-linux-i686.egg/pandas/io/pytables.py in select(self, key, where, start, stop, columns, iterator, chunksize, auto_close, **kwargs) 597 group = self.get_node(key) 598 if group is None: --> 599 raise KeyError('No object named %s in the file' % key) 600 601 # create the storer and axes KeyError: 'No object named vertices in the file'
<class 'pandas.io.pytables.HDFStore'> File path: /home/guillaume/Python/leg_joint/saved_graphs/joint_2014-03-06T09_25_05/eptm_joint_2014-03-06T09_25_05.h5 Empty
from mpl_toolkits.mplot3d import Axes3D
all_areas = all_areas[all_areas.is_cell_vert > 0]
all_areas = all_areas[all_areas.is_alive > 0]
stamp = all_areas.index.get_level_values('stamp').values
colors = plt.cm.jet(stamp)
fig, ax = plt.subplots(subplot_kw={'projection':'3d'})
ax.scatter(stamp,
all_areas.zeds.values,
zs=all_areas.areas.values,
c=stamp, cmap='jet', alpha=0.1)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-5154c63cffae> in <module>() 1 from mpl_toolkits.mplot3d import Axes3D 2 ----> 3 all_areas = all_areas[all_areas.is_cell_vert > 0] 4 all_areas = all_areas[all_areas.is_alive > 0] 5 NameError: name 'all_areas' is not defined
all_areas.index.get_level_values('stamp').unique().size
404
lj.draw(eptm,
output3d=os.path.join(eptm.paths['png'],
'after_apopto.png'))
avg_dists = []
for cell in eptm.cells:
neighbs = eptm.cells.get_neighbor_cells(cell)
xyz = np.array([[eptm.ixs[n] - eptm.ixs[cell],
eptm.wys[n] - eptm.wys[cell],
eptm.zeds[n] - eptm.zeds[cell]]
for n in neighbs])
if not len(xyz):
continue
avg_dist = np.sqrt((xyz**2).sum(axis=1)).mean()
avg_dists.append(avg_dist)
avg_dists = np.array(avg_dists)
num_sigma = 2*np.pi*eptm.rhos.a.mean() / avg_dists.mean()
print('Number of cells around the leg: %.1f' % num_sigma)
width_apopto = fixed_params['width_apopto']
p0 = 1.
amp = fixed_params['amp']
thetas = np.linspace(-np.pi, np.pi, 512)
zeds = np.linspace(-20, 20, 512)
fig, ax = plt.subplots()#subplot_kw={'projection':'3d'})
thetas, zeds = np.meshgrid(thetas, zeds)
probas = p_apopto(zeds, thetas,
width_apopto=width_apopto,
p0=p0, amp=0.4)
im = ax.imshow(probas.T, vmin=0, vmax=1, cmap='gray', aspect=20/180.,
extent=(-20, 20, 0, 360))
_ = plt.colorbar(im)
#plt.savefig('../doc/imgs/apoptosis_proba_width_{}_p0_{}_amp_{}.svg'.format(width_apopto, p0, amp))
fig, axes = plt.subplots(1, 4,
figsize=(16, 4))
radii = np.ones(8)
width = np.pi/4
avg_hists *= norm
for i in range(4):
num_depths = avg_hists[i, :]
ax = axes[i]
# bars = ax.bar(np.arange(0, 2*np.pi, np.pi/4), radii,
# width=width, bottom=0.0, )
# for nd, bar in zip(num_depths, bars):
# bar.set_facecolor([0, 0, 0])
# bar.set_alpha(nd/avg_hists.max())
labels = ['%1.1f' % nd for nd in avg_hists[i, :]]
sizes = np.ones(8)
colors = [(1 - nd/avg_hists.max(),
1 - nd/avg_hists.max(),
1 - nd/avg_hists.max())
for nd in avg_hists[i, :]]
ax.pie(sizes, colors=colors, labels=labels, startangle=-90)
ax.axis('equal')
fig.savefig('../doc/imgs/repartition_pie_plot.svg')
plt.draw()
all_hists = []
n_cells = []
for seed in range(10):
print('Random seed: %i' % seed)
apopto_cells = get_apoptotic_cells(eptm,
seed=seed, z0=0.,
width_apopto=width_apopto,
p0=p0, amp=amp)
apopto_sequence = get_sequence(apopto_cells, num_steps=10)
n_seq = len(apopto_sequence)
n_cells.append(len(apopto_cells))
apopto_4steps = [np.concatenate(
apopto_sequence[n_seq//4 * i:
n_seq//4 * i + n_seq//4]
) for i in range(4)]
thetas_4steps = [np.unique([eptm.thetas[cell] for cell in seq])
for seq in apopto_4steps]
hists_4steps = [np.histogram(thetas, bins=8, range=(-np.pi, np.pi))[0]
for thetas in thetas_4steps]
all_hists.append(hists_4steps)
all_hists = np.array(all_hists)
n_cells= np.array(n_cells)
print('Average number of apoptic cells: %.1f ± %.2f'
% (n_cells.mean(), n_cells.std()))
avg_hists = all_hists.mean(axis=0)
norm = n_cells.mean() / avg_hists.sum()
print('repartition: ')
print(avg_hists * norm)
print('Summed:')
print(avg_hists.sum(axis=0) * norm)
in_vivo_hist = np.array([[0.6, 0.6, 0.2, 0.0, 0.3, 0.6, 0.6, 1.0],
[1.5, 0.8, 0.3, 0.5, 0.3, 0.7, 2.7, 2.9],
[1.2, 2.4, 0.6, 0.8, 1.3, 1.8, 3.5, 1.0],
[0.0, 0.0, 0.0, 1.3, 1.4, 0.6, 0.4, 0.0]])
eptm_unbiased = eptm
def average_rho(eptm, bin_width=10):
eptm.update_rhotheta()
zeds = eptm.zeds.a
rhos = eptm.rhos.a
rhos = rhos[np.argsort(zeds)]
zeds = np.sort(zeds)
rhos_cliped = rhos[: -(rhos.size % bin_width)]
rhos_cliped = rhos_cliped.reshape((rhos_cliped.size // bin_width, bin_width))
rhos_avg = rhos_cliped.mean(axis=1)
rhos_max = rhos_cliped.max(axis=1)
rhos_min = rhos_cliped.min(axis=1)
zeds_cliped = zeds[: -(zeds.size % bin_width)]
zeds_cliped = zeds_cliped.reshape((zeds_cliped.size // bin_width, bin_width))
zeds_avg = zeds_cliped.mean(axis=1)
return zeds_avg, rhos_avg, rhos_max, rhos_min
def plot_avg_rho(eptm, bin_width, ax=None, retall=False, ls='r-'):
if ax is None:
fig, ax = plt.subplots(figsize=(12,4))
else:
fig = ax.get_figure()
zeds_avg, rhos_avg, rhos_max, rhos_min = average_rho(eptm, bin_width)
ax.fill_between(zeds_avg,
rhos_max,
rhos_min,
facecolor='0.5', edgecolor='0.9')
ax.plot(zeds_avg, rhos_avg, ls, lw=2, alpha=0.7)
ax.set_aspect('equal')
max_zed = ax.get_ylim()[1]
ax.set_ylim(0, max_zed)
if not retall:
return ax
return ax, (zeds_avg, rhos_avg, rhos_max, rhos_min)
out = plot_avg_rho(eptm, 20)
thetas = np.linspace(0, 2*np.pi, 180)# + np.pi/2
i = eptm.stamp + 1
for n, theta in enumerate(thetas):
#output_nt= '../saved_graphs/png/after_apopto_nt_3d/angle_%03i.png' %n
output3d= os.path.join(eptm.paths['png'], 'eptm3d_%03i.png' % i)
lj.draw(eptm, d_theta=theta, output3d=output3d)
i += 1
def average_aniso(eptm, bin_width=10):
anisotropies, alignments = eptm.cells.get_anisotropies()
eptm.graph.set_vertex_filter(eptm.is_cell_vert)
zeds = eptm.zeds.fa
anisotropies = anisotropies.fa
eptm.graph.set_vertex_filter(None)
anisotropies = anisotropies[np.argsort(zeds)]
zeds = np.sort(zeds)
anisotropies_cliped = anisotropies[: -(anisotropies.size % bin_width)].clip(0, 4)
anisotropies_cliped = anisotropies_cliped.reshape((anisotropies_cliped.size // bin_width,
bin_width))
anisotropies_avg = anisotropies_cliped.mean(axis=1)
anisotropies_max = anisotropies_cliped.max(axis=1)
anisotropies_min = anisotropies_cliped.min(axis=1)
zeds_cliped = zeds[: -(zeds.size % bin_width)]
zeds_cliped = zeds_cliped.reshape((zeds_cliped.size // bin_width, bin_width))
zeds_avg = zeds_cliped.mean(axis=1)
return zeds_avg, anisotropies_avg, anisotropies_max, anisotropies_min
def plot_avg_aniso(eptm, bin_width, ax=None, retall=False, ls='r-'):
if ax is None:
fig, ax = plt.subplots(figsize=(12,4))
else:
fig = ax.get_figure()
zeds_avg, anisotropies_avg, anisotropies_max, anisotropies_min = average_aniso(eptm, bin_width)
ax.fill_between(zeds_avg,
anisotropies_max,
anisotropies_min,
facecolor='0.5', edgecolor='0.9')
ax.plot(zeds_avg, anisotropies_avg, ls, lw=2, alpha=0.7)
max_zed = ax.get_ylim()[1]
ax.set_ylim(0, max_zed)
if not retall:
return ax
return ax, (zeds_avg, anisotropies_avg, anisotropies_max, anisotropies_min)
ax = plot_avg_aniso(eptm, bin_width=10, ax=None, retall=False, ls='r-')
anisotropies, alignments = eptm.cells.get_anisotropies()
eptm.graph.set_vertex_filter(eptm.is_cell_vert)
fig, ax = plt.subplots()
ax.plot(eptm.zeds.fa, anisotropies.fa, 'ro', alpha=0.2)
ax.plot(eptm.zeds.fa, alignments.fa, 'bo', alpha=0.2)
ax.set_ylim(-2, 4)
eptm.graph.set_vertex_filter(None)