Skip to content

Commit

Permalink
Merge pull request #57 from moshi4/develop
Browse files Browse the repository at this point in the history
Bump to v1.3.0
  • Loading branch information
moshi4 authored Feb 18, 2024
2 parents 65b3559 + 212b36f commit 4a3c82a
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version}}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Python 3.11
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyCirclize"
version = "1.2.0"
version = "1.3.0"
description = "Circular visualization in Python"
authors = ["moshi4"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/pycirclize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pycirclize.circos import Circos

__version__ = "1.2.0"
__version__ = "1.3.0"

__all__ = [
"Circos",
Expand Down
2 changes: 1 addition & 1 deletion src/pycirclize/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MIN_R = 0
MAX_R = 100
R_PLOT_MARGIN = 5
ARC_RADIAN_STEP = 0.001
ARC_RADIAN_STEP = 0.01
R_LIM = (MIN_R, MAX_R)
AXIS_FACE_PARAM = dict(zorder=0.99, ec="none", edgecolor="none")
AXIS_EDGE_PARAM = dict(zorder=1.01, fc="none", facecolor="none")
Expand Down
9 changes: 5 additions & 4 deletions src/pycirclize/parser/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def parse_fromto_table(
fromto2value = defaultdict(int)
for row in fromto_table.itertuples():
from_label, to_label, value = str(row[1]), str(row[2]), row[3]
fromto = f"{from_label}{to_label}"
fromto2value[fromto] = value
label2value_sum[from_label] += value
label2value_sum[to_label] += value
if float(value) > 0:
fromto = f"{from_label}{to_label}"
fromto2value[fromto] = value
label2value_sum[from_label] += value
label2value_sum[to_label] += value
all_labels = list(label2value_sum.keys())

# Set user specified label order
Expand Down
3 changes: 2 additions & 1 deletion src/pycirclize/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,8 @@ def _to_arc_radr(
all_arc_rad.extend([rad1, rad2])
all_arc_r.extend([r1, r2])
else:
step = config.ARC_RADIAN_STEP
# To obtain finely chopped coordinates, step is reduced by a tenth
step = config.ARC_RADIAN_STEP / 10
if rad1 > rad2:
step *= -1
arc_rad = list(np.arange(rad1, rad2, step)) + [rad2]
Expand Down
43 changes: 43 additions & 0 deletions src/pycirclize/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,49 @@ def get_target_xlim(
)
return target_xlim

def show_confidence(
self,
*,
size: float = 8,
orientation: str = "vertical",
label_formatter: Callable[[float], str] | None = None,
**kwargs,
) -> None:
"""Show confidence value on each internal node of the phylogenetic tree
Parameters
----------
size : float, optional
Text size
orientation : str, optional
Text orientation (`horizontal` or `vertical`)
label_formatter : Callable[[float], str] | None, optional
User-defined function for label format.
**kwargs : dict, optional
Text properties (e.g. `color="red", ...`)
<https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.text.html>
"""
node: Clade
for node in self.tree.get_nonterminals():
# Ignore if confidence value is None
confidence = node.confidence
if confidence is None:
continue

# Format confidence label
if label_formatter:
label = label_formatter(float(confidence))
elif str(confidence).isdigit():
label = str(confidence)
else:
label = f"{float(confidence):.2f}"

# Get target node x, r coordinate
x, r = self.name2xr[str(node.name)]

kwargs.update(size=size, orientation=orientation)
self.track.parent_sector.text(label, x, r + 1.0, **kwargs)

def highlight(
self,
query: str | list[str] | tuple[str],
Expand Down
2 changes: 1 addition & 1 deletion src/pycirclize/utils/example_data/trees/alphabet.nwk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(((A:1.90623,(B:0.77315,(C:0.78332,(D:2.24573,(E:1.25976,F:1.85780):0.00000):0.15046):1.04012):0.90160):0.72056,((((G:0.59616,H:1.70149):1.58325,I:1.00419):1.19115,(J:0.91877,K:1.31367):0.88856):1.55681,L:0.88143):0.74292):1.02610,((M:1.46117,((N:0.12272,(O:1.12953,P:0.58300):0.73047):0.70152,(Q:0.71106,((((R:0.53759,S:0.71617):1.49010,T:1.40058):1.09120,(U:0.80607,V:1.06576):0.73818):0.94044,W:1.90216):1.65416):1.75184):0.90540):1.56327,(X:0.59332,(Y:1.23427,Z:1.60350):0.98802):0.87582):0.47830):0.00000;
(((A:1.90623,(B:0.77315,(C:0.78332,(D:2.24573,(E:1.25976,F:1.85780)95:0.00000)99:0.15046)99:1.04012)100:0.90160)99:0.72056,((((G:0.59616,H:1.70149)91:1.58325,I:1.00419)98:1.19115,(J:0.91877,K:1.31367)91:0.88856)99:1.55681,L:0.88143)99:0.74292)95:1.02610,((M:1.46117,((N:0.12272,(O:1.12953,P:0.58300)99:0.73047)91:0.70152,(Q:0.71106,((((R:0.53759,S:0.71617)90:1.49010,T:1.40058)100:1.09120,(U:0.80607,V:1.06576)99:0.73818)100:0.94044,W:1.90216)91:1.65416)93:1.75184)90:0.90540)91:1.56327,(X:0.59332,(Y:1.23427,Z:1.60350)93:0.98802)90:0.87582)97:0.47830)100:0.00000;
2 changes: 2 additions & 0 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def test_phylogenetic_tree_plot(fig_outfile: Path):
tv.set_node_line_props(["S", "R"], color="lime", descendent=False)
tv.set_node_line_props(["X", "Y", "Z"], color="purple", apply_label_color=True)

tv.show_confidence()

circos.savefig(fig_outfile)
assert fig_outfile.exists()

Expand Down

0 comments on commit 4a3c82a

Please sign in to comment.