%load_ext autoreload
%autoreload 2
%matplotlib inline
%run nb_init.py
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)
eptm.isotropic_relax()
ax = lj.plot_avg_rho(eptm, bin_width=20)
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))
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
(eptm.is_local_vert.a * (eptm.is_cell_vert.a)).sum()
eptm.zeds.fa.size
fig, ax = plt.subplots()
ax.plot(eptm.zeds.fa, eptm.ixs.fa, 'o', alpha=0.5)
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()])
eptm.update_geometry()
np.all(np.isfinite(eptm.ixs.fa))
eptm.stamp
import hdfgraph
latest = hdfgraph.graph_from_hdf(eptm.paths['hdf'], stamp=6746)
latest
eptm.graph
vertex_df, edge_df = hdfgraph.frames_from_hdf(eptm.paths['hdf'], stamp=6746)
vertex_df.drop_duplicates().xs(0, level='vertex_index')
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
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'))