[R-sig-phylo] diversitree with multicore

Rafael Maia queirozrafaelmv at yahoo.com.br
Wed Mar 21 17:56:32 CET 2012


hi Rafael,

I have recently conducted diversitree analysis in a cluster. The only way I got it to work was using the Rmpi package (I couldn't get multicore to detect cores in multiple nodes, so it was limited to the number of cores in a single node, in my case 8; with Rmpi there wasn't such limit).

To pass multiple arguments, what I did was create a wrapper function that included within it the defining parameters, the likelihood function, and in my case the MCMC run. Then I just iterated this wrapper function on my trees, in parallel, using an apply-like function from the Rmpi package.

If you want to see what my script looks like just let me know and I'd gladly share it with you.

Abraços,
Rafael Maia
---
webpage: http://gozips.uakron.edu/~rm72
"A little learning is a dangerous thing; drink deep, or taste not the Pierian spring." (A. Pope)
Graduate Student - Integrated Bioscience
University of Akron
http://gozips.uakron.edu/~shawkey/

On Mar 21, 2012, at 12:38 PM, David Bapst wrote:

> Hey Rafael-
> Hey, I'm using mclapply right now! What I'm doing with it is a trick I use
> often in lapply and sapply statements. If I have, say a list 'A' and a
> vector 'B' of the same length that I want to analyze in a lapply statement
> which analyzes each corresponding pair, I do the following:
> 
> mclapply(1:length(A),function(x) myfunctionhere(A[[x]], B[x]))
> 
> So, in this way, you could put each likelihood function in a list with the
> corresponding starting parameters in another list of the same length and
> then use the code above.
> 
> Also, you can also do more complex things, say if you want to end up with a
> nested list where you analyze each element of A with every element of B...
> mclapply(1:length(A),function(x) lapply(1:length(B),function(y)
> myfunctionhere(A[[x]], B[y]))
> 
> -Dave
> 
> 
> On Wed, Mar 21, 2012 at 10:58 AM, Rafael Rubio de Casas <rafa at nescent.org>wrote:
> 
>> Dear all,
>> I have been trying to come up with easy ways to split diversitree runs
>> among processors when using multiple trees. It seems that the multicore
>> package would be a good way of doing it, but I have failed to use
>> multicore with diversitree functions. Essentially, I cannot figure out
>> how to tell multicore that the function takes two set of objects, one
>> containing the likelihood functions and another one containing the
>> parameters. Does anybody have experience and/or advice doing this? Any
>> guidance would be most welcome.
>> Other alternatives for splitting diversitree jobs among processors would
>> also be highly appreciated.
>> Thanks in advance,
>> Rafa
>> --
>> National Evolutionary Synthesis Center
>> *NESCent <http://www.nescent.org/>*
>> 2024 W. Main Street, Suite A200
>> Durham, NC27705
>> rafa at nescent.org <mailto:rfr6 at duke.edu>
>> 919.668.9107
>> 
>>       [[alternative HTML version deleted]]
>> 
>> _______________________________________________
>> R-sig-phylo mailing list
>> R-sig-phylo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
>> 
> 
> 
> 
> -- 
> David Bapst
> Dept of Geophysical Sciences
> University of Chicago
> 5734 S. Ellis
> Chicago, IL 60637
> http://home.uchicago.edu/~dwbapst/
> http://cran.r-project.org/web/packages/paleotree/index.html
> 
> <http://home.uchicago.edu/%7Edwbapst/>
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-phylo mailing list
> R-sig-phylo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo



More information about the R-sig-phylo mailing list