PhyloTree

Contents

PhyloTree#

missionbio.plotting.phylotree.PhyloTree

class PhyloTree(labels: Sequence[str], parents: Sequence[Optional[str]], description: Optional[Sequence[str]] = None, marker_size: Union[float, Sequence[float]] = 18, font_size: float = 14, margin: float = 10, marker_gap: Tuple[float, float] = (60, 30))#

Container for creating a phylogenetic tree.

Snippets#

A tree with 4 nodes with custom descriptions and colors

>>> from missionbio.plotting.phylotree import PhyloTree
>>> labels = ["1", "2", "3", "4"]
>>> parents = [None, "1", "1", "2"]
>>> descriptions = ["WT", "KIT HET", "KIT HET<br>TP53 HET", "KIT LOH"]
>>> graph = PhyloTree(labels, parents, descriptions)
>>> graph.draw(palette={"1": "#000000", "2": "crimson", "3": "skyblue", "4": "red"})

Functions#

draw([palette, fig, row, col])

Create and draw the subclone tree graph.

expected_fig_size([positions, text_sizes, ...])

Estimate the plot size required to fit the tree.

Create a new PhyloTree instance.

Parameters:
labelsSequence[str]

The labels of the nodes in the tree.

parentsSequence[str]

The parent for each label. This must have the same length as labels and each parent must be present in labels.

descriptionSequence[str]

A long description for each label. This is the value shown on the plot.

font_sizefloat

The font size of the text in the plot

marker_sizefloat

The size of the circular markers used to represent the nodes.

marginfloat

The number of pixels that must be left empty within the plot boundaries on each edge of the plot

marker_gapTuple[float, float]

The gap between the nodes in the x and y direction respectively

Raises:
ValuError:

When the labels are not unique