Reconstructing trees from alignments using phangorn
So far in this chapter, we’ve assumed that trees are already available and ready to use. Of course, there are many ways to make a phylogenetic tree and, in this recipe, we’ll take a look at some of the different methods available.
Getting ready
For this chapter, we’ll use the abc.fa
file of yeast ABC transporter sequences, the Bioconductor Biostrings
package, and the CRAN msa
and phangorn
packages.
How to do it…
Constructing trees using phangorn
can be done like this:
- Load in the libraries and sequences and make an alignment:
library(Biostrings)library(msa)library(phangorn)seqfile <- fs::path_package( "extdata", "abc.fa", package="rbioinfcookbook")seqs <- readAAStringSet(seqfile)aln <- msa::msa(seqs, method=c("ClustalOmega"))
- Convert the alignment:
aln <- as.phyDat(aln, type = "AA")
- Make...