# How to create a dendrogram of clusters and reconstruct phylogenetic relationship

I'm working with a Daphnia data set looking at the 16s gene pulled from the BOLD database. So far I did a multiple sequence alignment and attempted to cluster and plot a dendrogram:

myClustalWAlignment <- DNAStringSet(msa(MySeqString, cluster="nj", gapOpening=30.0,  gapExtension=20.0, maxiters=2, substitutionMatrix="default", type="default", verbose=TRUE))


Replace full sequence names with Accession numbers for easy identification

names(myClustalWAlignment) <- Daphnia_DF\$Accession_number


Converts the alignment object into a DNAbin class. Some of the results are shown and may be useful for further analysis:

ClustalAlignment_dnaBin <- as.DNAbin(myClustalWAlignment)


Creating a distance matrix:

distmat <- dist.dna(ClustalAlignment_dnaBin, model = "TN93", as.matrix = TRUE, pairwise.deletion = TRUE)


clustering the sequences:

Daphnia_Clustered <- IdClusters(distmat,
method = "UPGMA",
cutoff = 0.01,
showPlot = TRUE,
type = "both",
myXStringSet = NULL,
model = MODELS,
collapse = 0,
processors = NULL,
verbose = TRUE)


checking to see the number of clusters:

length(unique(unlist(Daphnia_Clustered[[1]][1])))


output: 80

the problem is that I want a dendrogram showing just the 80 clusters if that's possible. Right now the output of the above clustering is:

Is there a way to get a smaller number of clusters? Or even being able to plot just the 80 OTU clusters would be great. Is there an easy way of reconstructing the phylogenetic relationship between these clusters?

• Welcome! Just curious - why don't you want to just make a maximum likelihood or Bayesian tree? Those are very standard approaches and you can just collapse nodes later on to make clusters. – conchoecia Oct 25 '18 at 6:22
• Hey, I'm just extremely new r and bioinformatics I guess. I did attempt that and I did come out with a tree structure. However, how would I go on about collapsing the branches, are there any packages you particularly recommend ? – Gurkamal Deol Oct 25 '18 at 14:41
• If you need to quickly visualize the tree I would just save the tree file, open it in FigTree, and collapse the nodes. biostars.org/p/18302 If you add some info to your question like what the end goals are for this project or this phylogenetic analysis/visualization I think people can get a better answer tailored to the needs of the question. – conchoecia Oct 25 '18 at 15:08
• I agree that it is easier to make a subtree in figtree and write the tree in R to the hard-drive. – Michael G. Dec 28 '18 at 21:13