# 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 ("ape" docs), tutorial3, and there are many more. There appears to be quite a few steps with dependencies from multiple packages: eg. "ape", "phangorn", "phytools", "geiger". 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("Biostrings")
library("seqinr")
library("ape")
library(phylogram)
library("dendextend")

#read in the data from a format with the aligned sequences (eg msf)
msf.res <- read.alignment(file = "geneticAlignment.msf", format = "msf")
#dist.alignment and not dna.dist commonly used in tutorials
msf.res.dist.alignment = dist.alignment(msf.res, matrix = "identity")
#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 = "Neighbor Joining")