[R-sig-phylo] Phylogenetic correlograms

2012-08-28 Thread Diogo B. Provete
Dear List,
I was trying to implement a phylogenetic correlogram with Moran's I in R.
Unfortunately all functions to implement correlograms in packages for
spatial statistics require Lat/Long coordinates. In an old version of ape
there was this function correlogram.phylo that worked with a cophenetic
matrix. But now only correlgram.formula is available that requires the user
to especifies the taxonomic levels. I'd like to do a correlogram based on
the cophenetic matrix and not in the taxonomic levels.

Any help would be very appreciated.

Thanks,
Diogo


-- 
Atenciosamente,
*Diogo Borges Provete*

==
Biólogo
Mestre em Biologia Animal (UNESP)
Doutorando PPG Ecologia e Evolução
Laboratório de Ecologia de Insetos (sl. 222)
Departamento de Ecologia
Instituto de Ciências Biológicas - ICB 1
Universidade Federal de Goiás, campus II - UFG
Goiânia-GO
CP: 131
74001-970
Brazil

Tel. Lab. +55 62 3521-1732
*Cel. +55 *62 8231-5775
*
*: diogoprovete
**: diogop...@yahoo.com.br

*Personal web page *

==

[[alternative HTML version deleted]]

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


[R-sig-phylo] Plot size

2012-08-28 Thread Gwennaël Bataille
Dear R-sig-phylo users,

I would like to rescale a large tree, but I am not an expert of graphs 
in R...

My labels overlap with each other. And I would like to find an option to 
put more space between each branch, but could not find one.

So I tried to resize the labels (playing with cex parameter), but now 
the branches are far too long in comparison with the labels... So I 
would like to reduce also branch lengths :

- I can define new values for "edge.length" but I want my taxa to be 
aligned. So, I prefer "use.edge.length=F"

- I also thought about playing with "x.lim" parameter, but my graph is 
then truncated rather than resized...

Any help would be appreciated.

Thanks a lot in advance,

Gwennaël ( gwennael.batai...@uclouvain.be 
 )

PS: Here are the script and the data :

#Question r-sig-phylo

library(ape)

t <- 
"(1,2,3),(18,19,20,21,22,23,24,25,26,27,28,29,30,31)),(4,5),(6,7,8),(9,10,11,12,13,14),(15,16,17),((32,33),34,((35,36,37),38,39))),40,42),41),(43,(44,45,46),47,((48,49),50))),51,52,53,54),(((55,((56,(57,58)),(59,60),61)),((62,63),64,65)),((66,67,68,69,70,71,72),73,(74,75,76,77,((78,(80,82)),(84,87)),((79,(81,83)),89)),(85,86)),88),(90,91,92))),((93,((94,95),((96,97,98,99,100,101,102,103,104,105,106),(118,(119,120),121,122,(123,124,125,126,127,128),129,(((130,131,132,133,134,135),136,138,139,((141,142),((143,144),(145,(146,147),137,140,(148,149,150,151),(152,153,154,155,156,157,158,159,160),((161,(164,165,166),((172,((173,177),(178,183)),179,180,181,182,184),174,175,176,185,186,187,188)),(167,168,169,170,171)),162,163))),((107,108),109,((110,111,112,113,114,115),(116,117),(((189,(((256,257,258,259,260,261,262),263,279),((268,269,271),270,272,(273,276),274,275,277,278)),(264,265,266,267)),(280,281,282,283,284,285),((286,287,288,289),(291,292),(293,294)),290)),342,343),(344,345,346)),349),(347,348))),295,((296,301),297,298,299,300,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,(((324,325,327,328),326),329),330,331,332,333,334,335,336,337,338,339,340,341)),(350,351,352,353,354,355,356,357,358,359,360,361,362,363)),364),(365,366),(367,368,369),370)),(((191,192,193),(((199,201),200),(202,(207,208))),(203,204)),(205,206)),209),((236,237),(242,(((243,247),244),(245,(246,248)),249))),240),238,239),241),250,253),255),254),(251,252),(((194,195,196),(197,198)),(210,211),212),213,(214,(215,216))),(228,(229,230))),((217,((218,221),(219,220),222,223,224,225,226,227)),231,234),233),232),235)),190));"

tree <- read.tree(text=t)

plot(tree)

#Plot with reduced size of the labels

windows(width=15, height=10, pointsize=10, rescale="fixed")

par(xpd=NA, cex = 0.3) #Reduce size of the labels

plot(tree, y.lim=c(0,400))

#Play with x.lim

plot(tree, y.lim=c(0,400), x.lim=200)

#Define new edge length

tree2 <- tree$edge.length <- rep.int(5,544)

plot(tree2, y.lim=c(0,400), x.lim=200, use.edge.length=T)


[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Plot size

2012-08-28 Thread Liam J. Revell

Hi Gwennael.

I'm not totally sure I understand the problem, but this might help.

You can use windows (in Windows) or dev.new to creating a plotting 
window with you desired dimensions. plot.phylo will then automatically 
rescale the branch lengths to fit. You can also control the font size 
from within plot.phylo.


For example:

library(ape)
dev.new(width=2,height=10)
plot(tree,cex=0.2,no.margin=T)
savePlot("test1.pdf",type="pdf")

# or, using phytools plotTree, which gets rid of some of the excess
# whitespace
library(phytools)
dev.new(width=2,height=10)
tree<-compute.brlen(tree) # since your tree has no edge lengths
plotTree(tree,fsize=0.2,ftype="i",lwd=0.4,pts=F)
savePlot("test2.pdf",type="pdf")

In addition, in an interactive session the tree (but not the labels) 
will automatically resize when you manually resize the plotting window.


Is this at all helpful?

All the best, Liam

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

On 8/28/2012 1:34 PM, Gwennaël Bataille wrote:

Dear R-sig-phylo users,

I would like to rescale a large tree, but I am not an expert of graphs
in R...

My labels overlap with each other. And I would like to find an option to
put more space between each branch, but could not find one.

So I tried to resize the labels (playing with cex parameter), but now
the branches are far too long in comparison with the labels... So I
would like to reduce also branch lengths :

- I can define new values for "edge.length" but I want my taxa to be
aligned. So, I prefer "use.edge.length=F"

- I also thought about playing with "x.lim" parameter, but my graph is
then truncated rather than resized...

Any help would be appreciated.

Thanks a lot in advance,

Gwennaël ( gwennael.batai...@uclouvain.be
 )

PS: Here are the script and the data :

#Question r-sig-phylo

library(ape)

t <-
"(1,2,3),(18,19,20,21,22,23,24,25,26,27,28,29,30,31)),(4,5),(6,7,8),(9,10,11,12,13,14),(15,16,17),((32,33),34,((35,36,37),38,39))),40,42),41),(43,(44,45,46),47,((48,49),50))),51,52,53,54),(((55,((56,(57,58)),(59,60),61)),((62,63),64,65)),((66,67,68,69,70,71,72),73,(74,75,76,77,((78,(80,82)),(84,87)),((79,(81,83)),89)),(85,86)),88),(90,91,92))),((93,((94,95),((96,97,98,99,100,101,102,103,104,105,106),(118,(119,120),121,122,(123,124,125,126,127,128),129,(((130,131,132,133,134,135),136,138,139,((141,142),((143,144),(145,(146,147),137,140,(148,149,150,151),(152,153,154,155,156,157,158,159,160),((161,(164,165,166),((172,((173,177),(178,183)),179,180,181,182,184),174,175,176,185,186,187,188)),(167,168,169,170,171)),162,163))),((107,108),109,((110,111,112,113,114,115),(116,117),(((189,(((256,257,258,259,260,261,262),263,279),((268,269,271),270,272,(273,276),274,275,277,278)),(264,265,266,267)),(280,281,282,283,284,285),((286,287,288,289),(291,292!

),(293
,294)),290)),342,343),(344,345,346)),349),(347,348))),295,((296,301),297,298,299,300,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,(((324,325,327,328),326),329),330,331,332,333,334,335,336,337,338,339,340,341)),(350,351,352,353,354,355,356,357,358,359,360,361,362,363)),364),(365,366),(367,368,369),370)),(((191,192,193),(((199,201),200),(202,(207,208))),(203,204)),(205,206)),209),((236,237),(242,(((243,247),244),(245,(246,248)),249))),240),238,239),241),250,253),255),254),(251,252),(((194,195,196),(197,198)),(210,211),212),213,(214,(215,216))),(228,(229,230))),((217,((218,221),(219,220),222,223,224,225,226,227)),231,234),233),232),235)),190));"


tree <- read.tree(text=t)

plot(tree)

#Plot with reduced size of the labels

windows(width=15, height=10, pointsize=10, rescale="fixed")

par(xpd=NA, cex = 0.3) #Reduce size of the labels

plot(tree, y.lim=c(0,400))

#Play with x.lim

plot(tree, y.lim=c(0,400), x.lim=200)

#Define new edge length

tree2 <- tree$edge.length <- rep.int(5,544)

plot(tree2, y.lim=c(0,400), x.lim=200, use.edge.length=T)


[[alternative HTML version deleted]]



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



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


[R-sig-phylo] Alter the branch lengths of a Tree

2012-08-28 Thread Fernando Sobral
Hi,

I am trying to alter the branch lengths of a phylogeny so that the smaller
branch has size igual 1 and the larger branch is the proportional sum of
the smaller branchs. For example, if the larger branch is equivalent to ten
smaller branchs, it should have size igual to 10. I already tryed use some
functions like compute.brlen(), compute.brtime() and rescaleTree(), but did
not work.

Any help would be greatly appreciated.

Thanks,

Fernando L. Sobral

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Alter the branch lengths of a Tree

2012-08-28 Thread Liam J. Revell

Hi Fernando.

I'm not entirely sure what you're going for, but let me try to be of 
some help.


The tree is stored in memory as what is called a "list" - basically, a 
set of objects that can be of different types. The branch lengths of the 
tree are stored in the list element "edge.length". So, for a "phylo" 
object with the variable name tree, you can access the branch lengths of 
the tree using tree$edge.length. (If your tree does not have branch 
lengths, this will be NULL.)


Consequently, you can assign any arbitrary values to the branch lengths 
of the tree by assigning values to tree$edge.length. For instance, to 
set all branch lengths to 1.0, you would just do:


tree$edge.length<-rep(1,nrow(tree$edge))

The order of tree$edge.length corresponds to the row order of tree$edge, 
so if you want to see which branches in tree$edge.length correspond to 
which branches on the tree, you can do something like the following 
(here, I use a simple random tree for illustration):


set.seed(1)
tree<-rtree(10); tree$edge.length<-rep(1,nrow(tree$edge))
X<-tree$edge
X[X[,2]%in%1:length(tree$tip),2]<-
   tree$tip[X[X[,2]%in%1:length(tree$tip),2]]
names(tree$edge.length)<-paste(X[,1],X[,2],sep=",")
plot(tree); nodelabels()
tree$edge.length

Now if, for instance, I want to make the branch length leading from node 
13 to tip taxon "t6" to (for instance) 3.0, I could just do:


tree$edge.length["13,t6"]<-3
plot(tree); nodelabels()

Of course, if we have some simple criterion on which we want to change 
our branch lengths, we can do that to. For instance, if we wanted to set 
all branch lengths with length <1 to 1.0 and all branch lengths with 
length >1 to 2.0, we could do it as follows:


tree$edge.length<-runif(n=nrow(tree$edge),min=0,max=2)
tree$edge.length
tree$edge.length[tree$edge.length<1]<-1
tree$edge.length[tree$edge.length>1]<-2
tree$edge.length
plot(tree)

I hope this is of some help.

All the best, Liam

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

On 8/28/2012 4:15 PM, Fernando Sobral wrote:

Hi,

I am trying to alter the branch lengths of a phylogeny so that the smaller
branch has size igual 1 and the larger branch is the proportional sum of
the smaller branchs. For example, if the larger branch is equivalent to ten
smaller branchs, it should have size igual to 10. I already tryed use some
functions like compute.brlen(), compute.brtime() and rescaleTree(), but did
not work.

Any help would be greatly appreciated.

Thanks,

Fernando L. Sobral

[[alternative HTML version deleted]]

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



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


[R-sig-phylo] Fwd: Alter the branch lengths of a Tree

2012-08-28 Thread Leandro Jones
Neither do I imagine what is Fernando going to do with this, but I think
this is what he wants to do:

> F <- rtree(10) # suppose this is Fernando's tree
> F$edge.length
 [1] 0.26509875 0.87023285 0.99953710 0.22727375 0.72152984 0.66757869
 [7] 0.19363565 0.79213697 0.58417425 0.90608903 0.09822511 0.62101620
[13] 0.96507543 0.75824378 0.04740603 0.90538387 0.59199804 0.24499763
> F$edge.length <- x$edge.length/min(x$edge.lengt)
> F$edge.length
 [1]  5.592089 18.357006 21.084596  4.794195 15.220211 14.082146  4.084620
 [8] 16.709623 12.322783 19.113369  2.071996 13.099940 20.357650 15.994668
[15]  1.00 19.098494 12.487820  5.168069
>

Hope it helps!
Leandro Jones


2012/8/28 Liam J. Revell 

Hi Fernando.
>
> I'm not entirely sure what you're going for, but let me try to be of some
> help.
>
> The tree is stored in memory as what is called a "list" - basically, a set
> of objects that can be of different types. The branch lengths of the tree
> are stored in the list element "edge.length". So, for a "phylo" object with
> the variable name tree, you can access the branch lengths of the tree using
> tree$edge.length. (If your tree does not have branch lengths, this will be
> NULL.)
>
> Consequently, you can assign any arbitrary values to the branch lengths of
> the tree by assigning values to tree$edge.length. For instance, to set all
> branch lengths to 1.0, you would just do:
>
> tree$edge.length<-rep(1,nrow(**tree$edge))
>
> The order of tree$edge.length corresponds to the row order of tree$edge,
> so if you want to see which branches in tree$edge.length correspond to
> which branches on the tree, you can do something like the following (here,
> I use a simple random tree for illustration):
>
> set.seed(1)
> tree<-rtree(10); tree$edge.length<-rep(1,nrow(**tree$edge))
> X<-tree$edge
> X[X[,2]%in%1:length(tree$tip),**2]<-
>tree$tip[X[X[,2]%in%1:length(**tree$tip),2]]
> names(tree$edge.length)<-**paste(X[,1],X[,2],sep=",")
> plot(tree); nodelabels()
> tree$edge.length
>
> Now if, for instance, I want to make the branch length leading from node
> 13 to tip taxon "t6" to (for instance) 3.0, I could just do:
>
> tree$edge.length["13,t6"]<-3
> plot(tree); nodelabels()
>
> Of course, if we have some simple criterion on which we want to change our
> branch lengths, we can do that to. For instance, if we wanted to set all
> branch lengths with length <1 to 1.0 and all branch lengths with length >1
> to 2.0, we could do it as follows:
>
> tree$edge.length<-runif(n=**nrow(tree$edge),min=0,max=2)
> tree$edge.length
> tree$edge.length[tree$edge.**length<1]<-1
> tree$edge.length[tree$edge.**length>1]<-2
> tree$edge.length
> plot(tree)
>
> I hope this is of some help.
>
> All the best, Liam
>
> Liam J. Revell, Assistant Professor of Biology
> University of Massachusetts Boston
> web: 
> http://faculty.umb.edu/liam.**revell/
> email: liam.rev...@umb.edu
> blog: http://phytools.blogspot.com
>
> On 8/28/2012 4:15 PM, Fernando Sobral wrote:
>
>> Hi,
>>
>> I am trying to alter the branch lengths of a phylogeny so that the smaller
>> branch has size igual 1 and the larger branch is the proportional sum of
>> the smaller branchs. For example, if the larger branch is equivalent to
>> ten
>> smaller branchs, it should have size igual to 10. I already tryed use some
>> functions like compute.brlen(), compute.brtime() and rescaleTree(), but
>> did
>> not work.
>>
>> Any help would be greatly appreciated.
>>
>> Thanks,
>>
>> Fernando L. Sobral
>>
>> [[alternative HTML version deleted]]
>>
>> __**_
>> R-sig-phylo mailing list
>> R-sig-phylo@r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-phylo
>>
>>
> __**_
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-phylo
>



-- 
Dr. Leandro R. Jones, Ph.D.
Director General de Coordinación Institucional
Secretaría de Ciencia, Tecnología e Innovación Productiva
Gobierno de la Provincia del Chubut




-- 
Dr. Leandro R. Jones, Ph.D.
Director General de Coordinación Institucional
Secretaría de Ciencia, Tecnología e Innovación Productiva
Gobierno de la Provincia del Chubut

[[alternative HTML version deleted]]

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