iplotx 0.6.4__py3-none-any.whl → 0.6.5__py3-none-any.whl
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.
- iplotx/edge/__init__.py +2 -0
- iplotx/ingest/typing.py +2 -1
- iplotx/network.py +5 -4
- iplotx/tree.py +7 -6
- iplotx/utils/matplotlib.py +32 -6
- iplotx/version.py +1 -1
- iplotx/vertex.py +2 -2
- {iplotx-0.6.4.dist-info → iplotx-0.6.5.dist-info}/METADATA +1 -1
- {iplotx-0.6.4.dist-info → iplotx-0.6.5.dist-info}/RECORD +10 -10
- {iplotx-0.6.4.dist-info → iplotx-0.6.5.dist-info}/WHEEL +0 -0
iplotx/edge/__init__.py
CHANGED
|
@@ -357,6 +357,8 @@ class EdgeCollection(mpl.collections.PatchCollection):
|
|
|
357
357
|
waypoints = edge_stylei.get("waypoints", "none")
|
|
358
358
|
if waypoints is False or waypoints is np.False_:
|
|
359
359
|
waypoints = "none"
|
|
360
|
+
elif isinstance(waypoints, (list, tuple)) and len(waypoints) == 0:
|
|
361
|
+
waypoints = "none"
|
|
360
362
|
elif waypoints is True or waypoints is np.True_:
|
|
361
363
|
raise ValueError(
|
|
362
364
|
"Could not determine automatically type of edge waypoints.",
|
iplotx/ingest/typing.py
CHANGED
|
@@ -311,11 +311,12 @@ class TreeDataProvider(Protocol):
|
|
|
311
311
|
leaf_name_attrs = ("name",)
|
|
312
312
|
|
|
313
313
|
# Add edge_df
|
|
314
|
-
edge_data = {"_ipx_source": [], "_ipx_target": []}
|
|
314
|
+
edge_data = {"_ipx_source": [], "_ipx_target": [], "branch_length": []}
|
|
315
315
|
for node in self.preorder():
|
|
316
316
|
for child in self.get_children(node):
|
|
317
317
|
edge_data["_ipx_source"].append(node)
|
|
318
318
|
edge_data["_ipx_target"].append(child)
|
|
319
|
+
edge_data["branch_length"].append(self.get_branch_length(child))
|
|
319
320
|
edge_df = pd.DataFrame(edge_data)
|
|
320
321
|
tree_data["edge_df"] = edge_df
|
|
321
322
|
|
iplotx/network.py
CHANGED
|
@@ -239,17 +239,18 @@ class NetworkArtist(mpl.artist.Artist):
|
|
|
239
239
|
labels = self._get_label_series("edge")
|
|
240
240
|
edge_style = get_style(".edge")
|
|
241
241
|
|
|
242
|
+
edge_df = self._ipx_internal_data["edge_df"].set_index(["_ipx_source", "_ipx_target"])
|
|
243
|
+
|
|
242
244
|
if "cmap" in edge_style:
|
|
243
245
|
cmap_fun = _build_cmap_fun(
|
|
244
|
-
edge_style
|
|
245
|
-
|
|
246
|
+
edge_style,
|
|
247
|
+
"color",
|
|
246
248
|
edge_style.get("norm", None),
|
|
249
|
+
internal=edge_df,
|
|
247
250
|
)
|
|
248
251
|
else:
|
|
249
252
|
cmap_fun = None
|
|
250
253
|
|
|
251
|
-
edge_df = self._ipx_internal_data["edge_df"].set_index(["_ipx_source", "_ipx_target"])
|
|
252
|
-
|
|
253
254
|
if "cmap" in edge_style:
|
|
254
255
|
colorarray = []
|
|
255
256
|
edgepatches = []
|
iplotx/tree.py
CHANGED
|
@@ -329,8 +329,8 @@ class TreeArtist(mpl.artist.Artist):
|
|
|
329
329
|
|
|
330
330
|
if "cmap" in edge_style:
|
|
331
331
|
cmap_fun = _build_cmap_fun(
|
|
332
|
-
edge_style
|
|
333
|
-
|
|
332
|
+
edge_style,
|
|
333
|
+
"color",
|
|
334
334
|
)
|
|
335
335
|
else:
|
|
336
336
|
cmap_fun = None
|
|
@@ -537,16 +537,17 @@ class TreeArtist(mpl.artist.Artist):
|
|
|
537
537
|
labels = self._get_label_series("edge")
|
|
538
538
|
edge_style = get_style(".edge")
|
|
539
539
|
|
|
540
|
+
edge_df = self._ipx_internal_data["edge_df"].set_index(["_ipx_source", "_ipx_target"])
|
|
541
|
+
|
|
540
542
|
if "cmap" in edge_style:
|
|
541
543
|
cmap_fun = _build_cmap_fun(
|
|
542
|
-
edge_style
|
|
543
|
-
|
|
544
|
+
edge_style,
|
|
545
|
+
"color",
|
|
546
|
+
internal=edge_df,
|
|
544
547
|
)
|
|
545
548
|
else:
|
|
546
549
|
cmap_fun = None
|
|
547
550
|
|
|
548
|
-
edge_df = self._ipx_internal_data["edge_df"].set_index(["_ipx_source", "_ipx_target"])
|
|
549
|
-
|
|
550
551
|
if "cmap" in edge_style:
|
|
551
552
|
colorarray = []
|
|
552
553
|
edgepatches = []
|
iplotx/utils/matplotlib.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
from typing import Optional, Any
|
|
1
2
|
from functools import wraps, partial
|
|
2
3
|
from math import atan2
|
|
3
4
|
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
4
6
|
import matplotlib as mpl
|
|
5
7
|
|
|
6
8
|
from .geometry import (
|
|
@@ -162,15 +164,39 @@ def _compute_mid_coord_and_rot(path, trans):
|
|
|
162
164
|
return coord, rot
|
|
163
165
|
|
|
164
166
|
|
|
165
|
-
def _build_cmap_fun(
|
|
166
|
-
|
|
167
|
+
def _build_cmap_fun(
|
|
168
|
+
style: dict[str, Any],
|
|
169
|
+
key: str,
|
|
170
|
+
norm=None,
|
|
171
|
+
internal: Optional[pd.DataFrame] = None,
|
|
172
|
+
):
|
|
173
|
+
"""Map colormap on top of numerical values.
|
|
174
|
+
|
|
175
|
+
Parameters:
|
|
176
|
+
style: A dictionary of style properties.
|
|
177
|
+
key: The key in the style dictionary to look for values. Values can be a list/array,
|
|
178
|
+
a dictionary of numerical values, or a string, in which case the corresponding
|
|
179
|
+
column in the "internal" DataFrame is used as an array of numerical values.
|
|
180
|
+
norm: An optional matplotlib Normalize instance. If None, the values are normalized.
|
|
181
|
+
internal: An optional DataFrame, required if "values" is a string.
|
|
182
|
+
"""
|
|
183
|
+
values = style[key]
|
|
184
|
+
cmap = style["cmap"]
|
|
185
|
+
|
|
167
186
|
cmap = mpl.cm._ensure_cmap(cmap)
|
|
168
187
|
|
|
169
|
-
if
|
|
170
|
-
|
|
188
|
+
if isinstance(values, str):
|
|
189
|
+
if not isinstance(internal, pd.DataFrame):
|
|
190
|
+
raise ValueError("If 'values' is a string, 'internal' must be a DataFrame.")
|
|
191
|
+
values = internal[values].values
|
|
192
|
+
internal[key] = values
|
|
193
|
+
|
|
194
|
+
else:
|
|
195
|
+
if np.isscalar(values):
|
|
196
|
+
values = [values]
|
|
171
197
|
|
|
172
|
-
|
|
173
|
-
|
|
198
|
+
if isinstance(values, dict):
|
|
199
|
+
values = np.array(list(values.values()))
|
|
174
200
|
|
|
175
201
|
if norm is None:
|
|
176
202
|
vmin = np.nanmin(values)
|
iplotx/version.py
CHANGED
iplotx/vertex.py
CHANGED
|
@@ -4,20 +4,20 @@ iplotx/cascades.py,sha256=OPqF7Huls-HFmDA5MCF6DEZlUeRVaXsbQcHBoKAgNJs,8182
|
|
|
4
4
|
iplotx/groups.py,sha256=_9KdIiTAi1kXtd2mDywgBJCbqoRq2z-5fzOPf76Wgb8,6287
|
|
5
5
|
iplotx/label.py,sha256=6am3a0ejcW_bWEXSOODE1Ke3AyCU1lJ45RfnXNbHAQw,8923
|
|
6
6
|
iplotx/layout.py,sha256=KxmRLqjo8AYCBAmXez8rIiLU2sM34qhb6ox9AHYwRyE,4839
|
|
7
|
-
iplotx/network.py,sha256=
|
|
7
|
+
iplotx/network.py,sha256=5A0yvoJKAfT1xcnWYh9hHM8dkF2NkHK7RK1h9Uc35-Y,11359
|
|
8
8
|
iplotx/plotting.py,sha256=yACxkD6unKc5eDsAp7ZabRCAwLEXBowSMESX2oGNBDU,7291
|
|
9
|
-
iplotx/tree.py,sha256=
|
|
9
|
+
iplotx/tree.py,sha256=Zzz7nCPZrSjh9_yHXFdd8hjbF-FYURTZs00rUHc4OT8,27304
|
|
10
10
|
iplotx/typing.py,sha256=QLdzV358IiD1CFe88MVp0D77FSx5sSAVUmM_2WPPE8I,1463
|
|
11
|
-
iplotx/version.py,sha256=
|
|
12
|
-
iplotx/vertex.py,sha256=
|
|
13
|
-
iplotx/edge/__init__.py,sha256=
|
|
11
|
+
iplotx/version.py,sha256=4IFN3njnGdyj6gkoCknMRXJtKdrK2JFUlkOSIdsZDNM,66
|
|
12
|
+
iplotx/vertex.py,sha256=AJEBtIDW0hDTij10M_hHXymVLm6iQHkQqZgVD2PllLw,14563
|
|
13
|
+
iplotx/edge/__init__.py,sha256=hxRYlfWEx7DINKem9Rush9MnykRthw8jj90dsDWrK_M,27002
|
|
14
14
|
iplotx/edge/arrow.py,sha256=C4XoHGCYou1z2alz5Q2VhdaWYEzgebtEF70zVYY_frk,15533
|
|
15
15
|
iplotx/edge/geometry.py,sha256=tiaF4PzvsNBoROrEgcCsw0YdxxZr3oBxF4ord_k4ThA,15069
|
|
16
16
|
iplotx/edge/leaf.py,sha256=SyGMv2PIOoH0pey8-aMVaZheK3hNe1Qz_okcyWbc4E4,4268
|
|
17
17
|
iplotx/edge/ports.py,sha256=BpkbiEhX4mPBBAhOv4jcKFG4Y8hxXz5GRtVLCC0jbtI,1235
|
|
18
18
|
iplotx/ingest/__init__.py,sha256=S0YfnXcFKseB7ZBQc4yRt0cNDsLlhqdom0TmSY3OY2E,4756
|
|
19
19
|
iplotx/ingest/heuristics.py,sha256=715VqgfKek5LOJnu1vTo7RqPgCl-Bb8Cf6o7_Tt57fA,5797
|
|
20
|
-
iplotx/ingest/typing.py,sha256
|
|
20
|
+
iplotx/ingest/typing.py,sha256=-40DsfCte65FN-FFzlvKFiLLVQGncaRNW61kitlHf9w,14086
|
|
21
21
|
iplotx/ingest/providers/network/igraph.py,sha256=8dWeaQ_ZNdltC098V2YeLXsGdJHQnBa6shF1GAfl0Zg,2973
|
|
22
22
|
iplotx/ingest/providers/network/networkx.py,sha256=FIXMI3hXU1WtAzPVlQZcz47b-4V2omeHttnNTgS2gQw,4328
|
|
23
23
|
iplotx/ingest/providers/network/simple.py,sha256=e_aHhiHhN9DrMoNrt7tEMPURXGhQ1TYRPzsxDEptUlc,3766
|
|
@@ -31,8 +31,8 @@ iplotx/style/leaf_info.py,sha256=JoX1cPjRM_k3f93jzUPQ3gPlVP4wY_n032nOVhrgelU,969
|
|
|
31
31
|
iplotx/style/library.py,sha256=wO-eeY3EZfAl0v21aX9f5_MiZhHuL2kGsBYA3uJkIGs,8535
|
|
32
32
|
iplotx/utils/geometry.py,sha256=6RrC6qaB0-1vIk1LhGA4CfsiMd-9JNniSPyL_l9mshE,9245
|
|
33
33
|
iplotx/utils/internal.py,sha256=WWfcZDGK8Ut1y_tOHRGg9wSqY1bwSeLQO7dHM_8Tvwo,107
|
|
34
|
-
iplotx/utils/matplotlib.py,sha256=
|
|
34
|
+
iplotx/utils/matplotlib.py,sha256=wELE73quQv10-1w9uA5eDTgkZkylJvjg7pd3K5tZPOo,6294
|
|
35
35
|
iplotx/utils/style.py,sha256=wMWxJykxBD-JmcN8-rSKlWcV6pMfwKgR4EzSpk_NX8k,547
|
|
36
|
-
iplotx-0.6.
|
|
37
|
-
iplotx-0.6.
|
|
38
|
-
iplotx-0.6.
|
|
36
|
+
iplotx-0.6.5.dist-info/METADATA,sha256=0-0qPdtrERP5KY_nlerTLKWF6ykr9pQPBfIBEOo-43M,4908
|
|
37
|
+
iplotx-0.6.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
38
|
+
iplotx-0.6.5.dist-info/RECORD,,
|
|
File without changes
|