Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-13 Thread David Bapst
Hello Rob and Antigoni, Would the following meet your purposes? Cheers, -Dave Bapst, UChicago library(ape) tree-rtree(30) #you can use your own tree here or rcoal() or whatever Nchanges-10#number of shifts at nodes nodeShifts-sample((2:Nnode(tree))+Ntip(tree),Nchanges)

Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-13 Thread Antigoni Kaliontzopoulou
Hello Dave, from my part, yes, this does exactly what I wanted to do. As far as I understood, it is also what Rob was suggesting. Thanks to everyone for helping with this. Cheers, Antigoni On 10/13/2011 07:02 AM, David Bapst wrote: Hello Rob and Antigoni, Would the following meet your

Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-13 Thread Antigoni Kaliontzopoulou
Hello again everyone, forwarded is some code provided by Dave Bapst for simulating a certain number of trait shifts in nodes AND tracking those changes as you go. This code will simulate Nchanges shifts and give both tip (tipChar) and node (intNodeChar) states at the end of the run. Dave

Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-12 Thread Antigoni Kaliontzopoulou
Hi Liam, thank you very much for this. Yes, the function works beautifully for what we wanted to do and the code you sent greatly facilitates implemantation. I was, however, wondering whether you can somehow limit the shifts to happen in nodes, to avoid character reversals across a single

Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-12 Thread Rob Lanfear
Hi Antigoni, I had been thinking about some of these kinds of simulations recently too. One challenge I encountered (which is similar to your problem here, if I've understood it) was how to make my simulations actually relevant. Specifically, given a particular tree I needed to simulate data

Re: [R-sig-phylo] Simulating binomial trait shifts on a phylogeny

2011-10-11 Thread Liam J. Revell
Hi Antigoni. I have a function in the new version of phytools called sim.history() that might help with this. This version is not available yet on CRAN, but it can be downloaded from my webpage: http://anolis.oeb.harvard.edu/~liam/R-phylogenetics/. The function generates stochastic