%run nb_init.py import IPython.core.display as disp %matplotlib inline disp.SVG(lj.data.get_image('one_cell.svg')) disp.SVG(lj.data.get_image('geometrie.svg')) eptm = lj.Epithelium(graphXMLfile=lj.data.before_apoptosis_xml(), save_dir='saved_graphs', identifier='tuto', copy=True) print(eptm) eptm.graph.list_properties() eptm.paths output3d = os.path.join(eptm.paths['png'], 'tissue_3d.png') output2d = os.path.join(eptm.paths['png'], 'tissue_2d.png') lj.draw(eptm, output3d=output3d, output2d=output2d) disp.Image(filename=output3d) disp.Image(filename='../doc/imgs/tissue_2d.png') eptm.graph.set_vertex_filter(None) ## The number of side is equal to the number of junction vertices ## thus to the number of out neighbors of each cell num_sides = eptm.graph.degree_property_map('out') ## Filter living cells live_cells = eptm.is_alive.copy() live_cells.a *= eptm.is_cell_vert.a eptm.graph.set_vertex_filter(live_cells) ## Computing nomrmalized area normed_areas = eptm.cells.areas.fa / eptm.cells.areas.fa.mean() ## Getting the numbr of sides only for living cells num_sides = np.asarray(num_sides.fa) u_num_sides = np.unique(num_sides) ## Plotting it all avg_areas = np.zeros(u_num_sides.size) stm_areas = np.zeros(u_num_sides.size) bins, n_cells = np.histogram(num_sides, bins=11, range=(0, 11)) for n, n_sides in enumerate(u_num_sides): avg_areas[n] = normed_areas[num_sides == n_sides].mean() stm_areas[n] = normed_areas[num_sides == n_sides].std() / np.sqrt(n_cells[np.int(n_sides)]) fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, figsize=(6, 6)) ax1.plot(num_sides, normed_areas, 'o', alpha=0.05) ax1.errorbar(u_num_sides, avg_areas, yerr=stm_areas, lw=2, elinewidth=2) ax1.set_xlim(0, 12) ax2.hist(num_sides, bins=11, range=(0.5, 11.5), normed=True, color='g', alpha=0.7) ax2.set_xlim(0, 12) eptm.graph.set_vertex_filter(None) ax2.set_xlabel('Number of cell neighbors') ax2.set_ylabel('Frequency') ax1.set_ylabel('Normalized cell area') plt.draw() fig.savefig(lj.data.get_image('tissue_geometry.svg'))