I did play around with making neighbor-joining trees in R, so I can plot these data in a meaningful way. It is actually much easier than I expected, R just has a library for working with phylogenies (ape) with a handy-dandy function for making neighbor-joining trees based on an input matrix of differences between each sample. There is one thing about the function example in the R docs that confuses me. When they make the input matrix:
x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
5, 6, 10, 9, 13, 8)
M <- matrix(0, 8, 8)
M[row(M) > col(M)] <- x
M[row(M) < col(M)] <- xThe matrix is not symmetrical. I tried it with excluding the second line that adds the data to the matrix, and it doesn't seem to affect the resulting tree. So I think I'll just be giving R my data with half the matrix empty.
The official documentation has a correct example with a symmetric matrix.
ReplyDeletehttp://cran.r-project.org/web/packages/ape/ape.pdf
### From Saitou and Nei (1987, Table 1):
x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
5, 6, 10, 9, 13, 8)
M <- matrix(0, 8, 8)
M[lower.tri(M)] <- x
M <- t(M)
M[lower.tri(M)] <- x
dimnames(M) <- list(1:8, 1:8)
tr <- nj(M)
plot(tr, "u")
### a less theoretical example
data(woodmouse)
trw <- nj(dist.dna(woodmouse))
plot(trw)
Also, BUCKET!!!
Ah, transposing the matrix makes sense. But since it doesn't change anything I doubt I'll bother. But ty anyway.
DeleteCUP.