Skip to content

Commit

Permalink
Merge pull request #96 from natetrux/9_9fixes
Browse files Browse the repository at this point in the history
Annotate subpackage fixes
  • Loading branch information
eaton-lab authored Sep 13, 2024
2 parents f9eb409 + dc6f314 commit 0b2ee6a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ nav:
- quadripartition methods: quadripartitions.ipynb
# - other: ...

- <i>.distance</i> - tree/node dists: # TO DO
- <i>.distance</i> - tree/node dists:
- node distances: node-distance.ipynb
- tree distances: tree-distance.ipynb

Expand Down
1 change: 1 addition & 0 deletions toytree/annotate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from toytree.annotate.src.add_tip_markers import *
from toytree.annotate.src.add_axes_box_outline import *
from toytree.annotate.src.add_scale_bar import *
from toytree.annotate.src.add_pie_markers import *

# ... edge_labels
# ... node_labels
Expand Down
8 changes: 4 additions & 4 deletions toytree/annotate/src/add_pie_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from toytree.style import check_arr, get_color_mapped_values
from toytree.annotate.src.checks import get_last_toytree_mark, assert_tree_matches_mark
from toytree.core.apis import add_subpackage_method, AnnotationAPI
from toytree.annotate.src.add_edge_markers import _get_edge_midpoints
from toytree.annotate.src.add_edge_markers import get_edge_midpoints
from toytree.drawing.src.mark_pie import PieChartMark
from toytree.style.src.validate_data import (
validate_numeric,
Expand Down Expand Up @@ -248,7 +248,8 @@ def add_edge_pie_charts(

# get coordinates of all real edges
nedges = tree.nnodes - 2 if tree.is_rooted() else tree.nnodes - 1
coords = _get_edge_midpoints(tree, mark.ntable, mark.layout, mark.edge_type)
#coords = _get_edge_midpoints(tree, mark.ntable, mark.layout, mark.edge_type)
coords = get_edge_midpoints(mark.etable, mark.ntable, mark.layout, mark.edge_type)

mask = validate_mask(tree, style={"node_mask": mask})[:nedges]

Expand Down Expand Up @@ -302,15 +303,14 @@ def add_edge_pie_charts(
import toytree
tree = toytree.rtree.unittree(6, seed=123)
canvas, axes, m0 = tree.draw()

# generate random pie-like (proportion) data array
import numpy as np
ncategories = 3
arr = np.random.random(size=(tree.nnodes, ncategories))
arr = (arr.T / arr.sum(axis=1)).T

# add pie charts to all internal Nodes
tree.annotate.add_edge_pie_charts(
tree.annotate.add_node_pie_charts(
axes=axes,
data=arr,
size=20,
Expand Down

0 comments on commit 0b2ee6a

Please sign in to comment.