I told Luke Mahler about how I'm interested in practicing analyses in R with my particular group of interest, even though I haven't collected data on more than a few species and I don't have a tree. He told me creating a tree from previously published studies is easy: just import the tree into R in newick format! In the geiger package in R, there is a function read.tree that does just that.
The tricky part about doing this is creating the newick-format tree itself. It involves a lot of parentheses, colons, and parentheses:
exampleTree = read.tree(text = "(((A:1, B:1):1, C:2):1, D:3);")
will give you
Since I was typing out the newick-format tree directly within read.tree, I needed to make sure it went into the text argument instead of the file argument. As for the newick format itself, the tip names are followed by the immediately subtending branch length: hence A:1 or D:3. The nodes also need to be provided with branch lengths, which is the :1 following each clade designated in parentheses. Finally, you can't forget the semi-colon at the end. It is very easy to get lost in a sea of parentheses, especially for large trees, so inevitably I needed to go back to make changes. Testing small clades at a time makes this a little easier.
In my particular tree, I had polytomies, which I designated with 0-length internal branches. So if in the above tree, I actually don't have any information about the interrelationships of A, B, and C, I can use this:
polytomyTree = read.tree(text = "(((A:1, B:1):0, C:1):1, D:2);")
to get
Thursday, April 19, 2012
Wednesday, April 11, 2012
RStudio
I was first introduced to RStudio when I took STA141 with Duncan Temple Lang. At the time, I was using a PC, and it made things much simpler. A few of the features that I love about it:
1) Color scheme for scripts. I can see at a glance what's a comment, and the parentheses pop out at you. This was something I envied about Macs when I used to use my PC exclusively. I do wish you could personalize it a little more, but the schemes they have are great. I personally like Cobalt.
2) Balancing parentheses and quotations. Yes, this can get obnoxious if you are tweaking existing code rather than starting from scratch, since if you try to type an end quote, it will be interpreted as another beginning quote. But I find being able to see what's matching your current end parenthesis incredibly helpful. Besides, if you don't like it, you can easily turn it off in the preferences.
3) Everything in one window. This wasn't a step up from my PC version since the normal R console keeps everything in one window, but it's so nice to have everything (script, console, history, help pages, graphics) in one window.
1) Color scheme for scripts. I can see at a glance what's a comment, and the parentheses pop out at you. This was something I envied about Macs when I used to use my PC exclusively. I do wish you could personalize it a little more, but the schemes they have are great. I personally like Cobalt.
2) Balancing parentheses and quotations. Yes, this can get obnoxious if you are tweaking existing code rather than starting from scratch, since if you try to type an end quote, it will be interpreted as another beginning quote. But I find being able to see what's matching your current end parenthesis incredibly helpful. Besides, if you don't like it, you can easily turn it off in the preferences.
3) Everything in one window. This wasn't a step up from my PC version since the normal R console keeps everything in one window, but it's so nice to have everything (script, console, history, help pages, graphics) in one window.
Subscribe to:
Comments (Atom)