LineageTree 1.8.0__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. lineagetree-2.0.3/PKG-INFO +130 -0
  2. {lineagetree-1.8.0 → lineagetree-2.0.3}/README.md +13 -35
  3. lineagetree-2.0.3/pyproject.toml +152 -0
  4. lineagetree-2.0.3/setup.cfg +4 -0
  5. lineagetree-2.0.3/src/LineageTree/__init__.py +30 -0
  6. lineagetree-2.0.3/src/LineageTree/legacy/export_csv.py +70 -0
  7. lineagetree-2.0.3/src/LineageTree/legacy/to_lineajea.py +30 -0
  8. lineagetree-2.0.3/src/LineageTree/legacy/to_motile.py +36 -0
  9. lineagetree-2.0.3/src/LineageTree/lineageTree.py +3550 -0
  10. lineagetree-2.0.3/src/LineageTree/lineageTreeManager.py +886 -0
  11. lineagetree-2.0.3/src/LineageTree/loaders.py +974 -0
  12. lineagetree-2.0.3/src/LineageTree/test/test_lineageTree.py +634 -0
  13. lineagetree-2.0.3/src/LineageTree/tree_approximation.py +488 -0
  14. lineagetree-2.0.3/src/LineageTree/utils.py +154 -0
  15. lineagetree-2.0.3/src/LineageTree.egg-info/PKG-INFO +130 -0
  16. lineagetree-2.0.3/src/LineageTree.egg-info/SOURCES.txt +28 -0
  17. lineagetree-2.0.3/src/LineageTree.egg-info/requires.txt +23 -0
  18. lineagetree-1.8.0/PKG-INFO +0 -156
  19. lineagetree-1.8.0/pyproject.toml +0 -77
  20. lineagetree-1.8.0/setup.cfg +0 -70
  21. lineagetree-1.8.0/src/LineageTree/__init__.py +0 -5
  22. lineagetree-1.8.0/src/LineageTree/lineageTree.py +0 -2723
  23. lineagetree-1.8.0/src/LineageTree/lineageTreeManager.py +0 -198
  24. lineagetree-1.8.0/src/LineageTree/loaders.py +0 -896
  25. lineagetree-1.8.0/src/LineageTree/tree_styles.py +0 -334
  26. lineagetree-1.8.0/src/LineageTree/utils.py +0 -154
  27. lineagetree-1.8.0/src/LineageTree.egg-info/PKG-INFO +0 -156
  28. lineagetree-1.8.0/src/LineageTree.egg-info/SOURCES.txt +0 -17
  29. lineagetree-1.8.0/src/LineageTree.egg-info/requires.txt +0 -28
  30. lineagetree-1.8.0/test/test_lineageTree.py +0 -298
  31. {lineagetree-1.8.0 → lineagetree-2.0.3}/LICENSE +0 -0
  32. {lineagetree-1.8.0 → lineagetree-2.0.3/src/LineageTree}/test/test_uted.py +0 -0
  33. {lineagetree-1.8.0 → lineagetree-2.0.3}/src/LineageTree.egg-info/dependency_links.txt +0 -0
  34. {lineagetree-1.8.0 → lineagetree-2.0.3}/src/LineageTree.egg-info/top_level.txt +0 -0
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: LineageTree
3
+ Version: 2.0.3
4
+ Summary: Structure for Lineage Trees
5
+ Author: Giannis Liaskas, Christopher Mazzerbo
6
+ Author-email: Léo Guignard <leo.guignard@univ-amu.fr>
7
+ Maintainer-email: Léo Guignard <leo.guignard@univ-amu.fr>
8
+ License-Expression: MIT
9
+ Project-URL: Bug Tracker, https://github.com/GuignardLab/LineageTree/issues
10
+ Project-URL: Documentation, https://github.com/GuignardLab/LineageTree#README.md
11
+ Project-URL: Source Code, https://github.com/GuignardLab/LineageTree
12
+ Project-URL: User Support, https://github.com/GuignardLab/LineageTree/issues
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: scipy>=1.9
27
+ Requires-Dist: numpy>=1.23
28
+ Requires-Dist: mastodon-reader
29
+ Requires-Dist: matplotlib
30
+ Requires-Dist: edist
31
+ Requires-Dist: svgwrite
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: pytest-cov; extra == "dev"
35
+ Requires-Dist: tox; extra == "dev"
36
+ Requires-Dist: black; extra == "dev"
37
+ Requires-Dist: ruff; extra == "dev"
38
+ Requires-Dist: bumpver; extra == "dev"
39
+ Provides-Extra: doc
40
+ Requires-Dist: sphinx-rtd-theme; extra == "doc"
41
+ Requires-Dist: myst-parser; extra == "doc"
42
+ Requires-Dist: sphinx_book_theme; extra == "doc"
43
+ Provides-Extra: test
44
+ Requires-Dist: pytest; extra == "test"
45
+ Requires-Dist: pytest-cov; extra == "test"
46
+ Dynamic: license-file
47
+
48
+ # LineageTree
49
+
50
+ This library allows to import and work with cell (but not limited to cells) lineage trees.
51
+ With LineageTree you can read from:
52
+
53
+ - TGMM algorithm outputs described in [Amat et al. 2014](https://www.nature.com/articles/nmeth.3036)
54
+ - TrackMate files described in [Tinevez et al. 2017](https://doi.org/10.1016/j.ymeth.2016.09.016)
55
+ - MaMuT files described in [Wolff et al. 2018](https://doi.org/10.7554/eLife.34410)
56
+ - SVF algorithm outputs described in [McDole, Guignard et al. 2018](https://doi.org/10.1016/j.cell.2018.09.031)
57
+ - ASTEC algorithm outputs described in [Guignard, Fiuza et al. 2020](https://doi.org/10.1126/science.aar5663)
58
+ - Data from the [Digital development Database](http://digital-development.org/index.html) described in [Du et al. 2014](https://www.cell.com/fulltext/S0092-8674(13)01542-0) and [Du et al. 2015](https://www.sciencedirect.com/science/article/pii/S1534580715004876?via%3Dihub)
59
+ - and few others
60
+
61
+ ## Basic usage
62
+
63
+ Once installed the library can be called the following way (as an example):
64
+
65
+ ```python
66
+ from LineageTree import lineageTree
67
+ ```
68
+
69
+ and one can then load lineage trees the following way:
70
+
71
+ For `.lT` files:
72
+
73
+ ```python
74
+ lT = lineageTree.load('path/to/file.lT')
75
+ ```
76
+
77
+ For ASTEC data:
78
+
79
+ ```python
80
+ from LineageTree import read_from_ASTEC
81
+ lT = read_from_ASTEC('path/to/ASTEC.pkl')
82
+ ```
83
+
84
+ For MaMuT or TrackMate:
85
+
86
+ ```python
87
+ from LineageTree import read_from_mamut_xml
88
+ lT = read_from_mamut_xml('path/to/MaMuT.xml')
89
+ ```
90
+
91
+ For TGMM:
92
+
93
+ ```python
94
+ from LineageTree import read_from_tgmm_xml
95
+ lT = read_from_tgmm_xml('path/to/single_time_file{t:04d}.xml', tb=0, te=500)
96
+ ```
97
+
98
+ For Mastodon:
99
+
100
+ ```python
101
+ from LineageTree import read_from_mastodon
102
+ lT = read_from_mastodon('path/to/Mastodon.mastodon')
103
+ ```
104
+
105
+ or, for Mastodon csv file:
106
+
107
+ ```python
108
+ from LineageTree import read_from_mastodon_csv
109
+ lT = read_from_mastodon_csv(['path/to/nodes.csv', 'path/to/links.csv'])
110
+ ```
111
+
112
+ ## Quick install
113
+
114
+ To quickly install the library together with its dependencies one can run:
115
+
116
+ ```shell
117
+ pip install LineageTree
118
+ ```
119
+
120
+ or, for the latest version if you have cloned the directory:
121
+
122
+ ```shell
123
+ pip install .
124
+ ```
125
+
126
+ or for the latest version wihtout cloning the directory
127
+
128
+ ```shell
129
+ pip install git+https://github.com/leoguignard/LineageTree
130
+ ```
@@ -3,7 +3,7 @@
3
3
  This library allows to import and work with cell (but not limited to cells) lineage trees.
4
4
  With LineageTree you can read from:
5
5
 
6
- - TGMM algorithm outputs described in [Fernando et al. 2014](https://www.nature.com/articles/nmeth.3036)
6
+ - TGMM algorithm outputs described in [Amat et al. 2014](https://www.nature.com/articles/nmeth.3036)
7
7
  - TrackMate files described in [Tinevez et al. 2017](https://doi.org/10.1016/j.ymeth.2016.09.016)
8
8
  - MaMuT files described in [Wolff et al. 2018](https://doi.org/10.7554/eLife.34410)
9
9
  - SVF algorithm outputs described in [McDole, Guignard et al. 2018](https://doi.org/10.1016/j.cell.2018.09.031)
@@ -24,66 +24,44 @@ and one can then load lineage trees the following way:
24
24
  For `.lT` files:
25
25
 
26
26
  ```python
27
- lT = lineageTree('path/to/file.lT')
27
+ lT = lineageTree.load('path/to/file.lT')
28
28
  ```
29
29
 
30
30
  For ASTEC data:
31
31
 
32
32
  ```python
33
- lT = lineageTree('path/to/ASTEC.pkl', file_type='ASTEC')
33
+ from LineageTree import read_from_ASTEC
34
+ lT = read_from_ASTEC('path/to/ASTEC.pkl')
34
35
  ```
35
36
 
36
- or
37
+ For MaMuT or TrackMate:
37
38
 
38
39
  ```python
39
- lT = lineageTree('path/to/ASTEC.xml', file_type='ASTEC')
40
- ```
41
-
42
- For SVF:
43
-
44
- ```python
45
- lT = lineageTree('path/to/SVF.bin')
46
- ```
47
-
48
- For MaMuT:
49
-
50
- ```python
51
- lT = lineageTree('path/to/MaMuT.xml', file_type='MaMuT')
52
- ```
53
-
54
- For TrackMate:
55
-
56
- ```python
57
- lT = lineageTree('path/to/MaMuT.xml', file_type='TrackMate')
40
+ from LineageTree import read_from_mamut_xml
41
+ lT = read_from_mamut_xml('path/to/MaMuT.xml')
58
42
  ```
59
43
 
60
44
  For TGMM:
61
45
 
62
46
  ```python
63
- lT = lineageTree('path/to/single_time_file{t:04d}.xml', tb=0, te=500, file_type='TGMM')
47
+ from LineageTree import read_from_tgmm_xml
48
+ lT = read_from_tgmm_xml('path/to/single_time_file{t:04d}.xml', tb=0, te=500)
64
49
  ```
65
50
 
66
51
  For Mastodon:
67
52
 
68
53
  ```python
69
- lT = lineageTree('path/to/Mastodon.mastodon', file_type='mastodon')
54
+ from LineageTree import read_from_mastodon
55
+ lT = read_from_mastodon('path/to/Mastodon.mastodon')
70
56
  ```
71
57
 
72
58
  or, for Mastodon csv file:
73
59
 
74
60
  ```python
75
- lT = lineageTree(['path/to/nodes.csv', 'path/to/links.csv'], file_type='mastodon')
61
+ from LineageTree import read_from_mastodon_csv
62
+ lT = read_from_mastodon_csv(['path/to/nodes.csv', 'path/to/links.csv'])
76
63
  ```
77
64
 
78
- ## Dependencies
79
-
80
- Some dependecies are requiered:
81
-
82
- - general python dependecies:
83
- - numpy, scipy
84
- - specific dependency:
85
- - svgwrite if svg output is needed
86
-
87
65
  ## Quick install
88
66
 
89
67
  To quickly install the library together with its dependencies one can run:
@@ -0,0 +1,152 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools.packages.find]
6
+ where = ["src"]
7
+
8
+ [project]
9
+ authors = [
10
+ { name = "Léo Guignard", email = "leo.guignard@univ-amu.fr"},
11
+ { name = "Giannis Liaskas"},
12
+ { name = "Christopher Mazzerbo"},
13
+ ]
14
+ maintainers = [
15
+ {name = "Léo Guignard", email = "leo.guignard@univ-amu.fr"}
16
+ ]
17
+ name = "LineageTree"
18
+ description = "Structure for Lineage Trees"
19
+ version = "2.0.3"
20
+ license = "MIT"
21
+ license-files = [ "LICENSE" ]
22
+ readme = {file = "README.md", content-type = "text/markdown"}
23
+ requires-python = ">= 3.10"
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Intended Audience :: Developers",
27
+ "Operating System :: OS Independent",
28
+ "Programming Language :: Python",
29
+ "Programming Language :: Python :: 3",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.10",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ ]
36
+
37
+ dependencies = [
38
+ "scipy>=1.9",
39
+ "numpy>=1.23",
40
+ "mastodon-reader",
41
+ "matplotlib",
42
+ "edist",
43
+ "svgwrite",
44
+ ]
45
+
46
+ [project.optional-dependencies]
47
+ dev = [
48
+ "pytest",
49
+ "pytest-cov",
50
+ "tox",
51
+ "black",
52
+ "ruff",
53
+ "bumpver",
54
+ ]
55
+ doc = [
56
+ "sphinx-rtd-theme",
57
+ "myst-parser",
58
+ "sphinx_book_theme",
59
+ ]
60
+ test = [
61
+ "pytest",
62
+ "pytest-cov",
63
+ ]
64
+
65
+ [project.urls]
66
+ "Bug Tracker" = "https://github.com/GuignardLab/LineageTree/issues"
67
+ Documentation = "https://github.com/GuignardLab/LineageTree#README.md"
68
+ "Source Code" = "https://github.com/GuignardLab/LineageTree"
69
+ "User Support" = "https://github.com/GuignardLab/LineageTree/issues"
70
+
71
+ [tool.black]
72
+ line-length = 79
73
+
74
+ [tool.isort]
75
+ profile = "black"
76
+ line_length = 79
77
+
78
+ [tool.bumpver]
79
+ current_version = "2.0.3"
80
+ version_pattern = "MAJOR.MINOR.PATCH[-TAG]"
81
+ commit_message = "bump version {old_version} -> {new_version}"
82
+ commit = true
83
+ tag = true
84
+ push = false
85
+
86
+ [tool.bumpver.file_patterns]
87
+ "pyproject.toml" = [
88
+ 'current_version = "{version}"',
89
+ 'version = "{version}"',
90
+ ]
91
+ "src/LineageTree/__init__.py" = [
92
+ '__version__ = "{version}"',
93
+ ]
94
+
95
+ [tool.ruff]
96
+ line-length = 79
97
+ lint.select = [
98
+ "E", "F", "W", #flake8
99
+ "UP", # pyupgrade
100
+ "I", # isort
101
+ "BLE", # flake8-blind-exception
102
+ "B", # flake8-bugbear
103
+ "A", # flake8-builtins
104
+ "C4", # flake8-comprehensions
105
+ "ISC", # flake8-implicit-str-concat
106
+ "G", # flake8-logging-format
107
+ "PIE", # flake8-pie
108
+ "SIM", # flake8-simplify
109
+ "I", # imports
110
+ "T201", # print statements
111
+ "ERA001", #commented out code
112
+ ]
113
+ lint.ignore = [
114
+ "E501", # line too long. let black handle this
115
+ "SIM300", # yoda conditions
116
+ ]
117
+
118
+ exclude = [
119
+ ".bzr",
120
+ ".direnv",
121
+ ".eggs",
122
+ ".git",
123
+ ".mypy_cache",
124
+ ".pants.d",
125
+ ".ruff_cache",
126
+ ".svn",
127
+ ".tox",
128
+ ".venv",
129
+ "__pypackages__",
130
+ "_build",
131
+ "buck-out",
132
+ "build",
133
+ "dist",
134
+ "node_modules",
135
+ "venv",
136
+ "*vendored*",
137
+ "*_vendor*",
138
+ ]
139
+
140
+ target-version = "py310"
141
+
142
+ [tool.ty.src]
143
+ root = "./src"
144
+
145
+ [tool.ty.rules]
146
+ unresolved-import = "ignore"
147
+
148
+ [tool.pytest.ini_options]
149
+ addopts = "--cov"
150
+
151
+ [report]
152
+ show_missing=true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,30 @@
1
+ __version__ = "2.0.3"
2
+ from .lineageTree import lineageTree
3
+ from .lineageTreeManager import lineageTreeManager
4
+ from .loaders import (
5
+ read_from_ASTEC,
6
+ read_from_binary,
7
+ read_from_csv,
8
+ read_from_mamut_xml,
9
+ read_from_mastodon,
10
+ read_from_mastodon_csv,
11
+ read_from_tgmm_xml,
12
+ read_from_txt_for_celegans,
13
+ read_from_txt_for_celegans_BAO,
14
+ read_from_txt_for_celegans_CAO,
15
+ )
16
+
17
+ __all__ = (
18
+ "lineageTree",
19
+ "lineageTreeManager",
20
+ "read_from_tgmm_xml",
21
+ "read_from_txt_for_celegans_BAO",
22
+ "read_from_ASTEC",
23
+ "read_from_binary",
24
+ "read_from_csv",
25
+ "read_from_mamut_xml",
26
+ "read_from_mastodon_csv",
27
+ "read_from_mastodon",
28
+ "read_from_txt_for_celegans",
29
+ "read_from_txt_for_celegans_CAO",
30
+ )
@@ -0,0 +1,70 @@
1
+ import csv
2
+
3
+ from lineageTree import lineageTree
4
+
5
+ """Writes a lineage tree into a series of csv files.
6
+
7
+ * spots.csv: id; label; timePoint; x; y; z; volume
8
+ * links.csv: source spot id; target spot id
9
+ * fates1.csv: tagValue
10
+ * fate_values1.csv: spot id; tagValue
11
+ * fates2.csv: tagValue
12
+ * fate_values2.csv: spot id; tagValue
13
+ * fates3.csv: tagValue
14
+ * fate_values3.csv: spot id; tagValue
15
+ """
16
+
17
+
18
+ def export_to_csv():
19
+ tree = lineageTree("Astec-Pm10_properties.pkl", file_type="ASTEC")
20
+
21
+ spots = [["id", "label", "timePoint", "x", "y", "z", "volume"]]
22
+ for node_id in tree.nodes:
23
+ cell_name = tree["cell_name"].get(node_id, "unknown")
24
+ spots.append(
25
+ [
26
+ node_id,
27
+ cell_name,
28
+ tree.time.get(node_id),
29
+ tree.pos[node_id][0],
30
+ tree.pos[node_id][1],
31
+ tree.pos[node_id][2],
32
+ tree.volume[node_id],
33
+ ]
34
+ )
35
+ write("spots.csv", spots)
36
+
37
+ links = [["source", "target"]]
38
+ for edge in tree.edges:
39
+ links.append([edge[0], edge[1]])
40
+ write("links.csv", links)
41
+
42
+ write_fate(tree.fates, "fates1.csv", tree, "fate_values1.csv")
43
+ write_fate(tree["cell_fate_2"], "fates2.csv", tree, "fate_values2.csv")
44
+ write_fate(tree["cell_fate_3"], "fates3.csv", tree, "fate_values3.csv")
45
+
46
+
47
+ def write_fate(fates, fate_name, tree, fate_value_name):
48
+ all_fates = []
49
+ for index in fates:
50
+ all_fates.append(fates[index])
51
+ unique_fates = set(all_fates)
52
+ fates_list = [["fate"]]
53
+ for fate in unique_fates:
54
+ fates_list.append([fate])
55
+ write(fate_name, fates_list)
56
+
57
+ fate_values = [["id", "value"]]
58
+ for node_id in tree.nodes:
59
+ fate_values.append([node_id, tree.fates.get(node_id)])
60
+ write(fate_value_name, fate_values)
61
+
62
+
63
+ def write(file_path, data):
64
+ with open(file_path, mode="w", newline="") as file:
65
+ writer = csv.writer(file)
66
+ writer.writerows(data)
67
+
68
+
69
+ if __name__ == "__main__":
70
+ export_to_csv()
@@ -0,0 +1,30 @@
1
+ import csv
2
+
3
+
4
+ def write_csv_from_lT_to_lineaja(
5
+ lT, path_to, start: int = 0, finish: int = 300
6
+ ):
7
+ csv_dict = {}
8
+ for time in range(start, finish):
9
+ for node in lT.time_nodes[time]:
10
+ csv_dict[node] = {"pos": lT.pos[node], "t": time}
11
+ with open(path_to, "w", newline="\n") as file:
12
+ fieldnames = [
13
+ "time",
14
+ "positions_x",
15
+ "positions_y",
16
+ "positions_z",
17
+ "id",
18
+ ]
19
+ writer = csv.DictWriter(file, fieldnames=fieldnames)
20
+ writer.writeheader()
21
+ for node in csv_dict:
22
+ writer.writerow(
23
+ {
24
+ "time": csv_dict[node]["t"],
25
+ "positions_z": csv_dict[node]["pos"][0],
26
+ "positions_y": csv_dict[node]["pos"][1],
27
+ "positions_x": csv_dict[node]["pos"][2],
28
+ "id": node,
29
+ }
30
+ )
@@ -0,0 +1,36 @@
1
+ import warnings
2
+
3
+ from ..lineageTree import lineageTree
4
+
5
+ try:
6
+ import motile
7
+ except ImportError:
8
+ warnings.warn(
9
+ "No motile installed therefore you will not be able to produce links with motile.",
10
+ stacklevel=2,
11
+ )
12
+
13
+
14
+ def to_motile(
15
+ lT: lineageTree, crop: int | None = None, max_dist=200, max_skip_frames=1
16
+ ):
17
+ try:
18
+ import networkx as nx
19
+ except ImportError:
20
+ raise Warning("Please install networkx") # noqa: B904
21
+
22
+ fmt = nx.DiGraph()
23
+ if not crop:
24
+ crop = lT.t_e
25
+ for time in range(crop):
26
+ for time_node in lT.nodes_at_t(time):
27
+ fmt.add_node(
28
+ time_node,
29
+ t=lT.time[time_node],
30
+ pos=lT.pos[time_node],
31
+ score=1,
32
+ )
33
+
34
+ motile.add_cand_edges(fmt, max_dist, max_skip_frames=max_skip_frames)
35
+
36
+ return fmt