Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solving mesh collision #263

Merged
merged 40 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9db3ed7
Fix for Issues #261 - cell division failed at the border
sophietheis Nov 8, 2022
524696f
Fix Mesh creation
sophietheis Nov 9, 2022
4d7b918
Add 2D collision solver
sophietheis Nov 10, 2022
c08f4f2
Update README.md
sophietheis Nov 11, 2022
934610d
Generalised wich vertex penetrate face
sophietheis Nov 11, 2022
fa64a25
Attempt to set out particular cases
sophietheis Nov 11, 2022
85eb93d
Detect and fix self-crossing face
sophietheis Nov 14, 2022
a041e9b
Use `.apply()`
sophietheis Nov 14, 2022
febed0f
ENH: write `mean_XX` method in `Epithelium` class (Issue #224)
sophietheis Nov 15, 2022
2be7b6d
Fix according to comments
sophietheis Nov 15, 2022
3ce763b
Fix Issue #258 ax argument not considered in `plt_draw.sheet_view`
sophietheis Nov 15, 2022
a23f656
ENH: pass column name to `data_at_opposite` issue (#245)
sophietheis Nov 15, 2022
ad7a335
Add publication and remove bibtex reference
sophietheis Nov 16, 2022
d23e9f5
Add check face convexity
sophietheis Nov 16, 2022
ce67fa4
Use reset_index and code simplification
sophietheis Nov 16, 2022
48c6859
yAdd to_mesh function (issue #221) and some test
sophietheis Nov 17, 2022
f25763e
Remove the use of reset_index in face_self_intersect
sophietheis Nov 17, 2022
47d36fc
use ipv_draw with 2D data
sophietheis Nov 18, 2022
6840f29
Fix solution after detection point inside polygon
sophietheis Nov 18, 2022
c41b940
Remove solving collision for 2 same face...
sophietheis Nov 18, 2022
aca8e18
Abord vertex displacement if it creates twisted face
sophietheis Nov 23, 2022
430dd38
New way to calculate the position of "penetrate" vertices
sophietheis Nov 24, 2022
c1757b7
WIP - use force field to fix collision
sophietheis Nov 28, 2022
aa21e9e
Small fix
sophietheis Nov 29, 2022
a7772b6
Remove function duplication due to circular import
sophietheis Dec 9, 2022
73aae18
Calculate "repulsion" gradient in the effector method. Remove loop
sophietheis Dec 12, 2022
bf53966
Fix tests
sophietheis Jan 3, 2023
dec83f0
Add lateralsheet shapes + test
sophietheis Feb 21, 2023
b168d59
Update publication + add collapse texte
sophietheis Feb 22, 2023
902fb72
Add test for Repulsion effector
sophietheis Feb 28, 2023
b0d3723
Add test update repulsion
sophietheis Feb 28, 2023
b226c31
Remove unused import
sophietheis Feb 28, 2023
5047751
Add `drop_face` to allow hole (issues #220 and #141) (associate #221)
sophietheis Feb 28, 2023
98b6e18
Update readme.md
sophietheis Mar 1, 2023
ebc1805
Update publications in README.md
sophietheis Mar 6, 2023
181edcd
Add `lineage` attribute to `Epithelium`
sophietheis Mar 7, 2023
455f1ca
Remove memory oscillation
sophietheis Jun 27, 2023
5ab02ef
dependency (#277)
glyg Dec 27, 2023
dc8521c
merge with main
glyg Dec 27, 2023
bcf9b7e
bug fixes
glyg Dec 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ dist/

## pytest
.pytest_cacheflycheck_*

.idea/
115 changes: 83 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This commit to the **new default branch `main` is the official start of the 1.0

<hr/>

<<<<<<< HEAD
=======

[![Doc Status](https://readthedocs.org/projects/tyssue/badge/?version=latest)](http://tyssue.readthedocs.io/en/latest/
)
Expand All @@ -36,33 +38,46 @@ This commit to the **new default branch `main` is the official start of the 1.0



>>>>>>> main
| Name | Downloads | Version | Platforms |
| --- | --- | --- | --- |
| [![Conda Recipe](https://img.shields.io/badge/recipe-tyssue-green.svg)](https://anaconda.org/conda-forge/tyssue) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/tyssue.svg)](https://anaconda.org/conda-forge/tyssue) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/tyssue.svg)](https://anaconda.org/conda-forge/tyssue) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/tyssue.svg)](https://anaconda.org/conda-forge/tyssue) |

# tyssue is now published in the Journal of Open Source Software!
| Coverage | Doc | CHAT |
| --- | --- | --- |
| [![Coverage Status](https://coveralls.io/repos/DamCB/tyssue/badge.svg)](https://coveralls.io/r/DamCB/tyssue) | [![Doc Status](https://readthedocs.org/projects/tyssue/badge/?version=latest)](http://tyssue.readthedocs.io/en/latest/) | [![Join the chat at https://gitter.im/DamCB/tyssue](https://badges.gitter.im/DamCB/tyssue.svg)](https://gitter.im/DamCB/tyssue?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |

[![DOI](https://joss.theoj.org/papers/10.21105/joss.02973/status.svg)](https://doi.org/10.21105/joss.02973)

# tyssue is now published in the Journal of Open Source Software!

| ZENODO DOI | JOSS DOI |
| --- | --- |
| [![DOI](https://zenodo.org/badge/32533164.svg)](https://zenodo.org/badge/latestdoi/32533164) | [![DOI](https://joss.theoj.org/papers/10.21105/joss.02973/status.svg)](https://doi.org/10.21105/joss.02973) |

The `tyssue` library seeks to provide a unified interface to implement
bio-mechanical models of living tissues.
biomechanical models of living tissues.
It's main focus is on **vertex based epithelium models**.

## Overview

### What kind of Models does it implement?

The first model implemented is the one described in
Monier et al. [monier2015apico]. It is an example of a vertex model,
Monier et al.<sup id="a1">[1](#f1)</sup>. It is an example of a vertex model,
where the interactions are only evaluated on the apical surface sheet
of the epithelium. The second class of models is still at an
of the epithelium. The second class of models is still at a
stage. They implement a description of the tissue's rheology, within a
dissipation function formalism.

![The two models considered](doc/illus/two_models.png)

### What kind of geometry does it model ?
`tyssue` allows to model different geometries in 2D and in 3D. Presentation of the different geometries and how to create them are shown in this [notebook](https://github.com/DamCB/tyssue-demo/blob/master/01-Geometry.ipynb).
<p align="center">
<img src="doc/illus/geometry.png" width="500">
</p>


### General Structure of the modeling API

#### Design principles
Expand All @@ -71,7 +86,7 @@ dissipation function formalism.

Each biological question, be it in morphogenesis or cancer studies is
unique, and requires tweeking of the models developed by the
physicists. Most of the modelling softwares follow an architecture
physicists. Most of the modelling software follow an architecture
based on a core C++ engine with a combinaison of markup or scripting
capacities to run specific simulation.

Expand All @@ -82,13 +97,13 @@ possibilities as open as possible.
> Separate structure, geometry and models

We seek to have a design as modular as possible, to allow the same
epithlium mesh to be fed to different physical models.
epithelium mesh to be fed to different physical models.

> Accessible, easy to use data structures

The core of the tyssue library rests on two structures: a set of
`pandas DataFrame` holding the tissue geometry and associated data,
and nested dictionnaries holding the model parameters, variables and
and nested dictionaries holding the model parameters, variables and
default values.

![Tyssue data structure](doc/illus/tyssue_data_management.png)
Expand All @@ -100,7 +115,7 @@ methods to manipulate indexing of the dataframes to ease calculations.
The mesh structure is heavily inspired by
[CGAL Linear Cell Complexes](http://doc.cgal.org/latest/Linear_cell_complex/index.html),
most importantly, in the case of a 2D vertex sheet for example, each
junction edge between the cells is "splitted" between two oriented **half
junction edge between the cells is "splited" between two oriented **half
edges**.


Expand All @@ -121,27 +136,41 @@ sheet.sanitize()
fig, ax = sheet_view(sheet)
```

### Features

* Easy data manipulation.
* Multiple geometries (Sheets in 2D and 3D, monolayers, bulk).
* Easy to extend.
* 2D (matplotlib) and 3D (ipyvolume) customisable visualisation.
* Easy quasistatic model definition.
* Self collision detection. **new in 0.3**


### Documentation

* The documentation is now browsable on [tyssue.io](http://tyssue.io)
* The old documentation is still browsable online [here](http://tyssue.readthedocs.io/en/latest/)
* Introduction notebooks are available [here](https://github.com/DamCB/tyssue-demo).

## Visualisation
Thanks to @kephale, there is a napari plugin to visualise tyssue simulation output.
You can find it [here](https://github.com/kephale/napari-tyssue).


### What's new in 1.0 ?
* No collision in 2D (use effector `Repulsion`)
* Add new geometry : 2D lateral geometry
* Add mean calculation in `Epithelium`
* Add `sheet` conversion to `mesh` from `Meshio`
* Allow hole in 2D sheet
* Fix some visualisation

### Roadmap
You are welcome to participate in the development of `Tyssue`.
What is planned for the future of `Tyssue`?
* Solve collision in 2.5D & 3D
* Use ZARR instead of HDF5 as base file format
* Upgrade geometry creation
* Compound geometry to form complex shape
* Use biological image as blueprint
* Add rheology model
* Switch to github-action for continuous integration

### Mailing list:

[email protected] - https://framalistes.org/sympa/info/tyssue

Subscribe ➙ https://framalistes.org/sympa/subscribe/tyssue
Subscribe ➙ https://framalistes.org/sympa/subscribe/tyssue
Unsubscribe ➙ https://framalistes.org/sympa/sigrequest/tyssue


Expand All @@ -160,7 +189,9 @@ Unsubscribe ➙ https://framalistes.org/sympa/sigrequest/tyssue
As all the dependencies are already completely supported in
python 3.x, **we won't be maintaining a python 2.x version**, because
it's time to move on...

<details>
<summary>Show dependencies</summary>

### Core

- CGAL > 4.7
Expand All @@ -184,6 +215,9 @@ it's time to move on...
- coverage
- pytest-cov

</details>


## Install

You can install the library with the conda package manager
Expand All @@ -204,29 +238,42 @@ You can also install tyssue from PyPi, this is a CGAL-less version (pure python)

See [INSTALL.md](INSTALL.md) for a step by step install, including the necessary python environment.

## How to cite
If you find `tyssue` useful please cite [this repository](https://github.com/DamCB/tyssue) using its DOI as follows:

## Licence
> Theis, Suzanne, Gay, (2021). Tyssue: an epithelium simulation library. Journal of Open Source Software, 6(62), 2973 doi:[https://doi.org/10.21105/joss.02973](https://doi.org/10.21105/joss.02973)
>
> Zenodo doi:10.5281/zenodo.4817609

Since version 0.3, this project is distributed under the terms of the [General Public Licence](https://www.gnu.org/licenses/gpl.html).
## Publications
If `tyssue` has made a substantial contribution to your work, please edit this file and open a PR.

Lou Y, Rupprecht JF, Theis S, Hiraiwa T, and Saunders TE. Curvature-induced cell rearrangements in biological tissues. Phys. Rev. Lett. 2023. doi: [10.1103/PhysRevLett.130.108401](https://doi.org/10.1103/PhysRevLett.130.108401)

Versions 2.4 and earlier were distributed under the [Mozilla Public Licence](https://www.mozilla.org/en-US/MPL/2.0/).
Rahman T, Peters F and Wan LQ. Cell Jamming Regulates Epithelial Chiral Morphogenesis. J Biomech. 2023. doi: [10.1016/j.jbiomech.2023.111435](https://doi.org/10.1016/j.jbiomech.2023.111435)

If GPL licencing is too restrictive for your intended usage, please contact the maintainer.
Fiorentino J and Scialdone A. The role of cell geometry and cell-cell communication in gradient sensing. PLoS Comput Biol. 2022 doi: [10.1371/journal.pcbi.1009552](10.1371/journal.pcbi.1009552)
Related repository: [https://github.com/ScialdoneLab/2DLEGI](https://github.com/ScialdoneLab/2DLEGI)

sophietheis marked this conversation as resolved.
Show resolved Hide resolved
## Bibliography
Courcoubetis G, Xu C, Nuzhdin SV, Haas S. Avalanches during epithelial tissue growth; Uniform Growth and a drosophila eye disc model, PLoS Comput Biol 2022 doi: [10.1371/journal.pcbi.1009952](https://doi.org/10.1371/journal.pcbi.1009952)

* There is a [Bibtex file here](doc/bibliography/tyssue.bib) with collected relevant publications.
Martin E, Theis S, Gay G, Monier B, Rouvière C, Suzanne M. Arp2/3-dependent mechanical control of morphogenetic robustness in an inherently challenging environment. Dev Cell. 2021 doi: [10.1016/j.devcel.2021.01.005](https://doi.org/10.1016/j.devcel.2021.01.005)
Related repository: [https://github.com/suzannelab/polarity](https://github.com/suzannelab/polarity)

The tyssue library stemed from a refactoring of the `leg-joint` code used in [monier2015apico].
Gracia M, Theis S, Proag A, Gay G, Benassayag C, Suzanne M. Mechanical impact of epithelial-mesenchymal transition on epithelial morphogenesis in Drosophila. Nat Commun. 2019 doi: [10.1038/s41467-019-10720-0](https://doi.org/10.1038/s41467-019-10720-0)
Related repository: [https://github.com/suzannelab/invagination](https://github.com/suzannelab/invagination)

Monier B, Gettings M, Gay G, Mangeat T, Schott S, Guarner A, Suzanne M. Apico-basal forces exerted by apoptotic cells drive epithelium folding. Nature. 2015 doi: [10.1038/nature14152](https://doi.org/10.1038/nature14152)
Related repository: [https://github.com/glyg/leg-joint](https://github.com/glyg/leg-joint)

## Licence

Since version 0.3, this project is distributed under the terms of the [General Public Licence](https://www.gnu.org/licenses/gpl.html).

[monier2015apico]: Monier, B. et al. Apico-basal forces exerted by
apoptotic cells drive epithelium folding. Nature 518, 245–248 (2015).

[Tamulonis2013]: Tamulonis, C. Cell-based models. (Universiteit ven Amsterdam, 2013). doi:10.1177/1745691612459060.
Versions 2.4 and earlier were distributed under the [Mozilla Public Licence](https://www.mozilla.org/en-US/MPL/2.0/).

[Tlili2013]: Tlili,S. et al. Mechanical formalism for tissue dynamics. 6, 23 (2013).
If GPL licencing is too restrictive for your intended usage, please contact the maintainer.

## Research notice
Please note that this repository is participating in a study into sustainability
Expand All @@ -238,3 +285,7 @@ Data collected will include number of contributors, number of PRs, time taken to

For more information, please visit
[our informational page](https://sustainable-open-science-and-software.github.io/) or download our [participant information sheet](https://sustainable-open-science-and-software.github.io/assets/PIS_sustainable_software.pdf).

<hr/>

<b id="f1">1</b> : Monier B, Gettings M, Gay G, Mangeat T, Schott S, Guarner A, Suzanne M. Apico-basal forces exerted by apoptotic cells drive epithelium folding. Nature. 2015 doi: [10.1038/nature14152](https://doi.org/10.1038/nature14152) [↩](#a1)
11 changes: 11 additions & 0 deletions doc/bibliography/tyssue.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4301,4 +4301,15 @@ @article{zhaoModelingTumorClonal2016
file = {/home/guillaume/Zotero/storage/EDFS69XJ/Zhao et al. - 2016 - Modeling Tumor Clonal Evolution for Drug Combinati.pdf}
}

@article{rahman_cell_2022,
title = {Cell Jamming Regulates Epithelial Chiral Morphogenesis},
url = {https://papers.ssrn.com/abstract=4052248},
doi = {10.2139/ssrn.4052248},
number = {4052248},
author = {Rahman, Tasnif and Wan, Leo Q.},
urldate = {2022-11-15},
date = {2022-03-08},
keywords = {cell chirality, cell vertex model, epithelium, left-right asymmetry},
}

@preamble{ "\ifdefined\DeclarePrefChars\DeclarePrefChars{'’-}\else\fi " }
Binary file added doc/illus/geometry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
- notebook
- quantities
- ipython
- ipython_genutils
- ipywidgets
- pythreejs
- ipyvolume
Expand Down
54 changes: 54 additions & 0 deletions tests/collisions/test_sheet_collision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from pathlib import Path

from tyssue import Sheet, SheetGeometry, collisions
from tyssue.collisions import solvers
from tyssue.io import hdf5
from tyssue.stores import stores_dir


def test_detection():
sheet = Sheet("crossed", hdf5.load_datasets(Path(stores_dir) / "sheet6x5.hf5"))
sheet.vert_df.z = 5 * sheet.vert_df.x ** 2
# sheet.vert_df[sheet.coords] += np.random.normal(scale=0.001, size=(sheet.Nv, 3))
SheetGeometry.update_all(sheet)

sheet.vert_df.x -= 35 * (sheet.vert_df.x / 2) ** 3
SheetGeometry.update_all(sheet)
colliding_edges = set(collisions.self_intersections(sheet).flatten())

expected = {0, 1, 5, 6, 9, 32, 34, 35, 83, 84, 152, 153}
assert colliding_edges == expected


# def test_solving():
#
# sheet = Sheet("crossed", hdf5.load_datasets(Path(stores_dir) / "sheet6x5.hf5"))
# sheet.vert_df.z = 5 * sheet.vert_df.x**2
# SheetGeometry.update_all(sheet)
# positions_buffer = sheet.vert_df[sheet.coords].copy()
#
# sheet.vert_df.x -= 35 * (sheet.vert_df.x / 2) ** 3
# SheetGeometry.update_all(sheet)
# colliding_edges = collisions.self_intersections(sheet)
# boxes = solvers.CollidingBoxes(sheet, positions_buffer, colliding_edges)
# boxes.solve_collisions(shyness=0.01)
# assert collisions.self_intersections(sheet).size == 0
# assert sheet.vert_df.loc[[22, 12], "x"].diff().loc[12] == 0.01


# def test_already():
# # GH111
# sheet = Sheet("crossed", hdf5.load_datasets(Path(stores_dir) / "sheet6x5.hf5"))
# sheet.vert_df.z = 5 * sheet.vert_df.x**2
# SheetGeometry.update_all(sheet)

# sheet.vert_df.x -= 35 * (sheet.vert_df.x / 2) ** 3
# SheetGeometry.update_all(sheet)
# positions_buffer = sheet.vert_df[sheet.coords].copy()
# sheet.vert_df.x -= 0.1 * (sheet.vert_df.x / 2) ** 3
# SheetGeometry.update_all(sheet)
# colliding_edges = collisions.self_intersections(sheet)
# boxes = solvers.CollidingBoxes(sheet, positions_buffer, colliding_edges)
# boxes.solve_collisions(shyness=0.01)
# colliding_edges = collisions.self_intersections(sheet)
# assert len(colliding_edges) == 0
21 changes: 21 additions & 0 deletions tests/core/test_lateralsheet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# from numpy.testing import assert_almost_equal

# from tyssue import PlanarGeometry
# from tyssue.generation.shapes import (
# generate_lateral_tissue
# )

# def test_lateralsheet():

# sheet = generate_lateral_tissue(15, 15, 2)
# PlanarGeometry.update_all(sheet)
# apical_length = sheet.edge_df.loc[sheet.apical_edges, "length"]
# basal_length = sheet.edge_df.loc[sheet.basal_edges, "length"]
# lateral_length = sheet.edge_df.loc[sheet.lateral_edges, "length"]

# assert sheet.Nf == 15
# assert sheet.Ne == 60
# assert sheet.Nv == 32
# assert_almost_equal(apical_length.mean(), 1)
# assert_almost_equal(basal_length.mean(), 1)
# assert_almost_equal(lateral_length.mean(), 2)
12 changes: 6 additions & 6 deletions tests/core/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,12 +1012,12 @@ def test_ordered_edges():

res_edges_2d = _ordered_edges(eptm.edge_df.loc[eptm.edge_df["face"] == 0])
expected_edges_2d = [
[0, 1, 0],
[1, 2, 0],
[2, 3, 0],
[3, 4, 0],
[4, 5, 0],
[5, 0, 0],
[0, 1, 0, 0],
[1, 2, 0, 1],
[2, 3, 0, 2],
[3, 4, 0, 3],
[4, 5, 0, 4],
[5, 0, 0, 5],
]
expected_vert_idxs = [idxs[0] for idxs in expected_edges_2d]
assert res_edges_2d == expected_edges_2d
Expand Down
Loading