lineage.plotTree

This file includes function to plot lineage trees. It relies on the NetworkX and the Bio packages.

Module Contents

lineage.plotTree.cs = ['lightblue', 'orange', 'lightgreen', 'red', 'purple', 'grey']
lineage.plotTree.stateColors = ['blue', 'orange', 'green', 'red', 'purple', 'grey']
lineage.plotTree.plot_lineage_samples(tHMMobj_list, name)

This function plots a sample of lineages for lapatinib and gemcitabine analysis figures.

lineage.plotTree.CladeRecursive(cell, a: list, censor: bool, color: bool)

A recurssive function that takes in the root cell and traverses through cells to plot the lineage. The width of the lines show the phase of the cells. The color of the lines show the state of the cells.

“a” should be: a = [Clade(lineage1.full_lineage[0].obs[2]+lineage1.full_lineage[0].obs[3])] which is the root cell The following is the source code used to create Clades manually: https://github.com/biopython/biopython/blob/fce4b11b4b8e414f1bf093a76e04a3260d782905/Bio/Phylo/BaseTree.py#L801

lineage.plotTree.plotLineage(lineage, axes, censor=True, color=True)

Given a lineage of cells, uses the CladeRecursive function to plot the lineage.

lineage.plotTree.plotLineage_MCF10A(lineage, axes, censor=True, color=True)

Given a lineage of cells, uses the CladeRecursive function to plot the lineage.

lineage.plotTree.CladeRecursive_MCF10A(cell, a: list, censor: bool, color: bool)

A recurssive function that takes in the root cell and traverses through cells to plot the lineage. The width of the lines show the phase of the cells. The color of the lines show the state of the cells.

“a” should be: a = [Clade(lineage1.full_lineage[0].obs[1])] which is the root cell

lineage.plotTree.plot_networkx(T: np.ndarray, drug_name: str)

This function plots the Transition network for each drug tratment. The nodes show the states and the edges show the transition probabilities.

lineage.plotTree.draw(tree, label_func=str, do_show=True, show_confidence=True, axes=None, branch_labels=None, label_colors=None, *args, **kwargs)

Plot the given tree using matplotlib (or pylab). The graphic is a rooted tree, drawn with roughly the same algorithm as draw_ascii. Additional keyword arguments passed into this function are used as pyplot options. The input format should be in the form of: pyplot_option_name=(tuple), pyplot_option_name=(tuple, dict), or pyplot_option_name=(dict). Example using the pyplot options ‘axhspan’ and ‘axvline’:

from Bio import Phylo, AlignIO
from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor
constructor = DistanceTreeConstructor()
aln = AlignIO.read(open('TreeConstruction/msa.phy'), 'phylip')
calculator = DistanceCalculator('identity')
dm = calculator.get_distance(aln)
tree = constructor.upgma(dm)
Phylo.draw(tree, axhspan=((0.25, 7.75), {'facecolor':'0.5'}),
... axvline={'x':0, 'ymin':0, 'ymax':1})

Visual aspects of the plot can also be modified using pyplot’s own functions and objects (via pylab or matplotlib). In particular, the pyplot.rcParams object can be used to scale the font size (rcParams[“font.size”]) and line width (rcParams[“lines.linewidth”]). :Parameters:

label_funccallable

A function to extract a label from a node. By default this is str(), but you can use a different function to select another string associated with each node. If this function returns None for a node, no label will be shown for that node.

do_showbool

Whether to show() the plot automatically.

show_confidencebool

Whether to display confidence values, if present on the tree.

axesmatplotlib/pylab axes

If a valid matplotlib.axes.Axes instance, the phylogram is plotted in that Axes. By default (None), a new figure is created.

branch_labelsdict or callable

A mapping of each clade to the label that will be shown along the branch leading to it. By default this is the confidence value(s) of the clade, taken from the confidence attribute, and can be easily toggled off with this function’s show_confidence option. But if you would like to alter the formatting of confidence values, or label the branches with something other than confidence, then use this option.

label_colorsdict or callable

A function or a dictionary specifying the color of the tip label. If the tip label can’t be found in the dict or label_colors is None, the label will be shown in black.