%load_ext autoreload
%autoreload 2
%matplotlib inline
%run nb_init
# This imports leg_joint as lj
2015-02-21 17:38:51,998 -leg_joint -<module> -- INFO -successfully imported leg_joint
Although the core paramter of the tissue are stored in an xml file, the paramters for the leg joint formation simulation are stored as a json file and implemented in dictionaries.
params = {## parameters to retrieve the apoptotic cells sequence
'seq_kwargs': {'num_cells': 1., ## The number of apoptotic cells
'width_apopto':2, ## The width of the apoptotic ring
'amp': 0.4, ## Aplitude of the dorsal/ventral bias
'seed': 10, ## Seed for the random number generator
'num_steps': 10, ## Number of subsequent steps for one cell to complete apoptosis},
'random': True}, ## If True, (biased) random distrbution of apoptotic cells
## paramters for the dynamic of each apoptotic step
'apopto_kwargs': {'vol_reduction':0.7, ## Cell volume reduction
'contractility': 1.2, ## Cell increase in contractility
'radial_tension': 0.1}, ## Increase n amplitude of the apico-basal force
## paramters for the increase in contractility after apoptosis
'post_kwargs': {'max_ci':2., ## Maximum value of the contractility of the neighbouring cells
'rate_ci':1., ## Rate at whihc contractility increase
'span_ci':2}, ## Span of the contractility increase (in terms of distance w/r to the apoptotic cell)
}
all_kwargs = lj.get_list_kwargs(0, params)
eptm = lj.Epithelium(lj.data.before_apoptosis_xml(),
save_dir='saved_graphs',
identifier='single',
copy=True)
eptm.isotropic_relax()
2015-02-16 12:30:45,335 -leg_joint.epithelium -__init__ -- INFO -Instanciating epithelium single 2015-02-16 12:30:47,104 -leg_joint.epithelium -__init__ -- INFO -Initial cells 2015-02-16 12:30:47,105 -leg_joint.epithelium -__init__ -- INFO -Initial junctions 2015-02-16 12:30:56,300 -leg_joint.epithelium -__init__ -- INFO -Update geometry
and get apoptic cells sequence (here only one cell will die)
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 cell(s)' % len(fold_cells))
1 apoptotic cell(s) surrounded by 157 fold cell(s)
Now grab our apoptotic cell, and have a look at it's surroundings
apopto_kwargs
{'vol_reduction': 0.7, 'radial_tension': 0.1, 'contractility': 1.2}
a_cell = apopto_cells[0]
eptm.set_local_mask(None)
eptm.set_local_mask(a_cell, wider=True)
neighbours = [neighbour for neighbour in eptm.cells.get_neighbor_cells(a_cell)]
## Let's define a neat plotting function
def show_apopto_surroundings(eptm, a_cell):
eptm.set_local_mask(None)
eptm.set_local_mask(a_cell, wider=True)
is_apoptotic = eptm.ixs.copy()
is_apoptotic.a[:] = 0.
is_apoptotic[a_cell] = 1.
ax_zs, ax_xy = lj.plot_2pannels(eptm,
edge_kwargs={'c':'k', 'lw':0.5, 'alpha':0.5},
cell_kwargs={'cell_colors':is_apoptotic,
'cmap':'Reds',
'alpha':0.5})
eptm.set_local_mask(None)
return ax_zs, ax_xy
### And use it straight away
ax_zs, ax_xy = show_apopto_surroundings(eptm, a_cell)
/home/guillaume/anaconda/envs/python3/lib/python3.4/site-packages/matplotlib-1.4.x-py3.4-linux-x86_64.egg/matplotlib/figure.py:1644: 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 "
lj.apoptosis_step(eptm, a_cell, **apopto_kwargs)
ax_zs, ax_xy = show_apopto_surroundings(eptm, a_cell)
Now let's do the above repeatidly
steps = 1
for sub_sequence in apopto_sequence:
for a_cell in sub_sequence:
lj.apoptosis_step(eptm, a_cell, **apopto_kwargs)
steps += 1
print('We did %i steps' % steps)
#new_jv = remove_cell(eptm, prev_first)
ax_zs, ax_xy = show_apopto_surroundings(eptm, a_cell)
We did 11 steps
eptm.graph.save(os.path.join(eptm.paths['xml'], 'before_elimination.xml'))
lj.post_apoptosis(eptm, a_cell, fold_cells, **post_kwargs)
2015-02-16 13:42:19,829 -leg_joint.epithelium -remove_cell -- INFO -new vertex 5123
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-10-2eae1288a09d> in <module>() ----> 1 lj.post_apoptosis(eptm, a_cell, fold_cells, **post_kwargs) /home/guillaume/Python/leg-joint/leg_joint/epithelium.py in new_func(self, *args, **kwargs) 509 ''' 510 def new_func(self, *args, **kwargs): --> 511 out = func(self, *args, **kwargs) 512 store = self.paths['hdf'] 513 try: /home/guillaume/Python/leg-joint/leg_joint/graph_representation.py in new_func(eptm, *args, **kwargs) 56 def png_snapshot(func, *args, **kwargs): 57 def new_func(eptm, *args, **kwargs): ---> 58 out = func(eptm, *args, **kwargs) 59 png_dir = eptm.paths['png'] 60 outfname2d = os.path.join(png_dir, 'eptm2d_%04i.png' /home/guillaume/Python/leg-joint/leg_joint/apoptosis.py in post_apoptosis(eptm, a_cell, fold_cells, mode, **kwargs) 240 if (not je in new_edges) 241 and eptm.is_junction_edge[je]]) --> 242 new_jv = remove_cell(eptm, a_cell) 243 find_energy_min_pd(eptm, local=False) 244 /home/guillaume/Python/leg-joint/leg_joint/topology.py in remove_cell(eptm, cell) 510 511 for neighb_cell, jv in new_ctojs: --> 512 ctoj = eptm.new_edge(neighb_cell, jv, ctojs[0]) 513 eptm.set_local_mask(neighb_cell) 514 for jv0, jv1 in new_jes: /home/guillaume/Python/leg-joint/leg_joint/filters.py in new_edge(self, vertex0, vertex1, source_edge) 223 def new_edge(self, vertex0, vertex1, source_edge): 224 if self.any_edge(vertex0, vertex1) is None: --> 225 new_edge = self.graph.add_edge(vertex0, vertex1) 226 for prop in self.graph.edge_properties.values(): 227 prop[new_edge] = prop[source_edge] /home/guillaume/anaconda/envs/python3/lib/python3.4/site-packages/graph_tool/__init__.py in add_edge(self, source, target) 1481 self.__check_perms("add_edge") 1482 e = libcore.add_edge(weakref.ref(self), self.vertex(int(source)), -> 1483 self.vertex(int(target))) 1484 efilt = self.get_edge_filter() 1485 if efilt[0] is not None: TypeError: No registered converter was able to extract a C++ reference to type graph_tool::PythonVertex from this Python object of type NoneType
eptm.graph.save(os.path.join(eptm.paths['xml'], 'after_elimination.xml'))
lj.running_local_optimum(eptm, tol=1e-3)
eptm.set_local_mask(None)
for neighbour in neighbours:
eptm.set_local_mask(neighbour, wider=True)
eptm.graph.set_edge_filter(eptm.is_local_edge)
eptm.update_rhotheta()
depth = eptm.dzeds.copy()
for edge in eptm.graph.edges():
depth[edge] = (eptm.rhos[edge.source()]
+ eptm.rhos[edge.target()]) / 2.
depth.a -= depth.fa.min()
eptm.graph.set_edge_filter(None)
axes = lj.plot_2pannels(eptm,
cell_kwargs={'c_text':False},
edge_kwargs={'edge_color':depth, 'alpha':0.8})