This data was prepared using nucleotide data from 5 different chimp species. I then chose 10 arbitrary loci and compared them and found their PID and percent dis-similarity as well. I found these numbers for each pair of comparissons that could be made of the species availible. These results where then plotted in a table.
#install.packages("ape")
#install.packages("phangorn")
library(ape)
library(phangorn)
Build the matrix.
Be sure to add the nrow = … statemetn.
five_sim_mat <- matrix(c(1.0, 0.0, 0.0, 0.0, 0.0,
0.8, 1.0, 0.0, 0.0, 0.0,
0.7, 0.7, 1.0, 0.0, 0.0,
0.3, 0.3, 0.4, 1.0, 0.0,
0.6, 0.6, 0.5, 0.4, 1.0),
nrow=5, byrow = T)
Name things
row.names(five_sim_mat) <-c("M_E", "B", "G", "T", "M")
colnames(five_sim_mat) <-c("M_E", "B", "G", "T", "M")
Turn into a distance matrix. This is 2 steps and requires the as.dist() command
five_dist_mat<- 1-five_sim_mat
five_dist_mat2 <- as.dist(five_dist_mat)
Neighbor-Joining tree with nj()
five_nj <- nj(five_dist_mat2)
Plot unrooted NJ tree
plot(five_nj, "unrooted")
Plot rooted NJ tree
plot(five_nj)
Build UPGMA tree
five_upgma <- phangorn::upgma(five_dist_mat2)
Plot UPGMA tree
plot(five_upgma)
Compare rooted NJ and UPGMA plots
par(mfrow=c(1,2))
plot(five_nj)
plot(five_upgma)
Build WPGMA tree
five_wpgma <- wpgma(five_dist_mat2)
plot(wpgma(five_dist_mat))
Compare rooted WPGMA and UPGMA plots
par(mfrow=c(1,2))
plot(five_upgma)
plot(five_wpgma)
Build Minimum evolution tree
plot(fastme.ols(five_dist_mat2))