lineage.plotTree

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

Attributes

cs

stateColors

Classes

PhaseClade

Clade with cell cycle phase properties for plotting.

Functions

plot_lineage_samples(tHMMobj_list, name)

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

CladeRecursive(cell, a, censor, color)

A recurssive function that takes in the root cell and traverses through cells to plot the lineage.

plotLineage(lineage, axes[, censor, color])

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

plotLineage_MCF10A(lineage, axes[, censor, color])

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

CladeRecursive_MCF10A(cell, a, censor, color)

A recurssive function that takes in the root cell and traverses through cells to plot the lineage.

plot_networkx(T, drug_name)

This function plots the Transition network for each drug tratment.

draw(tree[, label_func, do_show, show_confidence, ...])

Plot the given tree using matplotlib (or pylab).

Module Contents

lineage.plotTree.cs = ['lightblue', 'orange', 'lightgreen', 'red', 'purple', 'grey']
lineage.plotTree.stateColors = ['blue', 'orange', 'green', 'red', 'purple', 'grey']
class lineage.plotTree.PhaseClade(branch_length=None, name=None, clades=None, confidence=None, color=None, width=None)

Bases: Bio.Phylo.BaseTree.Clade

Clade with cell cycle phase properties for plotting.

G1: float
G2: float
G1lw: float
G2lw: float
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, censor, color)

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

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

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

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

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

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

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

Parameters:
  • a (list)

  • censor (bool)

  • color (bool)

lineage.plotTree.plot_networkx(T, drug_name)

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

Parameters:
  • T (numpy.ndarray)

  • drug_name (str)

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_func -- 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_show -- Whether to show() the plot automatically.

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

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

  • branch_labels -- 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_colors -- 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.