|
24 | 24 | }, |
25 | 25 | { |
26 | 26 | "cell_type": "code", |
27 | | - "execution_count": 1, |
| 27 | + "execution_count": 19, |
28 | 28 | "metadata": {}, |
29 | 29 | "outputs": [], |
30 | 30 | "source": [ |
|
42 | 42 | }, |
43 | 43 | { |
44 | 44 | "cell_type": "code", |
45 | | - "execution_count": 2, |
| 45 | + "execution_count": 20, |
46 | 46 | "metadata": {}, |
47 | 47 | "outputs": [ |
48 | 48 | { |
|
118 | 118 | }, |
119 | 119 | { |
120 | 120 | "cell_type": "code", |
121 | | - "execution_count": 3, |
| 121 | + "execution_count": 21, |
122 | 122 | "metadata": {}, |
123 | 123 | "outputs": [], |
124 | 124 | "source": [ |
125 | 125 | "age_prop = pc.Property(\n", |
126 | 126 | " identifier=\"age\",\n", |
127 | 127 | " name=\"age\",\n", |
128 | | - " description=\"Age of the cell since the beginning of the lineage\",\n", |
| 128 | + " description=\"Age of the cell since the start of the lineage\",\n", |
129 | 129 | " provenance=\"custom\",\n", |
130 | 130 | " prop_type=\"node\",\n", |
131 | 131 | " lin_type=\"CellLineage\",\n", |
|
143 | 143 | }, |
144 | 144 | { |
145 | 145 | "cell_type": "code", |
146 | | - "execution_count": 4, |
| 146 | + "execution_count": 22, |
147 | 147 | "metadata": {}, |
148 | 148 | "outputs": [ |
149 | 149 | { |
150 | 150 | "name": "stdout", |
151 | 151 | "output_type": "stream", |
152 | 152 | "text": [ |
153 | | - "age: Age of the cell since the beginning of the lineage in frame(s)\n" |
| 153 | + "age: Age of the cell since the start of the lineage in frame(s)\n" |
154 | 154 | ] |
155 | 155 | } |
156 | 156 | ], |
|
192 | 192 | }, |
193 | 193 | { |
194 | 194 | "cell_type": "code", |
195 | | - "execution_count": 5, |
| 195 | + "execution_count": 23, |
196 | 196 | "metadata": {}, |
197 | 197 | "outputs": [], |
198 | 198 | "source": [ |
|
267 | 267 | }, |
268 | 268 | { |
269 | 269 | "cell_type": "code", |
270 | | - "execution_count": 6, |
| 270 | + "execution_count": 24, |
271 | 271 | "metadata": {}, |
272 | 272 | "outputs": [], |
273 | 273 | "source": [ |
|
304 | 304 | }, |
305 | 305 | { |
306 | 306 | "cell_type": "code", |
307 | | - "execution_count": 7, |
| 307 | + "execution_count": 25, |
308 | 308 | "metadata": {}, |
309 | 309 | "outputs": [], |
310 | 310 | "source": [ |
|
322 | 322 | }, |
323 | 323 | { |
324 | 324 | "cell_type": "code", |
325 | | - "execution_count": 8, |
| 325 | + "execution_count": 26, |
326 | 326 | "metadata": {}, |
327 | 327 | "outputs": [ |
328 | 328 | { |
|
2507 | 2507 | "autorange": "reversed", |
2508 | 2508 | "showgrid": true, |
2509 | 2509 | "title": { |
2510 | | - "text": "Time (frames)" |
| 2510 | + "text": "Time (timepoints)" |
2511 | 2511 | }, |
2512 | 2512 | "zeroline": true |
2513 | 2513 | } |
|
2539 | 2539 | }, |
2540 | 2540 | { |
2541 | 2541 | "cell_type": "code", |
2542 | | - "execution_count": 9, |
| 2542 | + "execution_count": 27, |
2543 | 2543 | "metadata": {}, |
2544 | 2544 | "outputs": [], |
2545 | 2545 | "source": [ |
|
2577 | 2577 | }, |
2578 | 2578 | { |
2579 | 2579 | "cell_type": "code", |
2580 | | - "execution_count": 10, |
| 2580 | + "execution_count": 28, |
2581 | 2581 | "metadata": {}, |
2582 | 2582 | "outputs": [], |
2583 | 2583 | "source": [ |
|
2602 | 2602 | }, |
2603 | 2603 | { |
2604 | 2604 | "cell_type": "code", |
2605 | | - "execution_count": 11, |
| 2605 | + "execution_count": 29, |
2606 | 2606 | "metadata": { |
2607 | 2607 | "tags": [ |
2608 | 2608 | "raises-exception" |
|
2616 | 2616 | "traceback": [ |
2617 | 2617 | "\u001b[31m---------------------------------------------------------------------------\u001b[39m", |
2618 | 2618 | "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", |
2619 | | - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[11]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m calc = ParityCalculator_incorrect(prop_incorrect)\n\u001b[32m 2\u001b[39m model.add_custom_property(calc)\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[43mmodel\u001b[49m\u001b[43m.\u001b[49m\u001b[43mupdate\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", |
2620 | | - "\u001b[36mFile \u001b[39m\u001b[32m/media/lxenard/data/Code/pycellin/pycellin/pycellin/classes/model.py:575\u001b[39m, in \u001b[36mModel.update\u001b[39m\u001b[34m(self, props_to_update)\u001b[39m\n\u001b[32m 567\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[32m 569\u001b[39m \u001b[38;5;66;03m# self.data._freeze_lineage_data()\u001b[39;00m\n\u001b[32m 570\u001b[39m \n\u001b[32m 571\u001b[39m \u001b[38;5;66;03m# TODO: need to handle all the errors that can be raised\u001b[39;00m\n\u001b[32m 572\u001b[39m \u001b[38;5;66;03m# by the updater methods to avoid incoherent states.\u001b[39;00m\n\u001b[32m 573\u001b[39m \u001b[38;5;66;03m# => saving a copy of the model before the update so we can roll back?\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m575\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_updater\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_update\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mprops_to_update\u001b[49m\u001b[43m)\u001b[49m\n", |
2621 | | - "\u001b[36mFile \u001b[39m\u001b[32m/media/lxenard/data/Code/pycellin/pycellin/pycellin/classes/updater.py:194\u001b[39m, in \u001b[36mModelUpdater._update\u001b[39m\u001b[34m(self, data, props_to_update)\u001b[39m\n\u001b[32m 190\u001b[39m \u001b[38;5;66;03m# Recompute the properties as needed.\u001b[39;00m\n\u001b[32m 191\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m calc \u001b[38;5;129;01min\u001b[39;00m cell_calculators:\n\u001b[32m 192\u001b[39m \u001b[38;5;66;03m# Depending on the class of the calculator, a different version of\u001b[39;00m\n\u001b[32m 193\u001b[39m \u001b[38;5;66;03m# the enrich() method is called.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m194\u001b[39m \u001b[43mcalc\u001b[49m\u001b[43m.\u001b[49m\u001b[43menrich\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 195\u001b[39m \u001b[43m \u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 196\u001b[39m \u001b[43m \u001b[49m\u001b[43mnodes_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_added_cells\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 197\u001b[39m \u001b[43m \u001b[49m\u001b[43medges_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_added_links\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 198\u001b[39m \u001b[43m \u001b[49m\u001b[43mlineages_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_added_lineages\u001b[49m\u001b[43m \u001b[49m\u001b[43m|\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_modified_lineages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 199\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 201\u001b[39m \u001b[38;5;66;03m# In case of modifications in the structure of some cell lineages,\u001b[39;00m\n\u001b[32m 202\u001b[39m \u001b[38;5;66;03m# we need to recompute the cycle lineages and their properties.\u001b[39;00m\n\u001b[32m 203\u001b[39m \u001b[38;5;66;03m# TODO: optimize so we don't have to recompute EVERYTHING for cycle lineages?\u001b[39;00m\n\u001b[32m 204\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m lin_ID \u001b[38;5;129;01min\u001b[39;00m (\u001b[38;5;28mself\u001b[39m._modified_lineages | \u001b[38;5;28mself\u001b[39m._added_lineages) - \u001b[38;5;28mself\u001b[39m._removed_lineages:\n", |
| 2619 | + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[29]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m calc = ParityCalculator_incorrect(prop_incorrect)\n\u001b[32m 2\u001b[39m model.add_custom_property(calc)\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[43mmodel\u001b[49m\u001b[43m.\u001b[49m\u001b[43mupdate\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n", |
| 2620 | + "\u001b[36mFile \u001b[39m\u001b[32m/media/lxenard/data/Code/pycellin/pycellin/pycellin/classes/model.py:910\u001b[39m, in \u001b[36mModel.update\u001b[39m\u001b[34m(self, props_to_update)\u001b[39m\n\u001b[32m 903\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m time_step \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m 904\u001b[39m \u001b[38;5;66;03m# TODO: add \"see documentation\" to the error message or explain\u001b[39;00m\n\u001b[32m 905\u001b[39m \u001b[38;5;66;03m# directly how to set it?\u001b[39;00m\n\u001b[32m 906\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 907\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mThe time step of the model is currently not defined \u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 908\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mbut is required for cycle lineage computation.\u001b[39m\u001b[33m\"\u001b[39m\n\u001b[32m 909\u001b[39m )\n\u001b[32m--> \u001b[39m\u001b[32m910\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_updater\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_update\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 911\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 912\u001b[39m \u001b[43m \u001b[49m\u001b[43mtime_prop\u001b[49m\u001b[43m=\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mmodel_metadata\u001b[49m\u001b[43m.\u001b[49m\u001b[43mreference_time_property\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 913\u001b[39m \u001b[43m \u001b[49m\u001b[43mtime_step\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtime_step\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 914\u001b[39m \u001b[43m \u001b[49m\u001b[43mprops_to_update\u001b[49m\u001b[43m=\u001b[49m\u001b[43mprops_to_update\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 915\u001b[39m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n", |
| 2621 | + "\u001b[36mFile \u001b[39m\u001b[32m/media/lxenard/data/Code/pycellin/pycellin/pycellin/classes/updater.py:280\u001b[39m, in \u001b[36mModelUpdater._update\u001b[39m\u001b[34m(self, data, time_prop, time_step, props_to_update)\u001b[39m\n\u001b[32m 276\u001b[39m \u001b[38;5;66;03m# Recompute the properties as needed.\u001b[39;00m\n\u001b[32m 277\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m calc \u001b[38;5;129;01min\u001b[39;00m cell_calculators:\n\u001b[32m 278\u001b[39m \u001b[38;5;66;03m# Depending on the class of the calculator, a different version of\u001b[39;00m\n\u001b[32m 279\u001b[39m \u001b[38;5;66;03m# the enrich() method is called.\u001b[39;00m\n\u001b[32m--> \u001b[39m\u001b[32m280\u001b[39m \u001b[43mcalc\u001b[49m\u001b[43m.\u001b[49m\u001b[43menrich\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 281\u001b[39m \u001b[43m \u001b[49m\u001b[43mdata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 282\u001b[39m \u001b[43m \u001b[49m\u001b[43mnodes_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[43mnodes_to_process\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# self._added_cells,\u001b[39;49;00m\n\u001b[32m 283\u001b[39m \u001b[43m \u001b[49m\u001b[43medges_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[43medges_to_process\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# self._added_links,\u001b[39;49;00m\n\u001b[32m 284\u001b[39m \u001b[43m \u001b[49m\u001b[43mlineages_to_enrich\u001b[49m\u001b[43m=\u001b[49m\u001b[43mlins_to_process\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# self._added_lineages | self._modified_lineages\u001b[39;49;00m\n\u001b[32m 285\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 287\u001b[39m \u001b[38;5;66;03m# In case of modifications in the structure of some cell lineages,\u001b[39;00m\n\u001b[32m 288\u001b[39m \u001b[38;5;66;03m# we need to recompute the cycle lineages and their properties.\u001b[39;00m\n\u001b[32m 289\u001b[39m \u001b[38;5;66;03m# TODO: optimize so we don't have to recompute EVERYTHING for cycle lineages?\u001b[39;00m\n\u001b[32m 290\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m lin_ID \u001b[38;5;129;01min\u001b[39;00m lins_to_process:\n", |
2622 | 2622 | "\u001b[36mFile \u001b[39m\u001b[32m/media/lxenard/data/Code/pycellin/pycellin/pycellin/classes/property_calculator.py:181\u001b[39m, in \u001b[36mNodeLocalPropCalculator.enrich\u001b[39m\u001b[34m(self, data, nodes_to_enrich, **kwargs)\u001b[39m\n\u001b[32m 179\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m nid, lin_ID \u001b[38;5;129;01min\u001b[39;00m nodes_to_enrich:\n\u001b[32m 180\u001b[39m lin = lineages[lin_ID]\n\u001b[32m--> \u001b[39m\u001b[32m181\u001b[39m lin.nodes[nid][\u001b[38;5;28mself\u001b[39m.prop.identifier] = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mcompute\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlin\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnid\u001b[49m\u001b[43m)\u001b[49m\n", |
2623 | 2623 | "\u001b[31mTypeError\u001b[39m: ParityCalculator_incorrect.compute() takes 2 positional arguments but 3 were given" |
2624 | 2624 | ] |
|
2646 | 2646 | }, |
2647 | 2647 | { |
2648 | 2648 | "cell_type": "code", |
2649 | | - "execution_count": 12, |
| 2649 | + "execution_count": 30, |
2650 | 2650 | "metadata": {}, |
2651 | 2651 | "outputs": [], |
2652 | 2652 | "source": [ |
|
2672 | 2672 | }, |
2673 | 2673 | { |
2674 | 2674 | "cell_type": "code", |
2675 | | - "execution_count": 13, |
| 2675 | + "execution_count": 31, |
2676 | 2676 | "metadata": {}, |
2677 | 2677 | "outputs": [ |
2678 | 2678 | { |
|
2735 | 2735 | }, |
2736 | 2736 | { |
2737 | 2737 | "cell_type": "code", |
2738 | | - "execution_count": 14, |
| 2738 | + "execution_count": 32, |
2739 | 2739 | "metadata": {}, |
2740 | 2740 | "outputs": [], |
2741 | 2741 | "source": [ |
2742 | 2742 | "age_prop2 = pc.Property(\n", |
2743 | 2743 | " identifier=\"relative_age\",\n", |
2744 | 2744 | " name=\"relative age\",\n", |
2745 | | - " description=\"Age of the cell since the beginning of the current cell cycle\",\n", |
| 2745 | + " description=\"Age of the cell since the start of the current cell cycle\",\n", |
2746 | 2746 | " provenance=\"custom\",\n", |
2747 | 2747 | " prop_type=\"node\",\n", |
2748 | 2748 | " lin_type=\"CellLineage\",\n", |
|
2751 | 2751 | ")\n", |
2752 | 2752 | "\n", |
2753 | 2753 | "\n", |
2754 | | - "class RelativeAgeCalculator(pc.NodeGlobalPropCalculator):\n", |
| 2754 | + "class MyRelativeAgeCalculator(pc.NodeGlobalPropCalculator):\n", |
2755 | 2755 | " def __init__(self, property: pc.Property, time_step: float):\n", |
2756 | 2756 | " # Call the parent __init__ method.\n", |
2757 | 2757 | " super().__init__(property)\n", |
|
2781 | 2781 | }, |
2782 | 2782 | { |
2783 | 2783 | "cell_type": "code", |
2784 | | - "execution_count": 15, |
| 2784 | + "execution_count": 33, |
2785 | 2785 | "metadata": {}, |
2786 | 2786 | "outputs": [], |
2787 | 2787 | "source": [ |
2788 | | - "calc = RelativeAgeCalculator(age_prop2, model.get_time_step())\n", |
| 2788 | + "calc = MyRelativeAgeCalculator(age_prop2, model.get_time_step())\n", |
2789 | 2789 | "model.add_custom_property(calc)" |
2790 | 2790 | ] |
2791 | 2791 | }, |
2792 | 2792 | { |
2793 | 2793 | "cell_type": "code", |
2794 | | - "execution_count": 16, |
| 2794 | + "execution_count": 34, |
2795 | 2795 | "metadata": {}, |
2796 | 2796 | "outputs": [ |
2797 | 2797 | { |
|
4976 | 4976 | "autorange": "reversed", |
4977 | 4977 | "showgrid": true, |
4978 | 4978 | "title": { |
4979 | | - "text": "Time (frames)" |
| 4979 | + "text": "Time (timepoints)" |
4980 | 4980 | }, |
4981 | 4981 | "zeroline": true |
4982 | 4982 | } |
|
5001 | 5001 | }, |
5002 | 5002 | { |
5003 | 5003 | "cell_type": "code", |
5004 | | - "execution_count": 17, |
| 5004 | + "execution_count": 35, |
5005 | 5005 | "metadata": {}, |
5006 | 5006 | "outputs": [], |
5007 | 5007 | "source": [ |
|
5036 | 5036 | }, |
5037 | 5037 | { |
5038 | 5038 | "cell_type": "code", |
5039 | | - "execution_count": 18, |
| 5039 | + "execution_count": 36, |
5040 | 5040 | "metadata": {}, |
5041 | 5041 | "outputs": [ |
5042 | 5042 | { |
|
6199 | 6199 | ], |
6200 | 6200 | "source": [ |
6201 | 6201 | "model.add_cycle_data()\n", |
6202 | | - "# Division time is a Pycellin property, and it is needed to compute the growth rate.\n", |
6203 | | - "model.add_division_time(in_time_unit=True)\n", |
| 6202 | + "# Division time is a Pycellin property, and it is needed to compute the growth rate,\n", |
| 6203 | + "# see line 23 in the code above.\n", |
| 6204 | + "model.add_division_time()\n", |
6204 | 6205 | "model.add_custom_property(GrowthRateCalculator(gr_prop))\n", |
6205 | 6206 | "model.update()\n", |
6206 | 6207 | "model.data.cycle_data[0].plot(node_hover_props=[\"cycle_ID\", \"growth_rate\"])" |
|
0 commit comments