Minimal working example for phylogenetic tree construction in R using an alignment of DNA strings and a vector of names? I am looking at how to build a phylogenetic tree in R from aligned genetic information (dna sequences). There are multiple tutorials on how to go about this task eg tutorial1, tutorial2 (&quot;ape&quot; docs), tutorial3, and there are many more. There appears to be quite a few steps with dependencies from multiple packages: eg. &quot;ape&quot;, &quot;phangorn&quot;, &quot;phytools&quot;, &quot;geiger&quot;. I would like to learn a minimal working example (mwe) for constructing a phylogenetic tree from a basic data-structure holding dna-strings.
Eg. I have a vector of nucleotide strings, and a separate vector for the 'names' of each string in the vector, how can I construct a phylogenetic tree from this information? (not a fasta file)
A key difference from many examples provided is that they assume that the data provided is in the form of sequences rather than an already aligned sequence alignment.
library(&quot;Biostrings&quot;)
library(&quot;seqinr&quot;)
library(&quot;ape&quot;)
library(phylogram)
library(&quot;dendextend&quot;)


#read in the data from a format with the aligned sequences (eg msf)
msf.res &lt;- read.alignment(file = &quot;geneticAlignment.msf&quot;, format = &quot;msf&quot;)
#dist.alignment and not dna.dist commonly used in tutorials
msf.res.dist.alignment = dist.alignment(msf.res, matrix = &quot;identity&quot;)
#perform neighbor joining upon the distance set
msf.res.dist.alignment.nj = nj(msf.res.dist.alignment)
#then plot the joined sequences
plot(msf.res.dist.alignment.nj, main = &quot;Neighbor Joining&quot;)