1
$\begingroup$

I'm new here. I need to construct a phylogenetic tree from 16s Sequence data (merged 151 bp) and color the branches/nodes based on my experimental conditions. From this blog, it looks like I need a .phy file to make the tree. I want to use Biopython for this since I'm reasonably comfortable with python.

I have a csv file with the 16s sequences, the phylogenetic information, and the "name" of the sequence, and the experimental conditions. How can I make a .phy file from this?

I would appreciate any help. Thank you.

$\endgroup$

2 Answers 2

1
$\begingroup$

You simply use Biopython's SeqIO and AlignIO. The documentation is https://biopython.org/wiki/AlignIO etc ... The format you seek is phylip

$\endgroup$
4
  • $\begingroup$ Thank you for your response. I made a .phy file similar to the one here link (except that in mine, the length of the sequences is 253). I ensured that they all have the same length. But when I ran al=AlignIO.read(open("for_tree_top10.phy"),"phylip"), I got "ValueError: Sequences must all be the same length". I'm not sure why, because I explicitly checked that the sequences have the same length. Not sure what to do now :( Any thoughts? $\endgroup$
    – Kaumz
    Feb 18, 2020 at 23:12
  • $\begingroup$ Possibly it is not a programming issue but formating. There is no simple answer to trouble shoot this. Could you ask this as a separate question please? Obviously it is solvable but there's several possibilities and the Moderators will intervene if there are multiple questions within a thread $\endgroup$
    – M__
    Feb 19, 2020 at 0:03
  • $\begingroup$ I have asked the question here link $\endgroup$
    – Kaumz
    Feb 19, 2020 at 15:31
  • $\begingroup$ thanks answered it $\endgroup$
    – M__
    Feb 19, 2020 at 16:33
1
$\begingroup$

Python works great for tying everything together and file manipulations. I find stepping out of Python, using system calls, best for alignment and tree building. For example:

os.system("mafft --auto {} > {}" .format("unaligned_16s_seq_in_file.fasta", "alignment_out_file.fasta"))

os.system("raxml -f a -s {} -p 12345 -x 12345 -# 100 -m GTRCAT -n {}" .format("alignment_out_file.fasta", "tree_out_file.tre"))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.