Skip to content

Commit

Permalink
Update tree_maker.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mkayasth authored May 10, 2024
1 parent 1a7e4e2 commit 59b1b49
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions fullSequenceAnalysis/neighborJoining/tree_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,33 @@
from Bio import Phylo
import matplotlib.pyplot as plt

# Parse the Newick string to create a Phylo tree object.
# Parsing the Newick string to create a Phylo tree object.
tree = Phylo.read("fullSequence-output/tree.txt", "newick")

# Set up a matplotlib figure.
fig = plt.figure(figsize=(15, 10), dpi=100)

fig = plt.figure(figsize=(20, 15), dpi=300)
axes = fig.add_subplot(1, 1, 1)

# formatting the branch labels to 3 significant figures.
def format_branch_length(clade):
if clade.branch_length is not None:
return f"{clade.branch_length:.3g}"


Phylo.draw(tree, do_show=False, axes=axes, branch_labels=format_branch_length)

Phylo.draw(tree, do_show=False, axes=axes, branch_labels=lambda c: c.branch_length)

axes.set_title('Phylogenetic Tree', fontsize=24)
axes.set_title('Phylogenetic Tree', fontsize=26)

# setting style.
# Setting style for the tree lines.
for line in axes.get_lines():
line.set_linewidth(3)
plt.setp(axes.get_xticklabels(), fontsize=20)
plt.setp(axes.get_yticklabels(), fontsize=20)
line.set_linewidth(3)

for lbl in axes.findobj(match=lambda obj: isinstance(obj, plt.Text)):
lbl.set_fontsize(16)




# Saving the figure to a JPEG file.
plt.savefig("fullSequence-output/tree.jpg", format='jpg', dpi=300)
Expand Down

0 comments on commit 59b1b49

Please sign in to comment.