Mercurial > repos > boris > phylorelatives
changeset 40:dd39849c2ff1 draft
plot now highlights minor allele sequences in tree
author | boris |
---|---|
date | Fri, 19 Jul 2013 17:44:58 -0400 |
parents | 369f0b641498 |
children | 9453ba52f46b |
files | phylorelatives.py |
diffstat | 1 files changed, 17 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/phylorelatives.py Tue Jun 25 00:41:54 2013 -0400 +++ b/phylorelatives.py Fri Jul 19 17:44:58 2013 -0400 @@ -97,45 +97,27 @@ return ascii_tree -def ape_plot_tree(outfile, tree1, tree2=None, root=False): +def ape_plot_tree(outfile, tree1, root=False): """Plot tree to png file""" ape = importr('ape') graphics = importr('graphics') grdevices = importr('grDevices') - if tree2 is None: - grdevices.png(file=outfile, width=1024, height=768) - if root: - ape.plot_phylo(ape.root(tree1,root),use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - else: - ape.plot_phylo(tree1,use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - #graphics.title(main='Neighbor Joining') - grdevices.dev_off() - elif tree2 is not None: - grdevices.png(file=outfile, width=1024, height=768) - graphics.par(mfcol=array.array('i',[1,2])) - if root: - ape.plot_phylo(ape.root(tree1,root),use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - else: - ape.plot_phylo(tree1,use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - graphics.title(main='Neighbor Joining', cex=1.5, font=2) - if root: - ape.plot_phylo(ape.root(tree2,root),use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - else: - ape.plot_phylo(tree2,use_edge_length=0, - show_node_label=1,edge_width=2, font=2, - cex=1,underscore=0, no_margin=1) - graphics.title(main='Maximum Parsimony',cex=1.5, font=2) - grdevices.dev_off() + grdevices.png(file=outfile, width=1024, height=768) + if root: + tree = ape.root(tree1,root) + labels = list(tree.rx("tip.label")[0]) + colors = robjects.StrVector(["red" if tip.endswith("_minor") else "black" for tip in labels]) + ape.plot_phylo(tree,tip_color=colors,use_edge_length=0, + show_node_label=1,edge_width=2, font=2, + cex=1,underscore=0, no_margin=1) + else: + tree = tree1 + labels = list(tree.rx("tip.label")[0]) + colors = robjects.StrVector(["red" if tip.endswith("_minor") else "black" for tip in labels]) + ape.plot_phylo(tree,tip_color=colors,use_edge_length=0, + show_node_label=1,edge_width=2, font=2, + cex=1,underscore=0, no_margin=1) + #graphics.title(main='Neighbor Joining') return