Re: [R-sig-phylo] ape: error in pcoa

2021-04-26 Thread Juan Antonio Balbuena
Many thanks Emmanuel for the detailed instructions and sorry for the 
messed up formatting.

Best

Juan


El 24/04/2021 a las 9:03, Emmanuel Paradis escribió:
> Hi Juan,
>
> There is a bug in pcoa() when only one axis is selected by the function. You 
> can fix it by editing the function with fix(pcoa) and modify line 38 (or 
> close depending on how the editor arranges the lines of code):
>
> vectors <- sweep(D.eig$vectors[, 1:k], 2, sqrt(eig[1:k]), FUN = "*")
>
> insert ', drop = FALSE' where D.eig$vectoes is indexed so this line becomes:
>
> vectors <- sweep(D.eig$vectors[, 1:k, drop = FALSE], 2, sqrt(eig[1:k]), FUN = 
> "*")
>
> save and close. There are two other similar lines but they are not used in 
> your example. I've fixed that in ape 5.5 (which should be on CRAN soon).
>
> As a side note, it took me some time to figure out the shape of the data you 
> posted. Mail applications sometimes format lines of text in different ways, 
> so it's better to run a command like this:
>
> cat(deparse(DH), sep = "\n")
>
> and paste the output in your message. This can then be input with: DH <- 
> [[the output from above]] with the attributes correctly set.
>
> Best,
>
> Emmanuel
>
> - Le 23 Avr 21, à 21:24, Juan Antonio Balbuena j.a.balbu...@uv.es a écrit 
> :
>
>> Hellow,
>>
>> I am running a set of simulations with distance matrices used as input
>> to pcoa (package ape).
>>
>> In one instance the matrix (DH) is
>>
>> H18 H20 H21 H18 0.000 0.3127452190 0.3127452190 H20 0.3127452
>> 0.00 0.0001625185 H21 0.3127452 0.0001625185 0.00
>>
>> when I run pcoa I get this
>>
>> H.PCo <- pcoa(DH, correction="none")$vectors Error in array(STATS,
>> dims[perm]) : 'dims' cannot be of length 0
>>
>> However, if I multiply DH*10 pcoa runs just fine:
>>
>> H.PCo <- pcoa(DH*10, correction="none")$vectors
>>
>> A word of explanation will be very much appreciated.
>>
>> Thank you for your attention
>>   
>> Juan A. Balbuena
>>
>> --
>>
>> Dr. Juan A. Balbuena
>> Cavanilles Institute of Biodiversity and Evolutionary Biology
>> Symbiont Ecology and Evolution Lab
>> University of Valencia http://www.uv.es/~balbuena
>> <http://www.uv.es/%7Ebalbuena>
>> P.O. Box 22085 http://www.uv.es/cophylpaco <http://www.uv.es/cophylpaco>
>> 46071 Valencia, Spain
>> e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543
>> 658    fax +34 963 543 733
>> 
>> *NOTE!*For shipments by EXPRESS COURIER use the following street address:
>> C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.
>> 
>>
>>
>>  [[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/
-- 

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085 http://www.uv.es/cophylpaco <http://www.uv.es/cophylpaco>
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543 
658    fax +34 963 543 733

*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.



[[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] ape: error in pcoa

2021-04-23 Thread Juan Antonio Balbuena
Hellow,

I am running a set of simulations with distance matrices used as input 
to pcoa (package ape).

In one instance the matrix (DH) is

H18 H20 H21 H18 0.000 0.3127452190 0.3127452190 H20 0.3127452 
0.00 0.0001625185 H21 0.3127452 0.0001625185 0.00

when I run pcoa I get this

H.PCo <- pcoa(DH, correction="none")$vectors Error in array(STATS, 
dims[perm]) : 'dims' cannot be of length 0

However, if I multiply DH*10 pcoa runs just fine:

H.PCo <- pcoa(DH*10, correction="none")$vectors

A word of explanation will be very much appreciated.

Thank you for your attention

Juan A. Balbuena

-- 

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733

*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.



[[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] cophylo

2019-06-17 Thread Juan Antonio Balbuena

Hi

I don't see why you cannot it with cophylo. All comes down to 
configuring assoc (matrix containing the tip labels in tr1 to match to 
the tip labels in tr2) correctly.


All the best

Juan A. Balbuena

El 17/06/2019 a las 12:03, Sa
El 17/06/2019 a las 12:03, Saleh Rahimlouye Barabi escribió:


Hello,

I want to plot two phylogenetic trees face-to-face using 
phytools::cophylo function. I see there is no possibility to connect 2 
or 3 same taxa in a tree to one taxon in the other tree (attached). Is 
there anyway doing this in R?


Best

Saleh Rahimlou

Ph.D. Candidate

Department of Botany and Ecology

University of Tartu

14A Ravila, 50411 Tartu

Estonia

Email: saleh.rahim...@ut.ee 


___
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/

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 


P.O. Box 22085 http://www.uv.es/cophylpaco
46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] Help needed with dist.multiPhylo package distory

2019-03-22 Thread Juan Antonio Balbuena

Solved!

The trees included node support data and this was causing the problem.

Thanks for your attention.

Juan


--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] Help needed with dist.multiPhylo package distory

2019-03-22 Thread Juan Antonio Balbuena

Hi,

I am getting an error using dist.multiPhylo of package distory that I am 
unable to decipher.


I wish to compute the geodesic distance between 2 trees (t1 and t2) in 
nexus format (see copy below).


I combine them in a list:

L <- list(t1, t2) # then I invoke the function:

dist.multiPhylo(L) #and get the following error:

Error in dist.multiPhylo(x, method = method, force.multi2di = 
force.multi2di,  :
  An error was encountered in parsing near position 39: Couldn't figure 
out what to do after a second leaf entry


Any idea, help will be very much appreciated.

Juan

**

THE TREES:

t1:

#NEXUS
[R-package APE, Fri Mar 22 16:37:39 2019]

BEGIN TAXA;
    DIMENSIONS NTAX = 9;
    TAXLABELS
        Mugliz
        Mcepha1
        Chesub
        Lizahaem
        Lizaram
        Chelab
        Lizaaur
        Lizasal
        Valabuc
    ;
END;
BEGIN TREES;
    TRANSLATE
        1    Mugliz,
        2    Mcepha1,
        3    Chesub,
        4    Lizahaem,
        5    Lizaram,
        6    Chelab,
        7    Lizaaur,
        8    Lizasal,
        9    Valabuc
    ;
    TREE * UNTITLED = [] 
((1:0.00826986,2:0.02165651)985:0.3174293,(((3:0.08488147,4:0.09383585)969:0.02111665,(5:0.0488584,((6:0.03890206,7:0.03355451)545:0.00550473,8:0.04896926)594:0.01171567)930:0.02600083)545:0.06207831,9:0.13004227)321:0.00534938)195;

END;

***

t2:

#NEXUS
[R-package APE, Fri Mar 22 16:37:57 2019]

BEGIN TAXA;
    DIMENSIONS NTAX = 9;
    TAXLABELS
        Valabuc
        Chesub
        Lizasal
        Lizahaem
        Mugliz
        Mcepha1
        Lizaaur
        Chelab
        Lizaram
    ;
END;
BEGIN TREES;
    TRANSLATE
        1    Valabuc,
        2    Chesub,
        3    Lizasal,
        4    Lizahaem,
        5    Mugliz,
        6    Mcepha1,
        7    Lizaaur,
        8    Chelab,
        9    Lizaram
    ;
    TREE * UNTITLED = [] 
(1:0.44662136,(2:0.18111073,((3:0.06637225,(4:0.02497353,(5:0.04256194,6:0.03313771)561:0.00410113)966:0.06080073)909:0.05298036,(7:0.05777136,(8:0.03691804,9:0.04690791)1000:0.04129831)602:0.01447255)918:0.07520298)706:0.11656507)1000;

END;

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] Branch lengths in phytools::plot.cophylo

2018-12-12 Thread Juan Antonio Balbuena

You can try this:

tree<- compute.brtime(tree, tree$Nnode:1)

It will produce an ultrametric tree with its nodes well separated.

I hope it helps

All the best

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] plot heatmap at nodes

2018-09-04 Thread Juan Antonio Balbuena

Hi

You may like to try this

T <- rtree(10)  #random tree with 10 terminals
plot(T)
nodelabels(pie=((1:8)*10/100))

#Just replace (1:8)*10 with the actual values

I hope this helps

Juan A. Balbuena

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-16 Thread Juan Antonio Balbuena

Thanks Liam

I will update R and the libraries in both computers and see what happens.

All the best

Juan


El 15/05/2018 a las 17:52, Liam J. Revell escribió:
No idea. Are they running different R or package versions? 
phytools::midpoint.root has not been updated recently, but other 
internally used functions may have been.


All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 5/15/2018 10:49 AM, Juan Antonio Balbuena wrote:

Thank you very much for your quick response.

I have the tree file in a cloud. When I run the code in one computer 
I get the error, whereas in the other one it runs fine. I use Windows 
7 in both. So it is kind of weird.


Any idea of the reason?

All the best,

Juan


El 15/05/2018 a las 17:38, Liam J. Revell escribió:

Hello Juan.

I was able to read your tree & midpoint root it using 
phytools::midpoint.root no problem. I will paste the tree I created 
below, but note also that phangorn::midpoint is functionally 
equivalent & when I run:


tree<-read.tree(text=text) ## from your Newick string
t1<-midpoint.root(tree)
t2<-midpoint(tree)
all.equal.phylo(t1,t2)

I get TRUE.

All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 5/15/2018 10:29 AM, Juan Antonio Balbuena wrote:

Hi all

This is really odd. I am using a piece of ode that used to work 
just fine with the very same file shown below. I changed computer 
and now get this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its 
contents here:


(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.00256691,PfH10:0.002582213):0.001063792); 



Any help will be most welcome.


Juan





--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085 http://www.uv.es/cophylpaco 
<http://www.uv.es/cavanilles/zoomarin/index.htm>

46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-15 Thread Juan Antonio Balbuena

Thank you very much for your quick response.

I have the tree file in a cloud. When I run the code in one computer I 
get the error, whereas in the other one it runs fine. I use Windows 7 in 
both. So it is kind of weird.


Any idea of the reason?

All the best,

Juan


El 15/05/2018 a las 17:38, Liam J. Revell escribió:

Hello Juan.

I was able to read your tree & midpoint root it using 
phytools::midpoint.root no problem. I will paste the tree I created 
below, but note also that phangorn::midpoint is functionally 
equivalent & when I run:


tree<-read.tree(text=text) ## from your Newick string
t1<-midpoint.root(tree)
t2<-midpoint(tree)
all.equal.phylo(t1,t2)

I get TRUE.

All the best, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 5/15/2018 10:29 AM, Juan Antonio Balbuena wrote:

Hi all

This is really odd. I am using a piece of ode that used to work just 
fine with the very same file shown below. I changed computer and now 
get this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its 
contents here:


(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.00256691,PfH10:0.002582213):0.001063792); 



Any help will be most welcome.


Juan



--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085 http://www.uv.es/cophylpaco 
<http://www.uv.es/cavanilles/zoomarin/index.htm>

46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] midpoint.root Error in phy$edge[, 2] : incorrect number of dimensions

2018-05-15 Thread Juan Antonio Balbuena

Hi all

This is really odd. I am using a piece of ode that used to work just 
fine with the very same file shown below. I changed computer and now get 
this error:


library(ape)

TreeH <- read.tree("Pf_tree_short.nwk")

TreeH <- midpoint.root(TreeH)
Error in phy$edge[, 2] : incorrect number of dimensions


The file Pf_tree_short.nwk si pretty short, so I can copy its contents here:

(PfH1:0.001054642,PfH9:0.004127868,((PfH3:0.08953517,(((PfH6:0.02378674,((PfH34:0.00255086,PfH40:0.00253142):0.001075694,(PfH39:0.002549484,PfH57:0.002551486):0.001030445):8.177499E-4,((PfH36:0.002555701,PfH43:0.002524015):0.001047094,(PfH41:0.002543331,PfH45:0.004011249):0.001035931):7.855741E-4):9.836483E-4,(PfH35:0.001056611,PfH38:0.002496405):0.001112379):0.00252234,(PfH37:0.002543709,PfH42:0.001073064):0.002640093):0.002623932,PfH56:0.00276149):0.02310424):0.01273145,PfH48:0.003223183):0.004103919,PfH44:0.006145397):0.06303876):0.04205169,(((PfH12:0.001042118,PfH25:0.002470368):9.797E-4,(PfH13:0.002446243,PfH16:0.002441275):9.147032E-4):8.726904E-4,(PfH14:0.002486386,PfH21:0.0025004):0.001079044):0.001147637,(PfH19:0.002508287,PfH22:0.002461656):0.001011963):0.00115,PfH24:0.00242401):0.002458328,(PfH15:0.003791243,PfH17:0.001056495):0.001058053):0.003886796,PfH23:0.004767665):0.1242874):0.1359654,PfH60:0.001068025,PfH84:0.0025608):0.001109104,(PfH81:0.00250909,PfH82:0.002508367):0.001089697):0.001053748,PfH83:0.002545513):0.002170283,(PfH79:0.001092604,PfH80:0.002562978):0.002563944):1.774651):0.09853968,(PfH26:0.001054175,PfH33:0.002518196):0.001162092,(PfH29:0.002488133,PfH70:0.003882958):0.001150588):7.06569E-4,(((PfH28:0.002519167,PfH32:0.002553086):9.516619E-4,(PfH31:0.002530325,PfH66:0.002590319):0.00105028):9.560662E-4,((PfH30:0.002507623,PfH74:0.002610591):0.001005149,(PfH68:0.002510002,PfH69:0.002556393):0.001053178):0.002324076):4.840203E-4):6.291873E-4,((PfH67:0.002528606,PfH72:0.00404201):0.001078995,(PfH75:0.005680973,PfH76:0.002538044):0.001066169):3.313337E-4):0.002079495,((PfH27:0.001071028,PfH71:0.005683054):0.001274396,PfH73:0.002455681):0.002553291):0.01016512):0.01257902,(PfH62:0.001050343,PfH63:0.004185532):0.005860629):0.00256691,PfH10:0.002582213):0.001063792);

Any help will be most welcome.


Juan

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] plot.cophylo: some edges missing

2018-03-13 Thread Juan Antonio Balbuena

Worked like a charm.

¡Gracias!


El 13/03/2018 a las 17:38, Liam J. Revell escribió:

Try ftype="off".

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 3/13/2018 11:27 AM, Juan Antonio Balbuena wrote:

Hi,

Yes!! It worked! Thank you so much!

BTW, is there a way to supress the tip labels? show.tip.label=FALSE 
does not work.


All the best

Juan


El 13/03/2018 a las 17:12, Liam J. Revell escribió:

Hola Juan.

I'm guessing you are using an old version of phytools as this bug 
has been identified & should be fixed 
(http://blog.phytools.org/2017/08/bug-fix-in-plotcophylo-for-co.html). 
If you update to the latest CRAN version that should take care of 
it, but I recommend updating to the latest version on GitHub using 
devtools as follows:


library(devtools)
install_github("liamrevell/phytools")

Let us know if the problem persists.

Saludos, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 3/13/2018 11:09 AM, Juan Antonio Balbuena wrote:

Hi all

I am using cophylo in phytools to draw a large tanglegram 
(phylogenies with 29 and 129 terminals, and 129 associations 
between them). The problem is that only a fraction of the edges of 
the larger tree (to the right) are plotted.


This is the syntax used


obj <- cophylo(euglossini29, orchids, links, rotate.multi=TRUE)

#which apparently works well:

Rotating nodes to optimize matching...
Done.

plot.cophylo(obj, links.lwd=1, link.lty=2, fsize=0.4, pts=FALSE, 
link.type="curved")


# the resulting plot can be visualized here: 
https://www.uv.es/balbuena/PDF/Rplot.pdf



I usually work in RStudio but I got the same result in an ordinary 
R console. In addition, when I use cophyloplot (ape) with the same 
input, I am able to get the tanglegram.


I wonder what the problem might be and any help will by much 
appreciated.


Juan A. Balbuena









--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085 http://www.uv.es/cophylpaco 
<http://www.uv.es/cavanilles/zoomarin/index.htm>

46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] plot.cophylo: some edges missing

2018-03-13 Thread Juan Antonio Balbuena

Hi,

Yes!! It worked! Thank you so much!

BTW, is there a way to supress the tip labels? show.tip.label=FALSE does 
not work.


All the best

Juan


El 13/03/2018 a las 17:12, Liam J. Revell escribió:

Hola Juan.

I'm guessing you are using an old version of phytools as this bug has 
been identified & should be fixed 
(http://blog.phytools.org/2017/08/bug-fix-in-plotcophylo-for-co.html). 
If you update to the latest CRAN version that should take care of it, 
but I recommend updating to the latest version on GitHub using 
devtools as follows:


library(devtools)
install_github("liamrevell/phytools")

Let us know if the problem persists.

Saludos, Liam

Liam J. Revell, Associate Professor of Biology
University of Massachusetts Boston
& Profesor Asociado, Programa de Biología
Universidad del Rosario
web: http://faculty.umb.edu/liam.revell/

On 3/13/2018 11:09 AM, Juan Antonio Balbuena wrote:

Hi all

I am using cophylo in phytools to draw a large tanglegram 
(phylogenies with 29 and 129 terminals, and 129 associations between 
them). The problem is that only a fraction of the edges of the larger 
tree (to the right) are plotted.


This is the syntax used


obj <- cophylo(euglossini29, orchids, links, rotate.multi=TRUE)

#which apparently works well:

Rotating nodes to optimize matching...
Done.

plot.cophylo(obj, links.lwd=1, link.lty=2, fsize=0.4, pts=FALSE, 
link.type="curved")


# the resulting plot can be visualized here: 
https://www.uv.es/balbuena/PDF/Rplot.pdf



I usually work in RStudio but I got the same result in an ordinary R 
console. In addition, when I use cophyloplot (ape) with the same 
input, I am able to get the tanglegram.


I wonder what the problem might be and any help will by much 
appreciated.


Juan A. Balbuena





--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 
<http://www.uv.es/%7Ebalbuena>
P.O. Box 22085 http://www.uv.es/cophylpaco 
<http://www.uv.es/cavanilles/zoomarin/index.htm>

46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] plot.cophylo: some edges missing

2018-03-13 Thread Juan Antonio Balbuena

Hi all

I am using cophylo in phytools to draw a large tanglegram (phylogenies 
with 29 and 129 terminals, and 129 associations between them). The 
problem is that only a fraction of the edges of the larger tree (to the 
right) are plotted.


This is the syntax used


obj <- cophylo(euglossini29, orchids, links, rotate.multi=TRUE)

#which apparently works well:

Rotating nodes to optimize matching...
Done.

plot.cophylo(obj, links.lwd=1, link.lty=2, fsize=0.4, pts=FALSE, 
link.type="curved")


# the resulting plot can be visualized here: 
https://www.uv.es/balbuena/PDF/Rplot.pdf



I usually work in RStudio but I got the same result in an ordinary R 
console. In addition, when I use cophyloplot (ape) with the same input, 
I am able to get the tanglegram.


I wonder what the problem might be and any help will by much appreciated.

Juan A. Balbuena

--

Dr. Juan A. Balbuena
Cavanilles Institute of Biodiversity and Evolutionary Biology
Symbiont Ecology and Evolution Lab
University of Valencia http://www.uv.es/~balbuena 

P.O. Box 22085 http://www.uv.es/cophylpaco 


46071 Valencia, Spain
e-mail: j.a.balbu...@uv.es tel. +34 963 543 
658    fax +34 963 543 733


*NOTE!*For shipments by EXPRESS COURIER use the following street address:
C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.


___
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] A possible alternate MRCA function to APE\'s getMRCA

2017-06-09 Thread Juan Antonio Balbuena

  
  
Package phytools includes a function, findMRCA, that is supposed
  to work very efficiently with large trees. you may wish to compare
  it with your function.
Cheers
Juan

-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

   
	
  
		Libre de virus. www.avast.com 		
	

 


___
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] Rooting trees in R

2017-05-24 Thread Juan Antonio Balbuena

  
  
As a general reference text to handle phylogentic data and sequences
in R, you may have a look at
Paradis (2011) Analysis of Phylogenetics and Evolution in R, 2nd
edition. Springer.

Best wishes

Juan A. Balbuena 


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

   
	
  
		Libre de virus. www.avast.com 		
	

 


___
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] ace() Warning message:, In sqrt(1/out$hessian) : NaNs produced

2017-05-18 Thread Juan Antonio Balbuena

  
  
Hi Emmanuel,
Thank you so much for taking the pain to check this. Looking at
  my vector of frequencies (Pfreq[,2]) it is pretty clear that it is
  hard to believe that the trait variance conforms to BM. 

All the best
Juan


El 18/05/2017 a las 10:00, Emmanuel
  Paradis escribió:

Hi Juan,
  
  
  This warning seems related to the fact that the trait did not
  evolve according to the specified model (i.e., Brownian motion). I
  simulated some data with:
  
  
      tr <- rphylo(50, .1, 0)
  
      x <- rTraitCont(tr)
  
  
  ace(x, tr)$sigma did not return NA out of 1000 replications. I
  changed the second line to:
  
  
      x <- rnorm(50)
  
  
  and NAs were returned in 18 cases.
  
  
  In your case, since you simulated the data, it could be that their
  distribution does not conform well to the Brownian motion model.
  Maybe you could transform them or discretize them and use a
  discrete trait model (i.e., Markovian model, type = "d" in ace).
  
  
  HTH
  
  
  Best,
  
  
  Emmanuel
  
  
  Le 11/05/2017 à 15:54, Juan Antonio Balbuena a écrit :
  
  Hi all


I am playing around with synthetic cophylogenetic data. In one
example, which represents a very extreme case of high agreement
between the host and parasite phylogenies (the data was
generated with 51 cospeciation, 2 sorting and 1 duplication
events), I get a warning when using ace() to label the
cophylogenetic nodes of the parasite tree:


fit.P<-ace(Pfreq[,2],obj$trees[[2]])

Warning message:

In sqrt(1/out$hessian) : NaNs produced


Where Pfreq[,2] is a vector of frequencies:


 >  Pfreq[,2]

  [1] 100.0 100.0  69.70874 100.0 100.0
100.0 100.0 100.0

  [9] 100.0 100.0 100.0  37.86408  38.44660 
62.13592 61.55340 100.0

[17] 100.0 100.0 100.0 100.0 100.0 100.0
100.0 100.0

[25] 100.0 100.0 100.0 100.0  62.13592 100.0
100.0 100.0

[33] 100.0 100.0 100.0 100.0 100.0 100.0
100.0 100.0

[41] 100.0 100.0  68.15534 100.0 100.0 100.0
100.0 100.0

[49] 100.0 100.0 100.0 100.0 100.0


The following works fine


nodelabels.cophylo(pie=fit.P$ace/100,
piecol=c("green","red"),cex=0.5, which="right")


but I have noticed that there is a NA in fit.P$sigma2. It would
be nice to know whether this warning is important or not.


Thank you very much for your attention.


Juan A. Balbuena



-- 

Dr. Juan A. Balbuena

Cavanilles Institute of Biodiversity and Evolutionary Biology

University of Valencia http://www.uv.es/~balbuena


P.O. Box 22085 http://www.uv.es/cophylpaco


46071 Valencia, Spain

e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel.
+34 963 543 658    fax +34 963 543 733



*NOTE!*For shipments by EXPRESS COURIER use the following street
address:

C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.





Pour nous remonter une erreur de filtrage, veuillez vous rendre
ici 





___

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/



Pour nous remonter une erreur de filtrage, veuillez vous rendre
ici : http://f.security-mail.net/301EU0Nrv8J


  
  


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/

[R-sig-phylo] ace() Warning message:, In sqrt(1/out$hessian) : NaNs produced

2017-05-11 Thread Juan Antonio Balbuena

  
  
Hi all
I am playing around with synthetic cophylogenetic data. In one
  example, which represents a very extreme case of high agreement
  between the host and parasite phylogenies (the data was generated
  with 51 cospeciation, 2 sorting and 1 duplication events), I get a
  warning when using ace() to label the cophylogenetic nodes of the
  parasite tree:
fit.P<-ace(Pfreq[,2],obj$trees[[2]])
  Warning message:
  In sqrt(1/out$hessian) : NaNs produced
Where Pfreq[,2] is a vector of frequencies:
>  Pfreq[,2]
   [1] 100.0 100.0  69.70874 100.0 100.0 100.0
  100.0 100.0
   [9] 100.0 100.0 100.0  37.86408  38.44660  62.13592 
  61.55340 100.0
  [17] 100.0 100.0 100.0 100.0 100.0 100.0
  100.0 100.0
  [25] 100.0 100.0 100.0 100.0  62.13592 100.0
  100.0 100.0
  [33] 100.0 100.0 100.0 100.0 100.0 100.0
  100.0 100.0
  [41] 100.0 100.0  68.15534 100.0 100.0 100.0
  100.0 100.0
  [49] 100.0 100.0 100.0 100.0 100.0
The following works fine

nodelabels.cophylo(pie=fit.P$ace/100,
  piecol=c("green","red"),cex=0.5, which="right")

but I have noticed that there is a NA in fit.P$sigma2. It would
  be nice to know whether this warning is important or not.
Thank you very much for your attention.
Juan A. Balbuena


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] simulate additive trees based on ultrametric trees

2017-02-23 Thread Juan Antonio Balbuena

  
  
Hi all
I am using core-gen (Keller-Schmidt et al. 2011
  https://www.bioinf.uni-leipzig.de/Publications/PREPRINTS/11-013.pdf)
  to simulate host and parasite phylogenies. For each instance, a
  get a pair of ultrametric trees reflecting the coevolutionary
  history of host and parasite taxa. 

I was wondering what is the best way to simulate gene trees (i.e.
  additive trees) preserving the topology of the ultrametric ones. I
  tried to simulate sequence evolution (1000 nucleotids) under the
  GTR +Γ evolution model, using phylosim, and reconstruct the
  phylogenies by ML and BI. The problem is that the resulting
  phylogenies differ from the original topologies. 

Any help will be much appreciated. Thank you very much for your
  attention.

Juan A. Balbuena

-- 

  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] Enigmatic error with drop.tip

2017-01-24 Thread Juan Antonio Balbuena

  
  
Hi Klaus and Emmanuel,
I am very grateful for your help. 

All the best
Juan Antonio


El 23/01/2017 a las 14:48, Emmanuel
  Paradis escribió:

Hi Klaus,
  
  
  Thanks for tracking this. It's fixed.
  
  
  Best,
  
  
  Emmanuel
  
  
  Le 20/01/2017 à 18:41, Klaus Schliep a écrit :
  
  Hi Juan,

it seems that you trim too many taxa.


I can replicate the error message if I trim for example 19 out
of a 20 tips

of a tree.

drop.tip(tree, sample(20, 19))

Error in integer(max(oldnodes)) : vector size cannot be infinite

In addition: Warning message:

In max(oldnodes) : no non-missing arguments to max; returning
-Inf

traceback()
  

3: integer(max(oldnodes))

2: collapse.singles(phy)

1: drop.tip(tree, sample(20, 19))


Maybe you include a check into your function z that the pruned
trees have

at least two tips left

if( length( setdiff(treeP$tip.label, colnames(hp))) < (
length(

treeP$tip.label ) -2 ) )


Cheers,

Klaus




On Fri, Jan 20, 2017 at 7:26 AM, Juan Antonio Balbuena
<j.a.balbu...@uv.es>

wrote:


Hello all
  
  
  I am working with a cophylogenetic problem where I have a host
  tree, a
  
  parasite tree and a binary matrix HP encapsulating the
  host-parasite
  
  associations . After trimming the matrix according to a given
  criterion, I
  
  require to prune the trees accordingly. Since I am getting
  errors at the
  
  execution I devised the following control function to check
  the number of
  
  tree nodes after pruning:
  
  z <- function (hp, treeH,treeP) {
  
    treeh <- drop.tip(treeH, setdiff(treeH$tip.label,
  rownames(hp)))
  
    treep <- drop.tip(treeP, setdiff(treeP$tip.label,
  colnames(hp)))
  
    res <- c(treeh$Nnode,treep$Nnode)
  
   return(res)
  
   }
  
  
  Then I try the following
  
  
  x <- sapply (THP, z, treeH=TreeH[[7]], treeP= TreeP[[7]])
  
  
  where THP is a list of trimmed HP matrices and TreeH and TreeP
  are
  
  multiphylo objects and get the following error:
  
  
  Error in integer(max(oldnodes)) : vector size cannot be
  infinite
  
  
  The traceback is
  
  
  6. integer(max(oldnodes))
  
  5. collapse.singles(phy)
  
  4. drop.tip(treeP, setdiff(treeP$tip.label, colnames(hp)))
  
  3. FUN(X[[i]], ...)
  
  2. lapply(X = X, FUN = FUN, ...)
  
  1. sapply(THP, z, treeH = TreeH[[7]], treeP = TreeP[[7]])
  
  
  This error appears only with this particular pair of host and
  parasite
  
  trees (#7) and I cannot find a reason why this case should be
  different.
  
  
  Any help will be very much appreciated.
  
  
  Juan A. Balbuena
  
  
  --
  
  
  Dr. Juan A. Balbuena
  
  Cavanilles Institute of Biodiversity and Evolutionary Biology
  
  University of Valencia
  
  http://www.uv.es/~balbuena
  
  P.O. Box 22085
  
  http://www.uv.es/cophylpaco
  
  
  
  46071 Valencia, Spain
  
  e-mail: j.a.balbu...@uv.es    tel. +34 963 543 658
  
  <+34%20963%2054%2036%2058>    fax +34 963 543 733
  
  <+34%20963%2054%2037%2033>
  
  
  
  *NOTE!* For shipments by EXPRESS COURIER use the following
  street address:
  
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain.
  
  
  
  
  ___
  
  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] Enigmatic error with drop.tip

2017-01-20 Thread Juan Antonio Balbuena

  
  
Hello all

I am working with a cophylogenetic problem where I have a host
  tree, a parasite tree and a binary matrix HP encapsulating the
  host-parasite associations . After trimming the matrix according
  to a given criterion, I require to prune the trees accordingly.
  Since I am getting errors at the execution I devised the following
  control function to check the number of tree nodes after pruning:
z <- function (hp, treeH,treeP) {
  treeh <- drop.tip(treeH, setdiff(treeH$tip.label,
rownames(hp)))
  treep <- drop.tip(treeP, setdiff(treeP$tip.label,
colnames(hp)))
  res <- c(treeh$Nnode,treep$Nnode)
 return(res)  
 }
Then I try the following

x <- sapply (THP, z, treeH=TreeH[[7]], treeP= TreeP[[7]])

where THP is a list of trimmed HP matrices and TreeH and TreeP
  are multiphylo objects and get the following error:
Error in integer(max(oldnodes)) : vector size cannot be infinite
The traceback is

6. integer(max(oldnodes)) 
  5. collapse.singles(phy) 
  4. drop.tip(treeP, setdiff(treeP$tip.label, colnames(hp))) 
  3. FUN(X[[i]], ...) 
  2. lapply(X = X, FUN = FUN, ...) 
  1. sapply(THP, z, treeH = TreeH[[7]], treeP = TreeP[[7]])

This error appears only with this particular pair of host and
  parasite trees (#7) and I cannot find a reason why this case
  should be different.
Any help will be very much appreciated.
Juan A. Balbuena


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] chronoMPL/APE

2017-01-17 Thread Juan Antonio Balbuena

  
  
The "strange" shape of your tree seems to result from negative
branch lengths.

If your goal is to just obtain an ultrametric tree under no specific
assumptions, use 

compute.brtime (yourtree, method="coalescent", force.positive=TRUE).

Where 'yourtree' must be an object of class phylo. 
force.positive=TRUE will prevent negative branch lengths to occur in
your tree. 

I hope this helps.

Juan A. Balbuena



-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] get branch lengths from distances to root

2016-11-30 Thread Juan Antonio Balbuena

  
  
Hi all
This is a simple question:
I have a set of ultrametric trees with information on their
  topology but without branch lengths. On a separate file, I have
  the distances of each node and leaf to the root. Can someone
  instruct me on how to to compute the branch lengths of the tree
  with these two separate bits of information?
Many thanks in advance
Juan A. Balbuena


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] plot.cophylo: how to change the colour of host-parasite associations

2016-09-12 Thread Juan Antonio Balbuena

  
  
Hi
No, I didn't have the latest version. Now I have and it works
  nicely.
Thank you very much for your continous effort to develop
  phytools. The package is amazing.
All the best
Juan


El 12/09/2016 a las 16:40, Liam J.
  Revell escribió:

Hi Juan.
  
  
  This update is pretty new so is probably not on CRAN. Do you have
  the latest version of phytools installed from GitHub? To install
  from GitHub I recommend using the package devtools:
  
  
  ## in a fresh R session
  
  install.packages("devtools") ## install devtools from CRAN
  
  library(devtools)
  
  install_github("liamrevell/phytools")
  
  library(phytools)
  
  
  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 9/12/2016 9:35 AM, Juan Antonio Balbuena wrote:
  
  Hi


I wonder whether there is a way to change the colours of the

host-parasite associations in plot.cophylo in phytools.


I tried:


t1 <- rtree(10) t2 <- rtree(10) obj <- cophylo(t1,t2)
plot.cophylo(obj,

link.col= "red")


But the links appear in black. According to the code in

https://github.com/liamrevell/phytools/blob/master/R/cophylo.R,
link.col

is set in the internal function makelinks (l. 119), being
"black" the

default. However, in function plot.cophylo (l. 151-152), it is
indicated


if(hasArg(link.col)) link.col<-list(...)$link.col else
link.col<-"black"


So I can't see why link.color = "red" didn't work.


Eventually I wish to code each host-parasite association as a
colour in

function of a continuous trait.


Actually I managed to do it with cophyloplot in ape


cophyloplot(TreeH, TreeP, assoc=links, use.edge.length=FALSE,

    gap=0, space=20, col=links$Col)


Where links$Col is a vector of colours ranging from "red" to
"blue".

However, I'd rather use plot.cophylo to the advantage of the
optimal

rotation of branches.


Any help will be most welcome.


Juan A. Balbuena



--


Dr. Juan A. Balbuena

Cavanilles Institute of Biodiversity and Evolutionary Biology

University of Valencia

http://www.uv.es/~balbuena 

P.O. Box 22085

http://www.uv.es/cophylpaco


46071 Valencia, Spain

e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>   
tel. +34 963

543 658    fax +34 963 543 733



*NOTE!*For shipments by EXPRESS COURIER use the following street
address:

C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.






___

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/


  
  


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
 

[R-sig-phylo] plot.cophylo: how to change the colour of host-parasite associations

2016-09-12 Thread Juan Antonio Balbuena

  
  
Hi
I wonder whether there is a way to change the colours of the
  host-parasite associations in plot.cophylo in phytools. 

I tried:
t1 <- rtree(10)

t2 <- rtree(10)

obj <- cophylo(t1,t2)

plot.cophylo(obj, link.col= "red")


But the links appear in black. According to the code in
  https://github.com/liamrevell/phytools/blob/master/R/cophylo.R,
  link.col is set in the internal function makelinks (l. 119), being
  "black" the default. However, in function plot.cophylo (l.
  151-152), it is indicated 

if(hasArg(link.col)) link.col<-list(...)$link.col
else link.col<-"black"

So I can't see why link.color = "red" didn't work.
Eventually I wish to code each host-parasite association as a
  colour in function of a continuous trait. 

Actually I managed to do it with cophyloplot in ape 

cophyloplot(TreeH, TreeP, assoc=links, use.edge.length=FALSE,
    gap=0, space=20, col=links$Col)  

Where links$Col is a vector of colours ranging from "red" to
  "blue". However, I'd rather use plot.cophylo to the advantage of
  the optimal rotation of branches. 

Any help will be most welcome.
Juan A. Balbuena


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] Adding random branches to tree recursively

2015-11-02 Thread Juan Antonio Balbuena

  
  
Thank you very much Liam,
You are always so helpful.

 I tried you code and get this warning:

Warning message:
In bind.tree(tree, tip, where = where, position = pp) :
 one tree has no branch lengths, they have been ignored

After adding edge.length= runif(1), it is working as it should.

All the best

Juan


El 30/10/2015 a las 18:16, Liam J.
  Revell escribió:

Hola
  Juan.
  
  
  position is distance below the specified node (or tip) so it has
  to be less than the the length of the edge to which the tip is
  being added or else you will get an error. You could modify as
  follows:
  
  
  node<-which(tree$tip.label==tip.name)
  
  tree<-bind.tip(tree,where=node,position=
  
  runif(n=1)*tree$edge.length[which(tree$edge[,2]==node)])
  
  
  and iterate it over the tips you want to add.
  
  
  - 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 10/30/2015 1:03 PM, Juan Antonio Balbuena wrote:
  
  Hello

I need to add branches to a tree at different, predefined tips.
For

instance:


th <- rtree(10)


I have an object HP_sim$nameH with the taxa names:


HP_sim$nameH
  

[1] "H1" "H2" "H3" "H4" "H5" "H6" "H7" "H8" "H9" "H10"


then

th$tip.label <- HP_sim$nameH


In a second object, I have the tips where the branches should be
added:


HP_sim$fai
  

[1] 1 4 7 9 10


(That is at H1, H4, H7, H9 and H10)


Now I wrote this syntax (where n.fai = 5):


for (i in 1:n.fai) th <- bind.tip(th,
HP_sim$nameH[HP_sim$fai[i]],

  where =

which(th$tip.label==HP_sim$nameH[HP_sim$fai[i]]), edge.length=
runif(1),

position=runif(1))


However, it doesn't work and get this error:


Error in bind.tree(tree, tip, where = where, position = pp) :
'position'

is larger than the branch length


Any help would be very much appreciated.


Thank you very much for your attention


Juan A. Balbuena








--


Dr. Juan A. Balbuena

Cavanilles Institute of Biodiversity and Evolutionary Biology

University of Valencia http://www.uv.es/~balbuena



P.O. Box 22085

http://www.uv.es/cophylpaco

46071 Valencia, Spain

e-mail: j.a.balbu...@uv.es <mailto:j.a.balbu...@uv.es>tel.
+34 963 543

658    fax +34 963 543 733



*NOTE!*For shipments by EXPRESS COURIER use the following street
address:

C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia), Spain.






___

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/


  
  
  


-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following 

[R-sig-phylo] Adding random branches to tree recursively

2015-10-30 Thread Juan Antonio Balbuena

  
  
Hello
I need to add branches to a tree at different, predefined tips. For
instance:

th <- rtree(10)

I have an object HP_sim$nameH with the taxa names:

> HP_sim$nameH
   [1] "H1" "H2" "H3" "H4" "H5" "H6" "H7" "H8" "H9" "H10"

then
th$tip.label <- HP_sim$nameH 

In a second object, I have the tips where the branches should be
added:

> HP_sim$fai
   [1] 1 4 7 9 10

(That is at H1, H4, H7, H9 and H10)

Now I wrote this syntax (where n.fai = 5):

for (i in 1:n.fai) th <- bind.tip(th,
HP_sim$nameH[HP_sim$fai[i]], 
 where =
which(th$tip.label==HP_sim$nameH[HP_sim$fai[i]]), edge.length=
runif(1), position=runif(1))

However, it doesn't work and get this error:

Error in bind.tree(tree, tip, where = where, position = pp)
  : 'position' is larger than the branch length

Any help would be very much appreciated.

Thank you very much for your attention

Juan A. Balbuena







-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] tip order in phylogeny - How does it work?

2014-10-09 Thread Juan Antonio Balbuena

Thank you very much for posting, Brian. I will certainly have a look at
reorder.phylo(). Yet, I think it would be useful not only to me but to 
other users

having some feed-back on how tips are ordered and why the tips inserted are
listed last.

Cheers

Juan Antonio

 Look at reorder.phylo() in ape and reorder() in phylo4: your desired tip
 order may be there.

Best,
Brian

___
Brian O'Meara
Assistant Professor
Dept. of Ecology  Evolutionary Biology
U. of Tennessee, Knoxville
http://www.brianomeara.info

Postdoc collaborators wanted: http://nimbios.org/postdocs/
Calendar: http://www.brianomeara.info/calendars/omeara

On Wed, Oct 8, 2014 at 4:45 AM, Juan Antonio Balbuena j.a.balbuena at 
uv.es

wrote:

  Hello
 I am working on a simulation that requires adding a number of random 
tips

 to multiple phylogenies:

 treeP - read.nexus(file= my file.tre) # 5K trees used to build a
 consensus tree (treeP is thus a multiPhylo object)
 NT = 30 # number of taxa in phylogeny
 N.dup = 3 # number of tips (duplications) I want to add to the trees
 sites - sort(sample(1:NT, N.dup), decreasing=TRUE) # Random tips to
 duplicate
 dup.labels - treeP[[1]]$tip.label[sites]
 treeP - .uncompressTipLabel(treeP)
 #
 # Add duplicates to branches following a Liam Revell recipe published in
 his blog:
 #
 for (n in 1:length(treeP)) {
   for (i in 1:N.dup ) {
 pos - runif(n=1)*
 treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
 edl - runif(n=1)*
 treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
 treeP[[n]] - bind.tip(treeP[[n]], tip.label=paste(dup.labels[i], 1,
 sep=.),
edge.length=edl, where=sites[i], 
position=pos)

   }
 }
 #
 treeP- .compressTipLabel(treeP)
 # Check tip labels:
 treeP$tip.label
 $tip.label
  [1] S24   S25   S9S15   S3S21 S12   S17
 S19   S30   S22   S4S16   S27   S10 S23   S1
 S2S14
 [20] S6S8S26   S29   S13   S20 S7S28
 S18   S5S11   S18.1 S20.1 S16.1

 When I plot any tree in treeP, S18.1, S20.1 and S16.1 appear 
together with

 S18, S20 and S16, as intended. So why are they at the end of the array
 above? This behaviour makes makes my life difficult because it 
forces me to
 rearrange a number of matrices to make them match this tip label 
order. I
 would appreciate if a kind soul can explain why it is that way and 
whether
 is possible to reorder the tip labels, placing each added tip 
together with

 its respective counterpart?

 Thanks in advance for your help.

 Juan Antonio

___
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] tip order in phylogeny - How does it work?

2014-10-08 Thread Juan Antonio Balbuena

  
  
Hello 
I am working on a simulation that requires adding a number of random
tips to multiple phylogenies:

treeP - read.nexus(file= "my file.tre") # 5K trees used to build
a consensus tree (treeP is thus a multiPhylo object) 
NT = 30 # number of taxa in phylogeny
N.dup = 3 # number of tips (duplications) I want to add to the trees
sites - sort(sample(1:NT, N.dup), decreasing=TRUE) # Random tips
to duplicate
dup.labels - treeP[[1]]$tip.label[sites]
treeP - .uncompressTipLabel(treeP)
#
# Add duplicates to branches following a Liam Revell recipe
published in his blog:
#
for (n in 1:length(treeP)) { 
  for (i in 1:N.dup ) {
    pos - runif(n=1)*
treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
    edl - runif(n=1)*
treeP[[n]]$edge.length[which(treeP[[n]]$edge[,2]==sites[i])]
    treeP[[n]] - bind.tip(treeP[[n]],
tip.label=paste(dup.labels[i], 1, sep="."),
   edge.length=edl, where=sites[i],
position=pos)
  }
}
#
treeP- .compressTipLabel(treeP)
# Check tip labels:
treeP$tip.label
$tip.label
 [1] "S24"   "S25"   "S9"    "S15"   "S3"    "S21"   "S12"   "S17"  
"S19"   "S30"   "S22"   "S4"    "S16"   "S27"   "S10"   "S23"  
"S1"    "S2"    "S14"  
[20] "S6"    "S8"    "S26"   "S29"   "S13"   "S20"   "S7"    "S28"  
"S18"   "S5"    "S11"   "S18.1" "S20.1" "S16.1"

When I plot any tree in treeP, S18.1, S20.1 and S16.1 appear
together with S18, S20 and S16, as intended. So why are they at the
end of the array above? This behaviour makes makes my life difficult
because it forces me to rearrange a number of matrices to make them
match this tip label order. I would appreciate if a kind soul can
explain why it is that way and whether is possible to reorder the
tip labels, placing each added tip together with its respective
counterpart? 

Thanks in advance for your help.

Juan Antonio
-- 
  
  

  Dr.
Juan
A. Balbuena 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia           
           
           
        http://www.uv.es/~balbuena

P.O. Box
22085           
           
           
           
    http://www.uv.es/cophylpaco
46071 Valencia,
Spain

e-mail: j.a.balbu...@uv.es   
tel.
+34 963 543 658    fax +34 963 543 733 
 
NOTE! For shipments by EXPRESS COURIER use
  the following street
  address: 
  C/ Catedrático José Beltrán 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] cophyloplot: how to marks links differently

2014-05-29 Thread Juan Antonio Balbuena

Hello
Thanks to Emmanuel's feedback I have worked out an answer to my own query:

# Demostration of cophyloplot where congruent and incongruent links
# are displayed in two different colors
# Hosts(H) and parasites (P) share a common topology (com.tree)
# with 1 to 1 (congruent) H-P links.
# Other part of the tree is different between H and P with random
# (incongruent) H-P links.
#
library(ape)
# set numbers of congruent and incongruent links
Nc = 6
Ni = 4
com.tree - rtree(Nc) # topology shared by H and P trees
H.tree - rcoal(n=Ni, tip.label=paste(I,1:Ni)) # H different topology
P.tree - rcoal(n=Ni, tip.label=paste(I,1:Ni)) # P different topology
#
# bind shared and unshared topologies:
com.tree$root.edge - H.tree$root.edge - P.tree$root.edge - runif(1)
H.tree - com.tree + H.tree
P.tree - com.tree + P.tree
#
# HPgamma creates HP matrix with coevl links in common part of tree and
# random links RESTRICTED TO random part of the tree
HPgamma - function (NH, NP, Nrand) { # input is no. H, P and Ni
  HP - diag(1, NH, NP) #diagonal 1 matrix of NH rows and NP cols
  HP2 - diag(1, Nrand)
  #The following randomizes the links of the non-coevolving part of the 
tree:

  i - sapply(seq_len(Nrand), function(x) sample(seq_len(Nrand)[-x], 1))
  HP2 - matrix(0, Nrand, Nrand)
  HP2[cbind(seq_len(Nrand), i)] - 1
  HP3 - which(HP2 ==1, arr.in=TRUE) #get coordinates of incongruent links
  HP[HP3] - 1
  for (i in 1:Nrand) HP[i,i] -0
  return(HP)
}
#
# Proper script starts here:
# 1. Sort assoc= input of cophyloplot. Incongruent links go first
HP - HPgamma(Nc+Ni,Nc+Ni,Ni)
rownames(HP)- rev(H.tree$tip.label)
colnames(HP)- rev(P.tree$tip.label)
HP.LUT - which(HP ==1, arr.in=TRUE)
links - cbind(rownames(HP)[HP.LUT[,1]],colnames(HP)[HP.LUT[,2]])
# 2. create a binary vector where 1 = incongruent and 0 = congruent
# order follow 'links' above
x - c(rep(1, Ni), rep(0, Nc))
# 3. color vector red = incongruent, blue = congruent
cols - c(blue,red)[(x==1)+1]
# 4. plot trees:
cophyloplot(H.tree, P.tree, assoc=links, use.edge.length=TRUE,
gap=0.5, space=8, col= cols)
# Voilà!


El 28/05/2014 11:20, Emmanuel Paradis escribió:
These options can be vectors with several values (and they are 
recycled if needed), so you should be able to specify different values 
for each link. If not, there is a problem.


E.

Wed, 28 May 2014 11:15:35 +0200 Juan Antonio Balbuena 
j.a.balbu...@uv.es:

  Hello Emmanuel,
I know that cophyloplot() has these options, but apparently 
there is no direct way to use two or more types of lines to mark 
links. I specifically wish to mark congruent links in both trees 
using a different type of line than that for incongruent links. 
This is not too difficult to implement manually but it would be 
great to write a function doing this.

Best
Juan
El 28/05/2014 11:03, Emmanuel Paradis escribioacute;:
 Hi Juan,   cophyloplot() has the options 
col, lwd, and lty which specify the   aspects of the association 
lines.   Le 27/05/2014 16:09, Juan Antonio Balbuena a 
eacute;crit :Hello This is a simple question and 
hope that there is a simpleanswer. Plotting a 
tanglegram, I would like to write a function where congruent 
tips on both trees are marked, say, with continuous lines, 
   whereas incongruent tips are marked 
differently (for instance withstippled lines). A 
starting point could be using cophyloplot() specifying 
assoc=NULL and then use segment() to plot the lines 
accordingly, but how can one get the x, y 
coordinates for segment()?   This is not possible (at least 
easily) because this function uses   a different system than 
plot.phylo(). HTH   Best, Emmanuel   
Any thoughts will be much appreciated. 
Juan A. balbuena -- 
Dr. Juan A. Balbuena Cavanilles Institute of 
Biodiversity and Evolutionary Biology University of 
Valencia http://www.uv.es/~balbuena 
http://www.uv.es/%7Ebalbuena P.O. Box 22085 
http://www.uv.es/cophylpaco 
http://www.uv.es/cavanilles/zoomarin/index.htm 46071 
Valencia, Spain e-mail: j.a.balbu...@uv.es 
mailto:j.a.balbu...@uv.estel. +34 963 543 658
fax +34 963 543 733 

*NOTE!*For shipments by EXPRESS COURIER use the following 
street address: C/ Catedraacute;tico 
Joseacute; Beltraacute;n 2, 46980 Paterna (Valencia), Spain. 
 
___ R-sig-phylo mailing 
list - R-sig-phylo@r-project.org 
https://stat.ethz.ch/mailman/listinfo/r-sig

[R-sig-phylo] help with dist.multiPhylo needed

2014-01-23 Thread Juan Antonio Balbuena

  
  
Hello

I would like to compute geodesic distances from random trees for
comparison and hypothesis testing with those produced from a given
set of trees. I am using dist.multiPhylo() in the 'distory' package,
but it seems to be too compute-intensive. To illustrate my point:


   lin4 #object consisting of 4 randomly generated trees
[1] "(S8: 1.0, (((S4: 0.28596, S5: 0.28596): 0.63211, (S10: 0.88214, ((S6: 0.49245, S7: 0.49245): 0.24813, S9: 0.74058): 0.14156): 0.03592): 0.03859, ((S1: 0.16950, S2: 0.16950): 0.61358, S3: 0.78308): 0.17357): 0.04335);"
[2] "((S6: 0.10938, S2: 0.10938): 0.89062, ((S7: 0.79060, ((S4: 0.31389, S8: 0.31389): 0.31812, (((S1: 0.06153, S3: 0.06153): 0.08642, S10: 0.14795): 0.47444, S9: 0.62238): 0.00962): 0.15860): 0.01336, S5: 0.80396): 0.19604);"
[3] "((S7: 0.98617, (S4: 0.90628, (S3: 0.86179, ((S1: 0.17650, S6: 0.17650): 0.48270, ((S10: 0.28064, S5: 0.28064): 0.06352, (S9: 0.00968, S8: 0.00968): 0.33448): 0.31505): 0.20259): 0.04449): 0.07990): 0.01383, S2: 1.0);"
[4] "(S6: 0.42675, S3: 0.42675): 0.16273, S8: 0.58948): 0.00542, S5: 0.59490): 0.05023, (S4: 0.19208, S7: 0.19208): 0.45305): 0.35486, (S9: 0.90829, (S10: 0.64179, (S2: 0.36191, S1: 0.36191): 0.27988): 0.26649): 0.09171);"


   dist.multiPhylo(lin4)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

If I increase the value of "expressions" from 5000 (default) to 25000 then

 options(expressions=25000)
 dist.multiPhylo(lin4)
Error: protect(): protection stack overflow

Is there a way to circumvent these errors?

Thank you very much for your time.

Juan A. Balbuena 






















-- 
  
  
 Dr. Juan A. Balbuena 
Marine Zoology Unit 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia

  http://www.uv.es/~balbuena 
P.O. Box 22085 http://www.uv.es/cavanilles/zoomarin/index.htm 
46071 Valencia,
Spain http://cetus.uv.es/mullpardb/index.html 
e-mail: j.a.balbu...@uv.es tel. +34 963 543 658 fax +34 963 543 733

 
NOTE! For

  shipments by EXPRESS COURIER use the following street
  address: 
  C/ Catedrtico Jos Beltrn 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] help with dist.multiPhylo needed

2014-01-23 Thread Juan Antonio Balbuena

  
  
Hi Klaus
You are right. The problem was that my lin4 object was a list. I
have saved the same trees in a text file as

"(S8: 1.0, (((S4: 0.28596, S5: 0.28596): 0.63211, (S10: 0.88214,
((S6: 0.49245, S7: 0.49245): 0.24813, S9: 0.74058): 0.14156):
0.03592): 0.03859, ((S1: 0.16950, S2: 0.16950): 0.61358, S3:
0.78308): 0.17357): 0.04335);"
"((S6: 0.10938, S2: 0.10938): 0.89062, ((S7: 0.79060, ((S4: 0.31389,
S8: 0.31389): 0.31812, (((S1: 0.06153, S3: 0.06153): 0.08642, S10:
0.14795): 0.47444, S9: 0.62238): 0.00962): 0.15860): 0.01336, S5:
0.80396): 0.19604);"
"((S7: 0.98617, (S4: 0.90628, (S3: 0.86179, ((S1: 0.17650, S6:
0.17650): 0.48270, ((S10: 0.28064, S5: 0.28064): 0.06352, (S9:
0.00968, S8: 0.00968): 0.33448): 0.31505): 0.20259): 0.04449):
0.07990): 0.01383, S2: 1.0);"
"(S6: 0.42675, S3: 0.42675): 0.16273, S8: 0.58948): 0.00542, S5:
0.59490): 0.05023, (S4: 0.19208, S7: 0.19208): 0.45305): 0.35486,
(S9: 0.90829, (S10: 0.64179, (S2: 0.36191, S1: 0.36191): 0.27988):
0.26649): 0.09171);"

and 

 tree4 - read.tree(file.choose())

 dist.multiPhylo(tree4)
 1 2 3
2 2.452629 
3 2.441263 2.362859 
4 1.598451 2.050473 2.259690

Excellent!

Thank you very much for your help!

Juan 


El 23/01/2014 16:54, Klaus Schliep
  escribi:


  I also checked it for a multiPhylo object the
function works fine, but not for a list or vector of characters.

  
  

    On Thu, Jan 23, 2014 at 4:49 PM, Juan
  Antonio Balbuena j.a.balbu...@uv.es wrote:
  
 Hello
  Thank you very much for your interest. Yes, it does read
  newick and works with similar trees. So the problem seems
  "architectural" instead of not applying the function
  correctly. 
  
  Cheers
  
  Juan 
  
  
  El 23/01/2014 16:35, Klaus Schliep escribi:
  
  

  
Sorry, should also read newick
  format, sorry for my comment. 
  


  
  On Thu, Jan 23, 2014 at
4:30 PM, Klaus Schliep klaus.schl...@gmail.com
wrote:

  

  
Dear Juan,

lin4 is not an object of class
multiPhylo but vector of characters.
Read in the trees with read.tree from
the ape package.  
  
  Regards, 

Klaus

  


  

  
  


  
On Thu, Jan 23, 2014 at 4:20 PM,
  Juan Antonio Balbuena j.a.balbu...@uv.es
  wrote:

  
  

  
 Hello
  
  I would like to compute geodesic
  distances from random trees for
  comparison and hypothesis testing
  with those produced from a given
  set of trees. I am using
  dist.multiPhylo() in the 'distory'
  package, but it seems to be too
  compute-intensive. To illustrate
  my point:
  
  

 lin4 #object consisting of 4 randomly generated trees
[1] "(S8: 1.0, (((S4: 0.28596, S5: 0.28596): 0.63211, (S10: 0.88214, ((S6: 0.49245, S7: 0.49245): 0.24813, S9: 0.74058): 0.14156): 0.03592): 0.03859, ((S1: 0.16950, S2: 0.16950): 0.61358, S3: 0.78308): 0.17357): 0.04335);"
[2] "((S6: 0.10938, S2: 0.10938): 0.89062, ((S7: 0.79060, ((S4: 0.31389, 

[R-sig-phylo] most efficient way to read trees from huge text file

2013-10-10 Thread Juan Antonio Balbuena
Hello,
I need to handle in R 10M trees produced with the program evolver of
PAML. With a smaller number of trees one could create a multi-phylo
object with ape as

tree.m - read.tree(filename.tre) 

but this is impractical in this case because it takes all the RAM
memory. I've tried something like

 library(ape)
 con = file(evolver.out, open=r) # where evolver.out contains 10M
trees
 lin = readLines(con)
 for (i in 1:length(lin)) {
+ tree - read.tree(lin[i])
+ # my additional syntax mrca analysis etc. here
+ }

But it doesn't work:

Error in file(file, r) : cannot open the connection
In addition: Warning messages:
1: closing unused connection 3 (evolver.out) 
2: In file(file, r) :
  cannot open file 'S6: 0.33544, (S1: 0.02314, S10: 0.02314):
0.31230): 0.53388, S5: 0.86932): 0.04830, (S4: 0.51901, (S7: 0.05901,
S2: 0.05901): 0.46000): 0.39861): 0.08238, (S3: 0.30236, (S8: 0.13236,
S9: 0.13236): 0.17000): 0.69764);': No such file or directory

I would very much appreciate your help. Note that computing efficiency
is key here.

Thank you very much for your attention.

Juan A. Balbuena

___
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] findMRCA of phytools not working

2013-07-30 Thread Juan Antonio Balbuena

  
  
Hello
I am using the function findMRCA of phytools. I tried it with a
simulated tree and it worked as it should. Now I want to use it with
a real tree but get an odd error message:
 
   findMRCA(TreeP, tips= c(16, 17))
Error in if (anc == 0) break : missing value where TRUE/FALSE needed

This is the info about TreeP:


   summary(TreeP)

Phylogenetic tree: TreeP 

  Number of tips: 17 
  Number of nodes: 16 
  Branch lengths:
mean: 0.05285941 
variance: 0.001793694 
distribution summary:
Min.  1st Qu.   Median  3rd Qu. Max. 
0.01 0.013200 0.036010 0.084470 0.143000 
  No root edge.
  First ten tip labels: Tbar 
Tmin
Gtho
Gact
Gpero
Gche
Gcos
Gpan
Gset
Gcha
  No node labels.

Any help will be much appreciated.

Juan Antonio Balbuena

-- 
  
  

  Dr. Juan
A. Balbuena 
Marine Zoology Unit 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia
  http://www.uv.es/~balbuena 
P.O. Box
22085
  http://www.uv.es/cavanilles/zoomarin/index.htm 
46071 Valencia,
Spain
  http://cetus.uv.es/mullpardb/index.html 
e-mail: j.a.balbu...@uv.es tel.
+34 963 543 658 fax +34 963 543 733 
 
NOTE! For
  shipments by EXPRESS COURIER use the following street
  address: 
  C/ Catedrtico Jos Beltrn 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] assign numbers to nodes

2013-07-05 Thread Juan Antonio Balbuena

  
  
Hello 
Sorry for this apparently simple question, but could not find the
right answer on the internet.

For a given phylo object in ape consisting of n tips, how can I
assign unique node numbers from 1 to 2n-1, such that if a node i is
ancestral to a node k, i  k?

Thanks for your attention.  

Juan A. Balbuena

-- 
  
  

  Dr. Juan
A. Balbuena 
Marine Zoology Unit 
Cavanilles Institute of Biodiversity and Evolutionary
Biology 
University of
Valencia
  http://www.uv.es/~balbuena 
P.O. Box
22085
  http://www.uv.es/cavanilles/zoomarin/index.htm 
46071 Valencia,
Spain
  http://cetus.uv.es/mullpardb/index.html 
e-mail: j.a.balbu...@uv.es tel.
+34 963 543 658 fax +34 963 543 733 
 
NOTE! For
  shipments by EXPRESS COURIER use the following street
  address: 
  C/ Catedrtico Jos Beltrn 2, 46980 Paterna (Valencia),
  Spain. 
  
  

  


___
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] compute HKY85 distances in R

2012-05-22 Thread Juan Antonio Balbuena
Hello
I would like to know whether it is possible to compute HKY85 genetic
distances using R. The model is not included in the dist.dna function
of ape and I was wondering whether it is available in another package.
Thank you very much for your attention.

Juan Antonio Balbuena

___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


[R-sig-phylo] randomizing clades within a node

2012-01-13 Thread Juan Antonio Balbuena

  
  
Hello

I would very much appreciate if someone can help me with this one. I
wish to compare two additive trees that are identical for some but
not all the clades.

So I use rtree of the ape package with, say, 10 tips to generate
tree "A". Then I wish to modify "A" to get tree "B" by randomizing
the clades and patristic distances in a given number of nodes. If
the number of nodes is, for instance, three, the 3 nodes furthest
apart from the origin will be randomized. Then "A" and "B" will be
compared. The whole procedure needs to be carried out a large number
of times (10,000). 

Any help would be much appreciated. 

Juan A. Balbuena

-- 
  
  
  
Dr. Juan A. Balbuena
  
  Marine
Zoology Unit
  
  Cavanilles
Institute of Biodiversity and Evolutionary Biology
  
  University
of
Valencia
  http://www.uv.es/~balbuena
  
  P.O.
Box
22085
  http://www.uv.es/cavanilles/zoomarin/index.htm
  
  46071
Valencia,
Spain
  http://cetus.uv.es/mullpardb/index.html
  
  e-mail: j.a.balbu...@uv.es
tel. +34 963 543 658 fax +34 963 543 733
  
  
  
  NOTE! For shipments by EXPRESS
  COURIER use the
  following street address:
  
  C/ Catedrtico Jos Beltrn 2,
46980 Paterna
(Valencia), Spain.
  
  

  


___
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo