0
$\begingroup$

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)

$\endgroup$

1 Answer 1

1
$\begingroup$

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")
 
$\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.