Re: [R-sig-phylo] phylo from igraph

2017-01-06 Thread Giulio V. Dalla Riva
Thanks Klaus! I could I've missed them!


Giulio Valentino Dalla Riva

Beaty Biodiversity Research Centre
University of British Columbia
Vancouver, Canada

From: Klaus Schliep <klaus.schl...@gmail.com>
Sent: January 6, 2017 2:34:49 PM
To: Giulio V. Dalla Riva
Cc: r-sig-phylo@r-project.org
Subject: Re: [R-sig-phylo] phylo from igraph

Hi Giulio,
there is an as_phylo function in igraph and as.igraph in ape.
Cheers,
Klaus




On Fri, Jan 6, 2017 at 5:02 PM, Giulio V. Dalla Riva 
<gv...@uclive.ac.nz<mailto:gv...@uclive.ac.nz>> wrote:
Dear Phyloers,


Has anybody already implemented a function to convert an igraph graph object 
into a phylo object?


(Let's pretend we are in the best of the worlds and the graph object is indeed 
a tree and all).


Best,


Giulio Valentino Dalla Riva

Beaty Biodiversity Research Centre
University of British Columbia
Vancouver, Canada

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - 
R-sig-phylo@r-project.org<mailto:R-sig-phylo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/



--
Klaus Schliep
Postdoctoral Fellow
Revell Lab, University of Massachusetts Boston
http://www.phangorn.org/


[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] phylo from igraph

2017-01-06 Thread Giulio V. Dalla Riva
Dear Phyloers,


Has anybody already implemented a function to convert an igraph graph object 
into a phylo object?


(Let's pretend we are in the best of the worlds and the graph object is indeed 
a tree and all).


Best,


Giulio Valentino Dalla Riva

Beaty Biodiversity Research Centre
University of British Columbia
Vancouver, Canada

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] simulate tree by specifying taxa distance

2016-11-03 Thread Giulio V. Dalla Riva
Dear Guangchuang,


Wouldn't that require that the distance between root and current time is, at 
most, 0.05 (= 0.1 /2) ?

In that case, I believe you just need to rescale the tree you simulated. That 
can be done in a number of way according to which package you use, e.g., in 
phytool:

pbtree(n=1000,scale=0.05)


Best,

Giulio Valentino Dalla Riva

Beaty Biodiversity Research Centre
University of British Columbia
Vancouver, Canada

From: R-sig-phylo  on behalf of Yu, 
Guangchuang 
Sent: November 3, 2016 5:02:25 AM
To: r-sig-phylo@r-project.org
Subject: [R-sig-phylo] simulate tree by specifying taxa distance

Dear all,

I want to simulate tree with restricted taxa distances (e.g. all taxa
distance should be less than 0.1). Is there any R package can do this?

Best wishes,
Guangchuang
--
--~--~-~--~~~---~--~~
Guangchuang Yu, PhD Candidate
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong
Hong Kong SAR, China
www: https://guangchuangyu.github.io
-~--~~~~--~~--~--~---

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] Making ultrametric trees

2016-10-31 Thread Giulio V. Dalla Riva
My 2cents on this.


TL;DR: there *may* be good information in the non ultrametric tree, which we 
may *not* want to throw away lightheartedly.

Long version: A phylogenetic model variance-covariance matrix is not, in 
general, the same thing of the pairwise phylogenetic distance matrix. They are 
proportional only in the case the rate of phenotypic evolution is constant 
across the tree (e.g., a Brownian Motion with one regime). In that case the 
"time available for phenotypic evolution" is, indeed, a predictor of the 
expected variance (and covariance) of a trait. But that is not always the case.


And, indeed, "a model allowing for variation in rate of trait evolution" *does* 
correspond to a transformation of the "original" (time calibrated, ultrametric) 
phylogenetic tree into a tree, in general non ultrametric, where the length of 
the branches correspond to the expected amount of evolution. i.e., a model of 
punctuated evolution on the original tree corresponds to a Brownian Motion on a 
rescaled tree where each (inner or pendant) branch has the same length.


A timed tree from molecular data may, actually, highlight how certain lineages 
evolved under a different mutation/selection regime to other branches. And the 
power to detect accelerated/slowed evolutionary rate may be higher from 
molecular data than from phenotypic data, so throwing that information away 
forcing the tree to be ultrametric may not be the best strategy. For example, 
there may be some particular trait that exhibit a different pattern from the 
overall evolutionary rate of the set of species we are looking at (e.g., a very 
labile trait evolving fast on some lineages where evolution is slow, or vice 
versa).


I think there's a question there that need to be addressed: why were the trees 
non ultrametric at the first place?


Giulio Valentino Dalla Riva

Beaty Biodiversity Research Centre
University of British Columbia
Vancouver, Canada

From: R-sig-phylo  on behalf of Alejandro 
Gonzalez Voyer 
Sent: October 31, 2016 12:56:02 PM
To: Emmanuel Paradis
Cc: R-phylo Mailing-list; Shinichi Nakagawa
Subject: Re: [R-sig-phylo] Making ultrametric trees

Hi,

>> Note that vcv(nonultrametric_tree, cor=TRUE) is different from
>> vcv(chronoMPL(nonultrametric_tree), cor = TRUE), which is relates to my
>> previous question (which one is preferred?)
>
> It (mainly) depends whether you want to assume a "clock-like" evolution for 
> the traits you are studying.

Assuming that Sinichi is working with contemporaneous species, the assumption 
of comparative analyses is that the time available for phenotypic evolution 
(the off diagonal element of the VCV matrix) is the same for all species. The 
rate of phenotypic evolution may of course differ among species, but I think 
that this is not the same as allowing the expected change in the traits to 
depend on the branch lengths of a non-ultrametric tree, as would be the case in 
vcv(nonultrametric_tree, cor=TRUE). In such a case, a model allowing for 
variation in rate of trait evolution in conjunction with an ultrametric tree 
would be more appropriate. Of course, as pointed out by Brian, estimating 
divergence times is no piece of cake and there may be uncertainty associated 
with that step of phylogeny estimation as well.

Cheers

Alejandro

___
Dr Alejandro Gonzalez Voyer
Newton Advanced Fellow
Investigador Asociado C

Laboratorio de Conducta Animal
Instituto de Ecolog�a
Circuito Exterior S/N
Ciudad Universitaria
Universidad Nacional Aut�noma de M�xico
M�xico, D.F.
04510
M�xico

Tel: +52 55 5622 9044
E-mail: alejandro.gonza...@iecologia.unam.mx

Lab website: 
www.alejandrogonzalezvoyer.com

> El 31/10/2016, a las 1:30 p.m., Emmanuel Paradis  
> escribi�:
>
> Le 30/10/2016 � 03:09, Shinichi Nakagawa a �crit :
>> Dear Emmanuel and Alejandro
>>
>> Many thanks for your replies.
>>
>> Emmanuel, I understand what you said if I use vcv(nonultrametric_tree,
>> cor=FALSE) in a phylogenetic comparative method (PCM). But if I use
>> vcv(nonultrametric_tree, cor=TRUE), isn't this the same as assuming a
>> ultrametric tree? I may be missing something here?
>
> No, this is not necessarily the same thing since the off-diagonal elements of 
> the matrices may be different depending on how branch lenghts are changed by 
> chronoMPL (or other procedures you might use to make the tree ultrametric).
>
>> Note that vcv(nonultrametric_tree, cor=TRUE) is different from
>> vcv(chronoMPL(nonultrametric_tree), cor = TRUE), which is relates to my
>> previous question (which one is preferred?)
>
> It (mainly) depends whether you want to assume a "clock-like" evolution for 
> the traits you are studying.
>
> Cheers,
>
> Emmanuel
>
>> Many thanks
>>
>> Shinichi
>>
>> On Sun, Oct 30, 2016 at 9:53 AM, Alejandro 

Re: [R-sig-phylo] plot trees distribution

2016-01-05 Thread Giulio V. Dalla Riva
Wonderful!

Thank  you so much, Liam. That's perfect (also for plotSimmap).
I'll gist the code in a couple of days.

Best,

Giulio Valentino Dalla Riva

PhD @ Biomathematics Research Centre
Room 523 - Erskine Building
University of Canterbury
Christchurch - New Zealand

phone: +64 3 364 2987 ext 4869


From: Liam J. Revell <liam.rev...@umb.edu>
Sent: Wednesday, 6 January 2016 12:37 p.m.
To: Giulio V. Dalla Riva; r-sig-phylo@r-project.org
Subject: Re: [R-sig-phylo] plot trees distribution

Hi Giulio.

You could try something like:

trees<-read.nexus("Wayqecha.tree")
trees<-read.tree(text=write.tree(trees))
plotTree(trees[[1]],color=rgb(0,0,1,0.05),ftype="i")
par(fg="transparent")
for(i in 2:length(trees)) plotTree(trees[[i]],
tips=setNames(1:Ntip(trees[[1]]),trees[[1]]$tip.label),
color=rgb(0,0,1,0.05),add=TRUE,ftype="i")
par(fg="black")

which has the effect of rescaling all the trees to have the same total
depth. It may be possible to circumvent this using xlim - I'd have to
check. This is similar to densiTree (I believe) in phangorn.

If you want to use plotSimmap, you can just substitute plotSimmap and
use a named vector of colors - however you should still generate the
colors with transparency using rgb.

Let us know if this is what you had in mind.

All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 1/5/2016 7:01 PM, Giulio V. Dalla Riva wrote:
> Dear Everybody,
>
>
> I have a list of phylogenies downloaded from the wonderful birdtree.org
> (in fact, it's a multiPhylo object) that I want to plot.
>
>
> The idea is obtain a representation of the empirical distribution of the
> phylogenies, in a graphical style similar to the
> phytools::fancyTree(type = "phenogram95") representation of the
> ancestral state reconstruction of a continuous character (see the fourth
> plot in http://www.phytools.org/eqg/Exercise_5.2/):
>
> plot of chunk unnamed-chunk-6
>
>
> In my case I would like to overlap each tree in the list, in some nice
> way. I can ladderize the first tree and use the produced tip order for
> all the other trees. This should (at least in my mind) produce an
> immediate representation of the metric and topological variance present
> in the list (which, in my case, is reasonably little).
>
>
> I could just compute a bootstrap, and plot support values on the splits.
> But it's not the same.
>
>
> I thought to remember there was a builtin function in some package, but
> I may be wrong.
>
> I have attached the nexus file for reference (this is a 100 trees,
> usually we would have 1000 or more).
>
>
> Best wishes,
>
>
> Giulio Valentino Dalla Riva
>
> P.S. A bonus point if anybody proposes a solution that works
> with|plotSimmap| for painted trees.
>
> PhD @ Biomathematics Research Centre
> Room 523 - Erskine Building
> University of Canterbury
> Christchurch - New Zealand
>
> phone: +64 3 364 2987 ext 4869
>
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


[R-sig-phylo] root edge issue in picante::evol.distinct()

2015-08-09 Thread Giulio V. Dalla Riva
Dear all,


I'm trying to compute the evolutionary distinctiveness of the tips of a tree
```R

tre - collapse.singles(read.newick(tree.phy))

evol.distinct(tre)

```

and I'm getting this error:

```R
Error in while (!(edge %in% root.edge)) { : argument is of length zero
In addition: Warning message:
In while (!(edge %in% root.edge)) { :
  the condition has length  1 and only the first element will be used
```
which, if I am not wrong, traces back to `.get.nodes()`. The problem _probably_ 
depends on the tree being originally unrooted, but persists if I to `reroot` it 
on an inner node. That is, anything like
```R
nod-fastMRCA(tre,Actinocyclus_actinochilus,Tursiops_truncatus) #this two 
are far away
tre - reroot(tre,node.number = nod, position = 
0.5*tre$edge.length[which(tre$edge[,2]==nod)])
```
seems not to be a solution (thanks to Liam Revell for the rerooting solution).


The original (unrooted) tree.phy so to replicate the error is here 
http://pastebin.com/QtGRKpfp


Best wishes,


Giulio Valentino Dalla Riva

PhD @ Biomathematics Research Centre
Room 523 - Erskine Building
University of Canterbury
Christchurch - New Zealand

phone: +64 3 364 2987 ext 4869

[[alternative HTML version deleted]]

___
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/


Re: [R-sig-phylo] PGLS - I have more taxa in my data set than in my phylogeny

2014-08-07 Thread Giulio V. Dalla Riva
Dear Anna,

My first answer would be to insert the individuals in the phylogeny from the 
beginning. But: how closely related do you expect the traits of individuals in 
the same species to be? If you can't answer soundly to this question, my 
approach would be not meaningful.

What PGLS need is a correlation structure matrix for the phylogeny. Roughly, 
you can see that as a matrix of pairwise phylogenetic distances between species 
(if you may assume that the traits evolved in a brownian motion way). If you 
have more than one individual per species you can add them to the matrix adding 
a row and a column for each extra individual. The distance with the individuals 
in the other species can be thought to be the same.

But, if I understood your scenario correctly, there may be a problem with the 
way you determine the distance between two individuals in the same species, as 
you miss the genetic information for the individuals. Not knowing how closely 
related are individuals compares to the species, may result in an arbitrary 
placement of the individuals pendant branches. Very short branches means really 
high correlation, long branches low correlation. Deciding the length of the 
branches for the individuals based on their traits would probably produce a 
risky circularity, if you then use those branch lengths to estimate the fit of 
the traits to an evolutionary model.

Anyhow, this is just an early morning answer, hence I suggest you to wait for 
other, more expert, answers.

Best,


Giulio Valentino Dalla Riva
PhD candidate @ Biomathematics Research Centre
University of Canterbury
Christchurch, NZ
Phone: +64 3642987 ext 4869

 On 8/08/2014, at 6:35 am, Anna Bastian anna.bast...@uct.ac.za wrote:
 
 Hello,
 
 I want to do a PGLS. The problem is that I have more taxa in my data set then 
 in my phylogeny.
 
 The questions are: Are peak frequency and skull length correlated? Are bite 
 force and skull length correlated? Are nasal capsule volume and skull length 
 correlated?
 
 I have ten species and each species has data for at least 2 individuals.
 The phylogeny on the other hand has only the ten species.
 
 Is there a way to use the same taxa at the tips of the phylogeny for more 
 than one row (=individual) in my data?
 
 I did the PGLS with the averaged data for a species so that I had exactly the 
 same number of entries (ten species in phylogeny and ten species in data). 
 The following regressions lacked statistical power possible due to the low 
 number of samples (ten species versus 61 individuals of ten species).
 I extracted the residuals for each of the ten species and plotted e.g. skull 
 length versus peak frequency.
 
 Could I use the residual for a species and apply it for each individual of 
 that species?
 Meaning, removing/subtracting the same amount of variation which is explained 
 by phylogeny from the value of each individual belonging to that species.
 
 Wouldn't this way give me the same result then using a tree with polytomies 
 representing the individuals within each species clade?
 
 I am absolutely unsure if any of this is statistically correct and would 
 appreciate if somebody with a more profound knowledge in this procedure could 
 provide advice.
 Thank you very much for your time and help
 
 Anna
 
 Here is our script used for the ten species:
 setwd(xy)
 regdata-read.table(reg.txt,sep=\t,header=TRUE)
 phyl-read.nexus(xy.nex)
 cdata-comparative.data(phy=phyl,data=regdata,names.col=Species,vcv=TRUE,na.omit=FALSE,warn.dropped=TRUE)
 brcor-corBrownian(phy=phyl)
 library('nlme')
 BFvsSKL.pgls-pgls(LogBF~logSKL,data=cdata,lambda='ML')
 summary(BFvsSKL.pgls)
 
 
 ...and the output:
 Call:
 pgls(formula = LogBF ~ logSKL, data = cdata, lambda = ML)
 
 Residuals:
 Min   1Q   Median   3Q  Max
 -0.10204  0.01829  0.02849  0.04665  0.05957
 
 Branch length transformations:
 
 kappa  [Fix]  : 1.000
 lambda [ ML]  : 1.000
   lower bound : 0.000, p = 0.047565
   upper bound : 1.000, p = 1
   95.0% CI   : (0.041, NA)
 delta  [Fix]  : 1.000
 
 Coefficients:
Estimate Std. Error t value  Pr(|t|)
 (Intercept) -4.056690.58857 -6.8924 0.0001255 ***
 logSKL   3.374580.44153  7.6430 6.057e-05 ***
 ---
 Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
 
 Residual standard error: 0.05415 on 8 degrees of freedom
 Multiple R-squared: 0.8795,Adjusted R-squared: 0.8645
 F-statistic: 58.42 on 1 and 8 DF,  p-value: 6.057e-05
 names(BFvsSKL.pgls)
 [1] model formula   call  RMS   NMS   NSSQ  
 RSSQ  aic   aicc
 [10] n k sterr fittedresiduals phyres
 x data  varNames
 [19] y param mlValsnamey boundsVt
 dname param.CI
 BFvsSKL.pgls[[14]]
  [,1]
 Species1 -0.22451460
 Species2 -0.04249437
 Species3 -0.04078567
 Species4 -0.14226713
 Species5 -0.11653145
 Species6  0.17663610
 Species7  0.10586335