lineage.plotTree ================ .. py:module:: lineage.plotTree .. autoapi-nested-parse:: This file includes function to plot lineage trees. It relies on the NetworkX and the Bio packages. Attributes ---------- .. autoapisummary:: lineage.plotTree.cs lineage.plotTree.stateColors Classes ------- .. autoapisummary:: lineage.plotTree.PhaseClade Functions --------- .. autoapisummary:: lineage.plotTree.plot_lineage_samples lineage.plotTree.CladeRecursive lineage.plotTree.plotLineage lineage.plotTree.plotLineage_MCF10A lineage.plotTree.CladeRecursive_MCF10A lineage.plotTree.plot_networkx lineage.plotTree.draw Module Contents --------------- .. py:data:: cs :value: ['lightblue', 'orange', 'lightgreen', 'red', 'purple', 'grey'] .. py:data:: stateColors :value: ['blue', 'orange', 'green', 'red', 'purple', 'grey'] .. py:class:: PhaseClade(branch_length=None, name=None, clades=None, confidence=None, color=None, width=None) Bases: :py:obj:`Bio.Phylo.BaseTree.Clade` Clade with cell cycle phase properties for plotting. .. py:attribute:: G1 :type: float .. py:attribute:: G2 :type: float .. py:attribute:: G1lw :type: float .. py:attribute:: G2lw :type: float .. py:function:: plot_lineage_samples(tHMMobj_list, name) This function plots a sample of lineages for lapatinib and gemcitabine analysis figures. .. py:function:: 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 .. py:function:: plotLineage(lineage, axes, censor = True, color = True) Given a lineage of cells, uses the `CladeRecursive` function to plot the lineage. .. py:function:: plotLineage_MCF10A(lineage, axes, censor = True, color = True) Given a lineage of cells, uses the `CladeRecursive` function to plot the lineage. .. py:function:: 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 .. py:function:: 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. .. py:function:: 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': .. code-block:: python 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"]). :param 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. :param do_show: Whether to show() the plot automatically. :param show_confidence: Whether to display confidence values, if present on the tree. :param axes: If a valid matplotlib.axes.Axes instance, the phylogram is plotted in that Axes. By default (None), a new figure is created. :param 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. :param 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.