Monday, October 15, 2012

What did Robert do today?

Well, I'm working on a data set of whole genome sequence from 13 Capsella grandiflora individuals. The main goal of this project is to quantify selection across the whole genome of this species (and the closely related selfer C. rubella). My main project today was to calculate pairwise divergence between my samples, so I can see if there is any clustering of individuals. Those scripts are running, and hopefully tomorrow I'll have awesome pictures.

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)] <- x
The 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.

2 comments:

  1. The official documentation has a correct example with a symmetric matrix.

    http://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!!!

    ReplyDelete
    Replies
    1. Ah, transposing the matrix makes sense. But since it doesn't change anything I doubt I'll bother. But ty anyway.

      CUP.

      Delete