Thanks Emmanuel. This did the trick. I greatly appreciate your help.

Best,
Martin

On 15 July 2015 at 18:42, Emmanuel Paradis <[email protected]> wrote:

> Martin,
>
> I have fixed the code. In fact, phydataplot() plots the tree and the data
> in the same plotting region so both share the same scales in x and y.
> Because the data and the branch lengths of the tree can be on quite
> different scales (which is your case), I have added a new option (scaling)
> to rescale the data.
>
> For your data, because sample sizes are different across species, you have
> to provide them as a list. This can be done with:
>
> X <- split(zt$med_, zt$scinam)
>
> I had something quite nice with:
>
> plot(tree, x.lim = 400)
> phydataplot(X, tree, "bo", offset = 50, scaling = 10)
>
> And with the '...' you can add colors, etc.
>
> Best,
>
> Emmanuel
>
>
> Le 15/07/2015 17:28, Martin Bulla a écrit :
>
>> Dear Emmanuel,
>>
>> I have managed to tweak the Liam's code by ordering the variables in the
>> below described manner (example 1), but I am failing to reproduce the
>> plot with the use of the new phydataplot() (example 2):
>>
>> example 1 (same data as in my previous message)
>> http://www.dropbox.com/sh/feinkkbb02ur9pi/AAAJs1WcB52A4GifNew4ESAqa?dl=0
>>         # where scinam is the name of the species and med_ is the value
>> of the trait and tree is the tree
>>          ladderize(tree, right=T) -> tree2
>>          tip.order <- tree2$tip.label[tree2$edge[tree2$edge[, 2] <=
>> Ntip(tree2), 2]]
>>          mm=data.frame(scinam=tip.order, order_=c(1:31))
>>          zt$order_=mm$order_[match(zt$scinam,mm$scinam )]
>>          zt=zt[order(zt$order_),]
>>          par(mfrow=c(1,2))
>>              plotTree(tree2,mar=c(5.1,1.1,2.1,0.1))
>>              par(mar=c(5.1,0.1,2.1,1.1))
>>
>> boxplot(zt$med_~zt$order_,horizontal=TRUE,axes=FALSE,xlim=c(1,Ntip(tree)))
>>              axis(1)
>>              title(xlab="Median bout length per nest [h]")
>>
>> example 2 (uses ordered data from above) gives warning message and
>> likely only medians - definitely not boxplots:
>>
>> https://www.dropbox.com/s/y08ts8n50vxk0bp/phyloplot_boxplot_tryout.png?dl=0
>>          xe=setNames(zt$med_,zt$scinam)
>>          plot(tree2, label.offset=35)
>>          phydataplot(xe, tree2, style = "boxplot", offset = 8)
>> Warning messages:
>> 1: In min(o$out) : no non-missing arguments to min; returning Inf
>> 2: In max(o$out) : no non-missing arguments to max; returning -Inf
>>
>> ​I wonder what goes wrong.
>> Best,
>> Martin​
>>
>> On 15 July 2015 at 16:29, Emmanuel Paradis <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>     Hi Martin.
>>
>>     I've modified phydataplot() so that it accepts style = "boxplot" and
>>     style = "dotchart" too. The version is on GH:
>>
>>     https://github.com/emmanuelparadis/phydataplot
>>
>>     The "boxplot" feature requires a data matrix with rownames
>>     eventually matching the tip labels.
>>
>>     Best,
>>
>>     Emmanuel
>>
>>     Le 15/07/2015 14:03, Martin Bulla a écrit :
>>
>>         Dear Liam,
>>
>>         Thank you very much for your helpful reply. I can replicate your
>>         example,
>>         but with my data, I get the boxplots assigned to the wrong
>>         species. I am
>>         sure it is an ordering issue, but I am not sure where it goes
>> wrong.
>>
>>         Your suggestions would help me please.The script, as well as the
>>         data are
>>         here:
>>         ​​
>>
>> http://www.dropbox.com/sh/feinkkbb02ur9pi/AAAJs1WcB52A4GifNew4ESAqa?dl=0
>>
>>         Best wishes,
>>         Martin
>>
>>
>>         On 14 July 2015 at 16:28, Liam J. Revell <[email protected]
>>         <mailto:[email protected]>> wrote:
>>
>>             Hi Martin.
>>
>>             The easiest way to do this is to create two side-by-side
>>             plots using
>>             par(mfcol=c(1,2)) and then put your tree & your boxplot in
>>             the two plots;
>>             however one has to be very careful in that case to ensure
>>             that the tips
>>             align to the correct boxes. I posted a demo of this to my
>>             blog. Let me know
>>             if this is helpful.
>>
>>
>> http://blog.phytools.org/2015/07/plotting-tree-with-adjacent-boxplot.html
>>
>>             All the best, Liam
>>
>>             Liam J. Revell, Assistant Professor of Biology
>>             University of Massachusetts Boston
>>             web: http://faculty.umb.edu/liam.revell/
>>             email: [email protected] <mailto:[email protected]>
>>             blog: http://blog.phytools.org
>>
>>
>>             On 7/14/2015 6:44 AM, Martin Bulla wrote:
>>
>>                 Dear list members,
>>
>>                 I wonder whether anyone of you has a code for
>>                 phyldataplot (or any other
>>                 plotting function) that allows for plotting the
>>                 distributions of variable
>>                 (e.g., boxplots) next to the phylogeny giving something
>>                 like:
>>
>>                 ​
>>
>> https://www.dropbox.com/s/2w48qceflgh1knc/boxplot_species_example2.png?dl=0
>>
>>                 Your suggestions would help me a lot please.
>>                 Best wishes,
>>                 Martin
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> Martin Bulla
>> PhD Student
>>
>> Department of Behavioural Ecology & Evolutionary Genetics
>> Max Planck Institute for Ornithology
>> Eberhard Gwinner Strasse 7
>> 82319 Seewiesen, Germany
>>
>> Tel: +49 (0) 8157 932 264
>> Fax: +49 (0) 8157 932 400
>> www.orn.mpg.de/bulla
>> <http://www.orn.mpg.de/409970/employee_page?employee_id=26243>
>> http://orn-mpg.academia.edu/MartinBulla
>>
>
>


-- 
Martin Bulla
PhD Student

Department of Behavioural Ecology & Evolutionary Genetics
Max Planck Institute for Ornithology
Eberhard Gwinner Strasse 7
82319 Seewiesen, Germany

Tel:  +49 (0) 8157 932 264
Fax: +49 (0) 8157 932 400
www.orn.mpg.de/bulla
<http://www.orn.mpg.de/409970/employee_page?employee_id=26243>
http://orn-mpg.academia.edu/MartinBulla

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to