[R-sig-phylo] Fwd: Extracting interspecific distances as a matrix

2023-02-05 Thread Eliot Miller
Sent on Jan 17th but perhaps using the wrong email address.

-- Forwarded message -
From: Eliot Miller 
Date: Tue, Jan 17, 2023 at 8:41 AM
Subject: Re: [R-sig-phylo] Extracting interspecific distances as a matrix
To: Jarrett Phillips 
Cc: 


I haven't used the dist.dna function before, so apologies if I'm off base,
but I see it returns a distance object. You can simply do
dMat <- as.matrix(d)
And now it's a matrix of the more familiar form. I haven't used the split
function before either, but rows (or columns) can just be extracted with
dMat[1,] etc.

Cheers,
Eliot

On Mon, Jan 16, 2023 at 11:06 PM Jarrett Phillips <
phillipsjarre...@gmail.com> wrote:

> Hello,
>
> I'm trying to extract interspecific distances from a large distance matrix
> using APE. However, my approach returns a vector.
>
> Consider the following illustrative example:
>
> library(ape)
> data(woodmouse)
>
> d <- dist.dna(woodmouse, model = "raw") # get p-distance matrix
> labs <- labels(woodmouse) # get species names
> o <- outer(labs, labs, "==") # this is a matrix
> inter <- d[!o] # this is a vector of interspecific distances
>
> What I need is for 'inter' to be a matrix so I can use split() to split the
> matrix into lists by species.
>
> Simply coercing to a matrix with as.matrix(inter) destroys the structure of
> the distance matrix.
>
> Any assistance is appreciated.
>
> Thanks!
>
> Cheers,
>
> Jarrett
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Extracting interspecific distances as a matrix

2023-01-17 Thread Eliot Miller
I haven't used the dist.dna function before, so apologies if I'm off base,
but I see it returns a distance object. You can simply do
dMat <- as.matrix(d)
And now it's a matrix of the more familiar form. I haven't used the split
function before either, but rows (or columns) can just be extracted with
dMat[1,] etc.

Cheers,
Eliot

On Mon, Jan 16, 2023 at 11:06 PM Jarrett Phillips <
phillipsjarre...@gmail.com> wrote:

> Hello,
>
> I'm trying to extract interspecific distances from a large distance matrix
> using APE. However, my approach returns a vector.
>
> Consider the following illustrative example:
>
> library(ape)
> data(woodmouse)
>
> d <- dist.dna(woodmouse, model = "raw") # get p-distance matrix
> labs <- labels(woodmouse) # get species names
> o <- outer(labs, labs, "==") # this is a matrix
> inter <- d[!o] # this is a vector of interspecific distances
>
> What I need is for 'inter' to be a matrix so I can use split() to split the
> matrix into lists by species.
>
> Simply coercing to a matrix with as.matrix(inter) destroys the structure of
> the distance matrix.
>
> Any assistance is appreciated.
>
> Thanks!
>
> Cheers,
>
> Jarrett
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Using bind.tip and lapply on a multiPhylo object

2021-06-04 Thread Eliot Miller
 History (Negaunee
>> Integrative Research Center)
>> >> Chair, Biodiversity Committee, American Society of Mammalogists
>> >> Taxonomy Advisor, IUCN/SSC Small Mammal Specialist Group
>> >> personal web: n8u.org | Google Scholar <
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fscholar.google.com%2Fcitations%3Fhl%3Den%26user%3DzIn4NoUJ%26view_op%3Dlist_works%26gmla%3DAJsN-F6ybkfthmTdjTpow6sgMhWKn1EKcfNtmIF_wzZcev7yeHuEu5_aolFS85rWiVRHpiQgbwg43i6eS6kArrabLdFL4bntzUSRmlRP2CW4lbZqeEcColwdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=sa9VBUNzHzzPUecVRmknFoa36gEQA7hySS7uFuxXh9o%3Dreserved=0>
>> | ASU profile <
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fisearch.asu.edu%2Fprofile%2F3682356data=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674838188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=D9p3TXN7AdorpSqBqnydAvKNoPXOGZ0wR7ESw8bB4H0%3Dreserved=0
>> >
>> >> e: nathan.up...@asu.edu | Skype: nate_upham | Twitter: @n8_upham <
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Fn8_uphamdata=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674848184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=OM3Q8KIzJ%2BpAvHy6Z5B74%2FD%2Bsy7LkDGVCSAotBNwjnU%3Dreserved=0
>> >
>> >>
>> 
>> >>> On Jun 2, 2021, at 4:19 PM, Eliot Miller 
>> wrote:
>> >>>
>> >>> Hi Russell,
>> >>>
>> >>> A package I wrote a while back should be able to do that fairly
>> easily.
>> >>>
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fgithub.com%2Feliotmiller%2FaddTaxa__%3B!!IKRxdwAv5BmarQ!OZj7-dFRbxvUothKjSj6hr9B0eXscAO6LVWi1-a0w3J_PxlDqvsFDNb0lQrzxl2aIw%24data=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674848184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=kgDYJXKFXRFIM8mv1x8fViY6QDiEjTQ8qP5mQ0SUq3k%3Dreserved=0
>> The only paper it's described in
>> >>> remains
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__https%3A%2F%2Fbsapubs.onlinelibrary.wiley.com%2Fdoi%2Ffull%2F10.3732%2Fajb.1500195__%3B!!IKRxdwAv5BmarQ!OZj7-dFRbxvUothKjSj6hr9B0eXscAO6LVWi1-a0w3J_PxlDqvsFDNb0lQp7PnRRHg%24data=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674848184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000sdata=DmHEuwIvxP0uiRhdBPZ%2BuUWUoVpIQ5PW8Xfrjyv9Nyg%3Dreserved=0
>> >>> It's a wrapper for bind.tip, with some additional stuff. You basically
>> >>> would give it a taxonomic file where you identify the clades you're
>> >>> interested in (e.g. both of those Cercopithecus species could be
>> named some
>> >>> unique clade name and off you go, it'd add the missing one to the
>> other),
>> >>> then lapply that whole addTaxa command over the list of trees in
>> >>> multiPhylo. At some point I made laser a dependency, and it's
>> possible I
>> >>> left it in that state. If that's the case, you can still get laser
>> from old
>> >>> CRAN mirrors I believe. Let me know if you want more help.
>> >>>
>> >>> Best,
>> >>> Eliot
>> >>>
>> >>> On Wed, Jun 2, 2021 at 7:05 PM Russell Engelman <
>> neovenatori...@gmail.com>
>> >>> wrote:
>> >>>
>> >>>> Dear R-sig-phylo,
>> >>>>
>> >>>> I have been working with a mammalian phylogeny I recently downloaded
>> from
>> >>>> VertLife (
>> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__http%3A%2F%2Fvertlife.org%2Fphylosubsets%2F__%3B!!IKRxdwAv5BmarQ!OZj7-dFRbxvUothKjSj6hr9B0eXscAO6LVWi1-a0w3J_PxlDqvsFDNb0lQoEdEnMAg%24data=04%7C01%7Cliam.revell%40umb.edu%7C1174c283b881427e2df508d926253e2a%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637582763674848184%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw

Re: [R-sig-phylo] Using bind.tip and lapply on a multiPhylo object

2021-06-02 Thread Eliot Miller
Hi Russell,

A package I wrote a while back should be able to do that fairly easily.
https://github.com/eliotmiller/addTaxa The only paper it's described in
remains https://bsapubs.onlinelibrary.wiley.com/doi/full/10.3732/ajb.1500195
It's a wrapper for bind.tip, with some additional stuff. You basically
would give it a taxonomic file where you identify the clades you're
interested in (e.g. both of those Cercopithecus species could be named some
unique clade name and off you go, it'd add the missing one to the other),
then lapply that whole addTaxa command over the list of trees in
multiPhylo. At some point I made laser a dependency, and it's possible I
left it in that state. If that's the case, you can still get laser from old
CRAN mirrors I believe. Let me know if you want more help.

Best,
Eliot

On Wed, Jun 2, 2021 at 7:05 PM Russell Engelman 
wrote:

> Dear R-sig-phylo,
>
> I have been working with a mammalian phylogeny I recently downloaded from
> VertLife (http://vertlife.org/phylosubsets/). Unfortunately, the phylogeny
> is missing a large number of species, so I am trying to manually add these
> taxa to the phylogeny. I have a series of 100 trees that I am using to do
> things such as test for phylogenetic signal. I know how to use bind.tip to
> add new taxa to a single tree, but I am having more trouble with a
> multiPhylo object. I am primarily adding these taxa by placing them as
> sister to their nearest included relative (since most of them are elevated
> former subspecies), but the issue here is that in the 100 trees in the
> multiPhylo object the node representing the taxon to bind these taxa to is
> not the same across all trees due to shifting topologies.
>
> This is an example of the code I have been using, in which "tree" is the
> tree object. This works for a single 'phylo' tree but not 'multiphylo'.
>
> ```
> newtree<-lapply(tree,bind.tip,tip.label="Cercopithecus_albogularis",
> position=0.59,edge.length = 0.59,
>
> where=mrca(tree)["Cercopithecus_mitis","Cercopithecus_mitis"])
> ```
>
> Now, this code will not work, but I know exactly why: 'tree' is a
> multiPhylo object and so the 'where' argument cannot find the node for the
> terminal taxon. However, the issue is how can I tell R to repeat this
> 'where' argument for each of the 100 trees, since the node in question is
> not identical across these trees? Is there an easier way to do this than
> using the 'mrca' call for each terminal taxon? I've noticed adding a 'mrca'
> argument also increases computation time and if I am reinventing the wheel
> it would be nice to know if I am overthinking things.
>
> Sincerely,
> Russell
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] identifying phylogenetically equivalent nodes

2021-02-18 Thread Eliot Miller
Assuming trees are rooted and fully bifurcating, I think the following will
work. I tried a few tests and it seemed to work. I traded a few emails back
and forth with Jake to make sure I understood what he wanted. Guess what I
was supposed to be working on wasn't holding my attention...

Best,
Eliot

library(geiger)

first <- sim.bdtree(n=50)
second <- sim.bdtree(n=1000)
third <- sim.bdtree(n=2000)

tableSetup <- function(tree1, tree2)
{
  output <-
data.frame(matrix(nrow=min(c(length(tree1$tip.label),length(tree2$tip.label)))-1,
ncol=2))
  names(output) <- c("tree1", "tree2")
  output
}

#least inclusive=if there are multiple nodes in tree 2 which could
potentially be mapped to
#a node in tree 1, do you want to keep the smallest or the largest one? for
example:
#((A,B),Z) vs (((A,B),Z),C), where C doesn't occur in tree 1. Do you want
the matched node
#from tree 2 to be A,B,Z or A,B,Z,C.
equivCut <- function(tree1, tree2, results, least.inclusive)
{
  #identify nodes that appear more than once
  dups <- unique(results[,2][duplicated(results[,2])])

  #if there aren't any, return the original results
  if(length(dups)==0)
  {
return(results)
  }

  #loop through, add details on size of clade to data frame
  for(i in 1:length(dups))
  {
#set aside all the results that pertain to that node
setAside <- results[results[,2]==dups[i],]

#go through each node and figure out how many taxa descend from that
node
temp <- data.frame(matrix(nrow=dim(setAside)[1], ncol=2))
names(temp) <- c("node","no.taxa")
for(j in 1:dim(setAside)[1])
{
  temp[j,"node"] <- setAside[j,"tree1"]
  temp[j,"no.taxa"] <- length(extract.clade(tree1,
setAside[j,"tree1"])$tip.label)
}

#now you can decide which of these to keep
if(least.inclusive)
{
  keep <- temp$node[temp$no.taxa==min(temp$no.taxa)]
  toDrop <- setdiff(temp$node, keep)
  results <- results[!(results$tree1 %in% toDrop),]
}

else
{
  keep <- temp$node[temp$no.taxa==max(temp$no.taxa)]
  toDrop <- setdiff(temp$node, keep)
  results <- results[!(results$tree1 %in% toDrop),]
}
  }

  results
}

idMatches <- function(tree1, tree2, least.inclusive=TRUE)
{
  #set the results table up
  results <- tableSetup(tree1, tree2)

  #define tree1 nodes here
  nodes1 <- (length(tree1$tip.label)+1):max(tree1$edge)

  for(i in 1:length(nodes1))
  {
#set the correct row in the tree1 column to the node in question
results[i,1] <- nodes1[i]

#find the descendants of this node
tips1 <- tips(tree1, nodes1[i])

#drop these to just tips that are in tree 2
tips1 <- tips1[tips1 %in% tree2$tip.label]

#if there's nothing left, set to no match and move on
if(length(tips1)==0)
{
  results[i,2] <- "no.match"
  next()
}

#find the MRCA of those tips in tree 2
#if there's only a single taxon left, pull the node it descends from
(getMRCA will fail)
if(length(tips1==1))
{
  edge2 <- which.edge(tree2, tips1)
  mrca2 <- tree2$edge[edge2,][1]
}
else
{
  mrca2 <- getMRCA(tree2, tips1)
}

#find the descendants of that node
tips2 <- tips(tree2, mrca2)

#drop to just taxa that are in tree1
tips2 <- tips2[tips2 %in% tree1$tip.label]

#if these tips are equivalent, the nodes match
if(setequal(tips1, tips2))
{
  results[i,2] <- mrca2
}

else
{
  results[i,2] <- "no.match"
}
  }

  #consider what you want to do next. do you want to, e.g., add a row for
  #every not-yet-mentioned tree2 node and add "no.match" to the first
column,
  #or do you want to return as is, or do you want to only return matches?
for
  #now, drop to only matches and re-class both as integer so can demonstrate
  #equality no matter which tree is first or second
  results <- results[results[,2] != "no.match",]
  results[,2] <- as.integer(results[,2])

  #run the equivCut function
  results <- equivCut(tree1, tree2, results, least.inclusive)
  results
}

#always returns equivalent no matter which tree is first if you set it to
least inclusive = TRUE
system.time(test <- idMatches(first,second))
system.time(test2 <- idMatches(second,first))
setequal(test[,1], test2[,2])
setequal(test[,2], test2[,1])

#always returns equivalent no matter which tree is first if you set it to
least inclusive = TRUE
system.time(test3 <- idMatches(second, third))
system.time(test4 <- idMatches(third, second))
setequal(test3[,1], test4[,2])
setequal(test3[,2], test4[,1])

#here's how you might compare a set of trees to a single reference one
ref <- sim.bdtree(n=100)
target1 <- sim.bdtree(n=78)
target2 <- sim.bdtree(n=86)

vs1 <- idMatches(ref,target1)
vs2 <- idMatches(ref,target2)
names(vs1) <- c("ref","target1")
names(vs2) <- c("ref","target2")

final <- data.frame(ref=unique(c(vs1$ref, vs2$ref)))
final <- merge(final, vs1, all.x=TRUE)
final <- merge(final, vs2, all.x=TRUE)
final

On Thu, Feb 18, 2021 at 8:56 AM Emmanuel Paradis 
wrote:

> Hi 

Re: [R-sig-phylo] issue with add.species.to.genus

2019-09-25 Thread Eliot Miller
Hi Karla,

Check out the addTaxa package I wrote a while back (
https://github.com/eliotmiller/addTaxa). I suspect it can do what you want.
We hope to publish some formal tests of how this approach performs, but
I've been sidetracked. In the meantime if you use it there's the original
reference in the literature to it (
https://bsapubs.onlinelibrary.wiley.com/doi/full/10.3732/ajb.1500195). To
get it running you would need to install the legacy version of laser from
the CRAN repository on GitHub using devtools. That won't always be the
case, but I ran out of time to complete the project and it's currently a
dependency.

Best wishes,
Eliot

On Tue, Sep 24, 2019 at 5:42 PM Karla Shikev  wrote:

> Dear all,
>
> Some time ago, Liam Revell kindly provided the code that is now
> incorporated into phytools in the add.species.to.genus function, which
> randomly adds an additional species to a genus on a phylogeny. However,
> this function either adds a species to the root node, or to the branches
> after the MRCA of all species in a genus.
>
> Can anyone envision a way in which it would also be possible to add tips to
> the branch between the root and the MRCA of all species in a clade?
> Preferably in a way that could be analogous to a model of diversification
> (e.g. pure birth)?
>
> Thanks!
>
> Karla
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] patristic distance doubts and meanings

2019-02-06 Thread Eliot Miller
The amount of time two taxa have been evolving independently from one
another is, barring some complex introgression, independent of other
species in the tree. Pruning the tree from however many species to 700
won't affect the distances between those 700. After pruning, use
cophenetic() to nearly instantly calculate the relevant distances between
taxa. All the values you need are in the matrix. Access the evolutionary
distance between any two taxa by pulling the relevant element of the
resulting cophenetic matrix, e.g. copheneticMatrix["sp1", "sp2"]. If you
are interested in the time since two taxa shared a common ancestor,
assuming the tree is ultrametric and in units of time, that value is the
distance between those two taxa divided by 2.

Cheers,
Eliot

On Mon, Feb 4, 2019 at 5:30 PM Bruno Garcia Luize 
wrote:

> Thank you Liam,
>
> For sure it is a lot of computational time. I'm only interested in a subset
> of species, lets say close to 700 species in a regional species pool. I did
> the computations using fastDist and it take almost 7 hs to complete in a
> windows based 16 Gb RAM. The function was realy useful for my propose.
> Another doubt that came is if I prune the bigger tree with my species list
> and apply the ape::cophenetic the distances will remain the same or the
> prunning will change the tree edges lengths and consequently the patristic
> distances. But, by the way I see that fastDist did the work I want.
>
> Best regards,
>
> Bruno Garcia Luize
>
> PhD candidate Ecology and Biodiversity – São Paulo State University (Unesp)
>
>
>
> Em seg, 4 de fev de 2019 às 16:53, Liam Revell 
> escreveu:
>
> > Dear Bruno.
> >
> >  > To estimate species divergence time between pair of species, I'm using
> >  > the phylogeny in Smith & Brown 2018 which is rooted and contain
> >  > 353 185 seed plant species along with 85 679 nodes, branch lengths
> >  > are dated. I'm applying the R function phytools::fastDist for a list
> >  > of sampled species to achieve a matrix of patristic distance.
> >
> > To get this straight, do you want to compute pairwise distances from a
> > tree containing over 353 thousand taxa? One problem that immediately
> > arises is the memory that would be required to store such a matrix. If
> > we assume that each element of the matrix occupies 8 bytes of memory,
> > and that we are economic & record only the upper or lower diagonals of
> > the matrix, we would still need about 500 GB to store the matrix.
> >
> > Maybe it would be sufficient to write each distance to file, so you
> > don't have to worry as much about memory (just enough disk space to
> > store the file). In that case, you could use fastDist to compute each
> > distance, but this would take a while as there are 62,369,645,520
> > non-trivial distances between taxa (that is, excluding the distance of
> > each taxon to itself and remembering that Dij=Dji). fastDist can indeed
> > calculate distances between tips on such a large tree, but (on my
> > computer) it takes about 0.5s per tip. At that rate it would take about
> > 10 years to compute all these distances.
> >
> > Perhaps you actually only need to compute the distances between a subset
> > of the taxa on your tree, like a few hundred up to a couple of thousand.
> > If that is the case, you should be able to use fastDist; however, for
> > cases in which all distances (not just one or a few) are required then
> > cophenetic (which computes all distances between all tips in the tree)
> > will be much faster than fastDist. fastDist is really only useful if one
> > or a small number of distances are required in which case it can be used
> > to compute these without calculating all patristic distances from the
> tree.
> >
> >  > As I see in Revell's blog "the patristic distance between them is
> >  > simply the sum of the heights above the root for species i and j minus
> >  > two times the height above the root of the common ancestor of i & j",
> >  > is this the same that Fourment and colleagues define as a patristic
> >  > distance: "A patristic distance is the sum of the lengths of the
> >  > branches that link two nodes in a tree"?
> >
> > Yes, these distances are the same. The patristic distance is the sum of
> > the edge lengths that connect a pair of taxa, but this value can be
> > computed by taking the sum of the total distance from the root to each
> > taxon, and then subtracting two times the distance from the root to
> > their common ancestor.
> >
> >  > Furthermore, I'm wondering if the results of the phytools::fastDist is
> >  > interchangeable with the adephylo::distTips(method="patristic")?
> >
> > I can't comment on that function, but the distances from fastDist are
> > the same as in ape::cophenetic.
> >
> >  > Finally, is the patristic distance the right choice for my propose or
> >  > should I use another phylogenetic distance?
> >
> > I don't know.
> >
> > All the best, Liam
> >
> > Liam J. Revell
> > Associate Professor, University of 

Re: [R-sig-phylo] Adding species to genera tree as polytomies

2018-10-16 Thread Eliot Miller
Hi there,

If I read this right, you're also wanting to loop this over multiple
genera. If so, it might save some time to try this with the addTaxa package
(https://github.com/eliotmiller/addTaxa/blob/master/DESCRIPTION). I haven't
worked on this project in a while, and I left the documentation in an
unfortunate place where it might not match exactly how the functions work
these days. But, it should do what you want it to if you can get it to go.

Rich's idea is good if you want to learn a bit more about Newick formats.
Count your parentheses up when you can't figure out how you broke it.

Eliot

On Tue, Oct 16, 2018 at 2:30 PM Richard Grenyer <
richard.gren...@ouce.ox.ac.uk> wrote:

> In the interests of furthering appalling hackery of the worst kind, on the
> assumption you want to replace *all* generic nodes with their descendants
> (or you don’t care about ultrametricity), you can do this easily with a
> good text editor and the genus tree in one of the parenthetical notation
> formats:
>
> Find: Genus_name
> Replace: (Species_one:x, Species_n:x)
>
> You could even do it *in R* with grep(). Obviously there’s no error
> checking and you can end up with horrible downstream problems. It will
> however give you the true experience of phyloinformatics in the 1990s.
>
> Good luck!
>
> Rich
>
>
>
> Rich Grenyer
> Associate Professor of Biogeography and Biodiversity, SOGE & Fellow of
> Jesus College
> University of Oxford
>
>
> 
> From: R-sig-phylo  on behalf of Liam
> J. Revell 
> Sent: Tuesday, October 16, 2018 7:02 pm
> To: Liam Kendall; r-sig-phylo@r-project.org
> Subject: Re: [R-sig-phylo] Adding species to genera tree as polytomies
>
> Hi Liam.
>
> First of all, great choice of names!
>
> Secondly, add.species.to.genus is a very old function & I wouldn't be
> surprised to find that it had some bugs. Be forewarned!
>
> Thirdly, I used Will's suggestion & got the function to work in the
> script you sent to me off-list, but with one additional modification
> that in your 'for' loop you were not replacing the tree with the added
> tip in each iteration of the loop. I.e.:
>
> new.tree<-tree
> for (i in 1:length(tips)){
> new.tree<-add.species.to.genus(tree,tips[i])
> }
>
> will only result in a tree with one more tip than the original tree.
> Your script should instead have the form:
>
> new.tree<-tree
> for (i in 1:length(tips)){
> new.tree<-add.species.to.genus(new.tree,tips[i])
> }
>
> Note that where="root" does not work if a genus is monotypic (as yours
> will be the first time a new tip is added to a given genus) & instead
> the species will be added halfway along the edge leading to that genus.
> Henceforward, additional species will be added to this point. This (or
> some variant thereof) must be the case, because if new tips were instead
> added at the start of this edge then sister genera would invariably form
> single, polytomous combs. (Draw it on a piece of paper. You'll see what
> I mean.)
>
> Finally, I noticed that some of your edge lengths in the original tree
> have negative lengths. This is not a problem for the method, as it turns
> out, but it will create an interesting visualization when graphed.
>
> Here is your fully modified script:
>
> library(phytools)
> bee_tree=read.tree("bee_tree.nex")
> species=read.csv("species.csv",stringsAsFactors = FALSE)
> beetree<-bee_tree
> ## Will's suggestion
> beetree$tip.label<-paste(beetree$tip.label,"_sp.",sep="")
> for(i in 1:length(species$Genus_species)){
> beetree<-add.species.to.genus(beetree,species$Genus_species[i],
> where="root")
> }
> ## prune out these same taxa
> ii<-grep("sp.",beetree$tip.label)
> beetree<-drop.tip(beetree,beetree$tip.label[ii])
>
> I hope this is helpful.
>
> All the best, Liam
>
> Liam J. Revell
> Associate Professor, University of Massachusetts Boston
> Profesor Asistente, Universidad Católica de la Ssma Concepción
> web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org
>
> On 10/15/2018 11:01 PM, Liam Kendall wrote:
> > Hi members,
> >
> > I am struggling with what I think is a relatively simple problem. I have
> a genera tree (i.e. genera are the branch tips) that I need to add 390
> species to as polytomies with equal branch lengths below the genera
> tips/nodes.
> >
> > Can anyone help me do this in R? I have tried a for loop using
> add.species.to.genus from phytools but it doesn’t work, I am guessing this
> is because the genera are tips rather than nodes (and I cant debug the code
> to find a solution).
> >
> > Is there another function in the R universe that might work?
> >
> > Any help would be much appreciated.
> >
> > Best,
> > Liam
> > ___
> > R-sig-phylo mailing list - R-sig-phylo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> > Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
> >
>
> ___
> R-sig-phylo mailing list - 

Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-07 Thread Eliot Miller
Unless it does something internally already, you might need to do something
like: options(digits=10) before running the node.depth.edgelength(tree) to
identify your problem.

Yes, I wasn't referring to branching.times. I was talking about various
methods, e.g., BAMM, that don't perform well (or at all) with zero-length
branches.

Cheers,
Eliot

On Mon, May 7, 2018 at 5:27 PM, David Bapst <dwba...@tamu.edu> wrote:

> Interesting, Rafael. Perhaps it is just barely within tolerance for
> force.ultrametric, but not within the zone to avoid issues with
> branching.times?
>
> What did
>
> node.depth.edgelength(tree)
>
> return? That should give us an idea how far each tip is from the root.
>
> As a note, Eliot, I don't think I've seen branching.times have
> problems with tree with zero-length branches, although that is pretty
> unusual with the ultrametric trees valid with branching.times.
>
> Cheers,
> -Dave
>
> On Fri, May 4, 2018 at 8:32 AM, Rafael S Marcondes
> <raf.marcon...@gmail.com> wrote:
> > Hi Elliot et al,
> >
> > Thanks for all the helpful answers, and sorry for my delay in getting
> back.
> > min(tree$edge.length) returns a nonzero positive number, but running
> > force.ultrametric on the tr did not cause that warning message to go
> away...
> >
> > --
> > Rafael Sobral Marcondes
> > PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
> >
> > Museum of Natural Science
> > Louisiana State University
> > 119 Foster Hall
> > Baton Rouge, LA 70803, USA
> >
> > Twitter: @brown_birds
> >
> >
> >
> > On Fri, May 4, 2018 at 8:22 AM Eliot Miller <eliot.is...@gmail.com>
> wrote:
> >>
> >> I suggest calling min(tree$edge.length) on any tree you plan to use for
> >> comparative methods, including the one you're having trouble with
> Rafael. If
> >> you get a negative value, then something is really funny and you need to
> >> solve it. If you get a zero then various comparative methods will throw
> >> errors, but it's not the end of the world--there are workarounds. If
> neither
> >> of these things is true, and the tree is still returning FALSE to
> >> is.ultrametric, then assuming the tree is supposed to be ultrametric,
> it's
> >> almost certainly a tolerance thing (which you can check directly by
> tweaking
> >> the tol method in the is.ultrametric function). In that case, I've had
> good
> >> experiences using the phangorn/phytools approach to force the tree
> >> ultrametric.
> >>
> >> Eliot
> >>
> >> On Thu, May 3, 2018 at 5:08 PM, Liam J. Revell <liam.rev...@umb.edu>
> >> wrote:
> >>>
> >>> Just to clarify, force.ultrametric is not a formal rate-smoothing
> method
> >>> or anything like that. It is intended only for use to resolve numerical
> >>> precision issues such as the one raised in this thread.
> >>>
> >>> 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/3/2018 4:21 PM, Theodore Garland wrote:
> >>>>
> >>>> I'll just add that it is always a really good idea to view the trees
> you
> >>>> (think you) are using, not just rely on the variance-covariance
> matrices
> >>>> derived from them and used in PGLS analyses, etc.  Several times when
> I was
> >>>> compiling trees and data from the literature authors sent me tree
> files
> >>>> (e.g., Nexus) that did not match what they showed in a paper or
> described in
> >>>> the methods.  Sometimes this was because the default display in
> Mesquite is
> >>>> NOT "branches proportional to lengths," but I am sure potentially
> misleading
> >>>> displays occur in some other programs as well.
> >>>>
> >>>> If one does force a tree to become ultrametric, then make sure you
> >>>> provide that tree and the original in the Online Supplemental
> Material or
> >>>> whatever, and clearly say what you did.
> >>>>
> >>>> Cheers,
> >>>> Ted
> >>>>
> >>>>
> >>>>
> >>>> Theodore Garland, Jr., Distinguished Professor
> >>>>
> >>>> Department of Evolution, Ecology, and Organismal Biology (EEOB)
> >>

Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-04 Thread Eliot Miller
I suggest calling min(tree$edge.length) on any tree you plan to use for
comparative methods, including the one you're having trouble with Rafael.
If you get a negative value, then something is really funny and you need to
solve it. If you get a zero then various comparative methods will throw
errors, but it's not the end of the world--there are workarounds. If
neither of these things is true, and the tree is still returning FALSE to
is.ultrametric, then assuming the tree is supposed to be ultrametric, it's
almost certainly a tolerance thing (which you can check directly by
tweaking the tol method in the is.ultrametric function). In that case, I've
had good experiences using the phangorn/phytools approach to force the tree
ultrametric.

Eliot

On Thu, May 3, 2018 at 5:08 PM, Liam J. Revell  wrote:

> Just to clarify, force.ultrametric is not a formal rate-smoothing method
> or anything like that. It is intended only for use to resolve numerical
> precision issues such as the one raised in this thread.
>
> 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/3/2018 4:21 PM, Theodore Garland wrote:
>
>> I'll just add that it is always a really good idea to view the trees you
>> (think you) are using, not just rely on the variance-covariance matrices
>> derived from them and used in PGLS analyses, etc.  Several times when I was
>> compiling trees and data from the literature authors sent me tree files
>> (e.g., Nexus) that did not match what they showed in a paper or described
>> in the methods.  Sometimes this was because the default display in Mesquite
>> is NOT "branches proportional to lengths," but I am sure potentially
>> misleading displays occur in some other programs as well.
>>
>> If one does force a tree to become ultrametric, then make sure you
>> provide that tree and the original in the Online Supplemental Material or
>> whatever, and clearly say what you did.
>>
>> Cheers,
>> Ted
>>
>>
>>
>> Theodore Garland, Jr., Distinguished Professor
>>
>> Department of Evolution, Ecology, and Organismal Biology (EEOB)
>>
>> University of California, Riverside
>>
>> Riverside, CA 92521
>>
>> Office Phone: (951) 827-3524 
>>
>> Facsimile: (951) 827-4286  (not confidential)
>>
>> Email: tgarl...@ucr.edu 
>>
>> http://www.biology.ucr.edu/people/faculty/Garland.html
>>
>> http://scholar.google.com/citations?hl=en=iSSbrhwJ
>>
>>
>> Director, UCR Institute for the Development of > >Educational Applications 
>>
>>
>> Editor in Chief, /Physiological and Biochemical Zoology <
>> http://www.press.uchicago.edu/ucp/journals/journal/pbz.html>/
>>
>>
>> Fail Lab: Episode One
>>
>> _https://www.youtube.com/watch?v=c0msBWyTzU0_
>>
>>
>> On Thu, May 3, 2018 at 1:09 PM, Liam J. Revell > > wrote:
>>
>> I haven't been closing following this thread, so I'm not sure that
>> this is relevant - but phytools has a function called
>> 'force.ultrametric' (I believe) that does precisely what its name
>> suggests it might.
>>
>> 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/3/2018 3:34 PM, David Bapst wrote:
>>
>> Hmm. I hope that isn't the case - branching.times() is used pretty
>> widely in ape-dependent packages for getting node ages from dated
>> ultrametric trees, and if such minimally non-ultrametric trees can
>> cause branching.times throw negative node ages, then I'm really
>> concerned what impact that might have elsewhere in the R-phylo
>> universe.
>> -Dave
>>
>> On Wed, May 2, 2018 at 2:30 PM, Brian O'Meara > > wrote:
>>
>> On Wed, May 2, 2018 at 2:53 PM, David Bapst
>> > wrote:
>>
>>
>> Given that your tree appears to be non-ultrametric
>> enough to cause
>> branching.times to throw some nonsensical node ages, if
>> it is supposed
>> to be ultrametric. I recommend checking it carefully to
>> figure out why
>> the tips seem to not quite be at the same distance from
>> the root.
>>
>>
>>Sometimes this happens with tree import from a file -- it
>> could be a newick
>> tree with branch lengths precise to the hundredths but a lot
>> of the R
>> ultrametric tests by default 

Re: [R-sig-phylo] Problem with negative ages in OUwie.boot?

2018-05-02 Thread Eliot Miller
What does: min(tree$edge.length) say?

Eliot

On Wed, May 2, 2018 at 2:22 PM, Rafael S Marcondes 
wrote:

> Here's a little more info that may be relevant: the tree is not supposed to
> have negative dates. Although when I do is.ultrametric(tr) I get FALSE, I
> have always been just ascribing that to lack of precision, in part because
> it has never been a problem with OUwie().
>
>
> *--*
> *Rafael Sobral Marcondes*
> PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
>
> Museum of Natural Science 
> Louisiana State University
> 119 Foster Hall
> Baton Rouge, LA 70803, USA
>
> Twitter: @brown_birds 
>
>
>
> On Wed, May 2, 2018 at 1:08 PM Rafael S Marcondes  >
> wrote:
>
> > Hi all,
> >
> > I need some help with a warning message I've been getting when running
> > parametric bootstrapping in OUwie.
> >
> > >OUwie.boot(nboot=1, simmap.tree=F...)
> > Beginning parametric bootstrap -- performing 1 replicates
> > Warning: Some dates are negative? rootAge may be incorrectly defined or
> > you are using a time-scaling method that warps the tree, like aba or
> zbla.
> > Initializing...
> > Finished. Begin thorough search...
> > Finished. Summarizing results.
> >
> > Initially I didn't give it much thought, but my bootstrapping results are
> > quite unexpected, and I'm starting to think that may be related to that
> > warning.
> >
> > I don't get that warning when I run OUwie() with the same
> > tree/dataset/settings, and I've been able to trace it to the function
> > dateNodes in the package paleotree, but haven't been able to go any
> further
> > than that.
> >
> > Thanks in advance for any help!
> >
> >
> >
> > *--*
> > *Rafael Sobral Marcondes*
> > PhD Candidate (Systematics, Ecology and Evolution/Ornithology)
> >
> > Museum of Natural Science 
> > Louisiana State University
> > 119 Foster Hall
> > Baton Rouge, LA 70803, USA
> >
> > Twitter: @brown_birds 
> >
> >
>
> [[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-ph...@r-project.org/
>

[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Add terminal branches to tree

2017-06-19 Thread Eliot Miller
Just to add to the slew of other good options, I have a small package up on
GitHub (https://github.com/eliotmiller/addTaxa/tree/master/R) that is
basically a big loop around Liam's bind.tip. There are examples included
with the package. The main function you'd be interested in is
randomlyAddTaxa(). It works fairly well last I checked, but there are some
limitations and the package is in need of an overhaul. The main limitation
is when two clades (A and B) are sister to one another and you intend to
add a taxon into the clade (A+B); it's currently impossible to generate the
topology (C,(A,B)), even though that's monophyletic and shouldn't be
prohibited. I aim to fix this at some point within the next month or two if
anyone's interested.

Eliot

On Mon, Jun 19, 2017 at 8:30 AM, Christoph Heibl 
wrote:

> Another possibility would be addSingleTip() and addTips() from the
> megaptera package (https://github.com/heibl/megaptera). The latter
> function can add any number of tips; the loop that Liam mentioned is
> already build into that function. This is potentially very slow, but for
> your tree size it should work. Note that you have to specify the 'tax'
> argument; it allows you to add tips also to internal nodes of higher rank
> than genera. In your case where you have only genera you can create 'tax'
> easily like this:
>
> ## 'species' is a vector of tip labels that you want to add
> ## will work only if your tip labels are of the form
> "Genus_epithet-or-any-other-string"
> library(megaptera)
> tax <- data.frame(genus = strip.spec(species),
> species = species,
> stringsAsFactors = FALSE)
>
>
>
> Christoph Heibl
> An der Weiherleite 3
> 86633 Neuburg an der Donau
> 08431-53 96 534 (Festnetz)
> 0176-23 86 57 92 (Mobil)
> christoph.he...@gmx.net
>
>
> Am 19.06.2017 um 14:06 schrieb Liam Revell:
>
> > The function add.species.to.genus may do what you want. It adds a single
> species to the group defined by the MRCA of members of a genus, according
> to multiple criteria (randomly and so on). It can add only one species at a
> time, so you will need to write a for loop or something to iterate over the
> species that you‚d like to add.
> >
> > --
> > Liam J. Revell, Associate Professor of Biology
> > University of Massachusetts Boston
> > web: http://faculty.umb.edu/liam.revell
> > email: liam.rev...@umb.edu
> >
> > Sent from my Windows 10 phone
> >
> > From: Sergio Ferreira Cardoso ferreira-card...@umontpellier.fr>
> > Sent: Monday, June 19, 2017 6:58 AM
> > To: r-sig-phylo
> > Subject: [R-sig-phylo] Add terminal branches to tree
> >
> > Hello all,
> >
> > I'm using the package 'phytools' to try to add terminal branches to a
> tree (attached). I tried to use add.everywhere function to add terminal
> branches. I have 167 terminal taxa inside each of the 7 genera on my tree.
> Basically, I just wanted to add some dozens of specimens to the end of each
> branch, but I don't find a way to do it. Is there any tool that would allow
> me to do this? Like adding 30 branches to 'Phal', adding 25 to 'Phat', etc.
> >
> > Thanks in advance.
> >
> >
> >
> > --
> > Institut des Sciences de l'Evolution
> > UMR5554, CNRS, IRD, EPHE
> > Université de Montpellier
> > Place Eugène Bataillon
> > 34095 Montpellier Cedex 05
> > France
> > Email: sergio.ferreira-card...@umontpellier.fr
> > Tel: +33 (4 ) 67 14 46 52
> >
> >   [[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-ph...@r-project.org/
>
>
> [[alternative HTML version deleted]]
>
>
> ___
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at http://www.mail-archive.com/r-
> sig-ph...@r-project.org/
>

[[alternative HTML version deleted]]

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

Re: [R-sig-phylo] ape prop.part error malloc(): memory corruption

2017-06-01 Thread Eliot Miller
Your Newick string is badly formatted. See:

plot(t1)

Error in plot.phylo(t1) :
  there are single (non-splitting) nodes in your tree; you may need to use
collapse.singles()

On Thu, Jun 1, 2017 at 1:31 AM, Mario José Marques-Azevedo <
mariojm...@gmail.com> wrote:

> Dears,
>
> I'm using extract.clade from ape package and get some issues. I'm using
> phytools package to load tree with single clade like above:
>
> library(phytools)
>
> t1 <- read.newick(text='(A_1,A_2,)A,(B1,B2,B3)B)C,(D1,(E1,E2)
> E)D),(F1)F)G)R;')
>
> t2 <- read.newick(text='A_1,A_2,)A,(B1,B2,B3)B)C,D1))),(
> E1,E2)E)D),(F1)F)R;
>
> When I extract 'F' clade, for instance:
>
> c1 <- extract.clade(t1, 'F')
>
> or
>
> c2 <- extract.clade(t2, 'F')
>
> I have this error:
>
> Error in prop.part(phy) : attempt to set index 8/8 in SET_VECTOR_ELT
>
> I have one tree with mode than 300 tips. When I try extract any clade, I
> have the same error. If I repeat the command I have this one:
>
> *** Error in `/usr/lib/rstudio/bin/rsession': malloc(): memory corruption:
> 0x0a3aaa40 ***
>
> My configurations was:
>
> platform   x86_64-pc-linux-gnu
> arch   x86_64
> os linux-gnu
> system x86_64, linux-gnu
> language   R
> version.string R version 3.3.3 (2017-03-06)
>
> phytools (0.6.0), ape (4.1), maps (3.1.1), Rcpp (0.12.10)
>
> I try update R to 3.4 and recompile all my packages, but I get the same
> error.
>
> My new configurations:
>
> platform   x86_64-pc-linux-gnu
> arch   x86_64
> os linux-gnu
> system x86_64, linux-gnu
> language   R
> version.string R version 3.4.0 (2017-04-21)
>
> phytools (0.6.0), ape (4.1), maps (3.1.1), Rcpp (0.12.10)
>
> I don't know why I have this error if I can extract with the same commands
> some time ago.
>
> I have the same error if I run in RStudio or in terminal. When I use
> RStudio, it abort after the error.
>
> I try Google, but I don't found nothing that can help me.
>
> Thank you and best regards,
>
> Mario
>
>
> 
> Mario José Marques-Azevedo
> Ph.D. Candidate in Ecology
> Department of Plant Biology, Institute of Biology
> University of Campinas, Campinas, São Paulo, Brazil
> https://github.com/mariojose 
>
> [[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-ph...@r-project.org/

[[alternative HTML version deleted]]

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

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

2015-10-30 Thread Eliot Miller
What I'm about to describe is essentially an elaborate wrapper for Liam's
bind.tip, so he deserves the credit for figuring this all out. But if you
are interested, I have a small package on GitHub that will automate this
for you. It probably doesn't make much difference with so few taxa you need
to add. If you do want to do it, you would create a data frame with the
first column "species", where you'd list all taxa, both those in the
original tree and those that you want to add. The second column would be
"group". In your case you could just do something like give the species
that are in the tree and those you want to bind to them the same group
name, e.g. "H1". All other species you never wanted to get a tip bound to
them could get some other name, e.g. "nothere". There are a few options for
branch lengths. It looks like you want to sample from a uniform
distribution of min=0 and max=the branch in question. That is an option on
there now too. The package has examples to explain more. But again, with so
few tips you probably want to just iterate over it like Liam said.

Cheers,
Eliot

On Fri, Oct 30, 2015 at 1:16 PM, Liam J. Revell  wrote:

> 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 tel. +34 963 543
>> 658fax +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 mailing list - R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
> Searchable archive at
> http://www.mail-archive.com/r-sig-phylo@r-project.org/
>

[[alternative HTML version deleted]]

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

Re: [R-sig-phylo] algorithm for maximum and minimum phylogenetic diversity

2014-11-13 Thread Eliot Miller
Hello Leonardo,

I'm I understand your question correctly, I believe that when using mean
pairwise phylogenetic distance (e.g., MPD from the picante package) the
maximum MPD will occur between the two most distantly related species in
the phylogeny, and the minimum will occur between the two most closely
related. With PD, the maximum will occur with the entire phylogeny, and the
minimum will again occur with the two most closely related species. If you
really want to calculate that (my guess is I misunderstood your question),
you could simply subset the pairwise genetic distance matrix from
cophenetic() to the relevant species and prune the tree accordingly.

One can't calculate MPD with  2 species. I suppose one could calculate PD
with  2 species if you wanted to define it as going through the root,
but then PD would just equal the tree height, assuming an ultrametric tree,
and there would be no single tree with minimum PD.

Best,
Eliot

On Thu, Nov 13, 2014 at 9:28 AM, Leonardo R� Jorge 
leonardorejo...@gmail.com wrote:

 Dear list members,

 I am studying the phylogenetic structure of interactions, and in order to
 build null models I need to calculate, for a given phylogeny with N
 species, what is the subset K (for K = 1 to N) of the species with maximum
 (and minumum) phylogenetic diversity, measured as mean phylogenetic
 distance and/or PD.
 After looking up, it does not look like a trivial problem as it would seem
 at first thought, and I am struggling to find some already written code, or
 at least some algorithm or strategy to measure this. Do you have any
 advice?

 Best regards,
 Leonardo R. Jorge

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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

Re: [R-sig-phylo] Displaying posterior probability in BEAST tree output

2014-01-17 Thread Eliot Miller
Mariana, see:
https://stat.ethz.ch/pipermail/r-sig-phylo/2013-June/002829.html


On Fri, Jan 17, 2014 at 4:31 PM, Mariana Vasconcellos
marian...@utexas.eduwrote:

 Dear all:
 I am trying to label the posterior probabilities in the nodes of the tree
 I generated in BEAST. Using nodelabels() doesn't seem to work. I also tried
 read.beast() using the package phyloch, but the following error appears:

  tree-read.beast(BEASToutput.tre)
 Error in (i2 + 1):end : argument of length 0

 Does anybody know an easy solution to label the nodes of a tree generated
 in BEAST with the posterior probabilities?

 Thank you very much,

 --
 Mariana Mira Vasconcellos
 marian...@utexas.edu
 PhD candidate
 Ecology, Evolution  Behavior
 Integrative Biology
 The University of Texas at Austin





 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] APE error message

2013-09-16 Thread Eliot Miller
Are you trying to load a single tree or multiple trees in a single Nexus
file? What function are you trying to use to load the tree(s)?


On Mon, Sep 16, 2013 at 5:46 PM, BIGANZOLI FERNANDO bigan...@agro.uba.arwrote:

 Hello all
 I'm new with APE. I'm trying to open a NEXUS tree with 109 sp and with many
 polytomies and I received the following error message: Error en trees[[i]]
 : subíndice fuera de  los límites
 Anyone know what that the error means? Ape has a maximum number of species?
 thanks!
 Fernando

 --
 Fernando Biganzoli
 Departamento de Métodos Cuantitativos y Sistemas de Información
 Facultad de Agronomía, UBA

 [[alternative HTML version deleted]]


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


[[alternative HTML version deleted]]

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

Re: [R-sig-phylo] Substitute for functions on the laser package

2013-09-03 Thread Eliot Miller
Hi Mariana,

To install from tar.gz: rtm.wustl.edu/writings/htrtargz.pdf

See also Liam's functions ltt() in phytools.

Cheers,
Eliot


On Tue, Sep 3, 2013 at 11:20 PM, Mariana Vasconcellos
marian...@utexas.eduwrote:

 Thanks, Liam! But, unfortunately I don't know how to build from source. I
 downloaded Xcode and the laser_2.3.tar.gz. But, I have no idea of how to
 install from source. If someone could help with any advise, that would be
 great!  Also, does anyone have another option to calculate decreasing
 speciation rate, increasing extinction rate or both using a different
 package?

 Thank you very much!

 --
 Mariana Vasconcellos
 Ecology, Evolution  Behavior
 Integrative Biology
 The University of Texas at Austin




 On Sep 3, 2013, at 10:05 PM, Liam J. Revell liam.rev...@umb.edu wrote:

  Hi Mariana.
 
  You can download old versions of laser from the CRAN archive (
 http://cran.r-project.org/src/contrib/Archive/laser/); however you will
 have to build from source. This is easy if you have Xcode (for Mac OS) or a
 gcc compiler installed. If you do not, and cannot figure out how to install
 from source, then respond to the list  I'm sure someone will help out 
 post a package binary for you.
 
  - 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://blog.phytools.org
 
  On 9/3/2013 10:39 PM, Mariana Vasconcellos wrote:
  Dear all:
  I just performed a test of the gamma-statistic on my tree and I found
 that diversification is not constant in time. So, I would like to perform
 the function fitSPVAR, fitEXVAR and fitBOTHVAR using the laser package.
 But, I just saw that the laser package was removed from the CRAN
 repository. Could anyone tell me what other alternative package I could use
 to develop and test models of decreasing speciation rate, increasing
 extinction rate or both? Does MEDUSA do this sort of analyses?
 
  Thank you for your help!
  Mariana
 
 
 
 
 
 
   [[alternative HTML version deleted]]
 
  ___
  R-sig-phylo mailing list - R-sig-phylo@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
  Searchable archive at
 http://www.mail-archive.com/r-sig-phylo@r-project.org/
 


 [[alternative HTML version deleted]]

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



[[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] Problem with R package checking

2013-08-08 Thread Eliot Miller
Tristan,

I ran into that problem when I wasn't exporting the function (i.e. it was
an internal function). If you use the package devtools to make your package
than you add a roxygen comment to the effect of #' @export and it will pass
the example checks. Not sure what the equivalent is with building it that
way, but perhaps that helps.

Cheers,
Eliot


On Thu, Aug 8, 2013 at 12:20 PM, Tristan Stayton tstay...@bucknell.eduwrote:

 Hello friends,

 Thanks to everyone who sent me suggestions a while ago on help developing R
 packages.  I've been progressing well since then, but lately I've hit a
 snag.  My examples will not run during a package check (R CMD check)
 because R can't find the functions that the examples are for (that is, when
 it tries to run the example from the .Rd file for the function convnum,
 it can't find the function convnum).  The .R files for the relevant
 functions are all where they're supposed to be (in the R folder in the
 folder for the package).  I've tried various options for the NAMESPACE
 file, thinking that this is probably where the problem is, to no avail, but
 I'm shaky on this particular part of the package.

 Has anyone encountered this problem before?  If anyone has any ideas or
 advice, I'd be most grateful.

 Thanks,

 Tristan

 --
 C. Tristan Stayton
 Associate Professor of Biology
 Bucknell University
 Lewisburg, PA  17837

 Office:  570-577-3272

 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Getting started making R packages

2013-07-12 Thread Eliot Miller
Tristan,

Check out the package devtools, and before submitting to CRAN make sure you
read: cran.us.r-project.org/doc/manuals/R-exts.pdf

There are obviously people on here who know a million times more than me,
and not that I've gotten very far, but I'm trying to figure this out myself
at the moment. Email me directly and I'll let you know what I find as I go.

Cheers,
Eliot


On Fri, Jul 12, 2013 at 1:19 PM, Tristan Stayton tstay...@bucknell.eduwrote:

 Hello,

 I'm relatively new to the world of R and need some general advice.  I have
 a number of R functions that I'd like to put together in a package and
 distribute via CRAN, and I've found a few more or less helpful tutorials on
 the subject.  However, I seem to be getting stuck with rtools (running R
 CMD check, etc...) and even if I get past that I'm sure other issues will
 come up.  So I'm wondering if there are any resources or tutorials
 available which you all would recommend.  What was helpful to you when you
 were first learning to build and distribute packages?

 Thanks in advance.  And feel free to let me know if this is not the proper
 venue for such questions.

 Tristan

 --
 C. Tristan Stayton
 Associate Professor of Biology
 Bucknell University
 Lewisburg, PA  17837

 Office:  570-577-3272

 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


[R-sig-phylo] question about measurement error in phylogenetic signal

2013-07-03 Thread Eliot Miller
Hello all,

I have been trying to get something to work in a number of different
packages and with a number of different approaches today that I couldn't
get to run in a believable way. Before I spend another day on this, I was
wondering what people think about the idea in general.

I have a dataset of disease prevalence across ~100 species. There are ~2000
individuals total across the dataset, with 4 individuals per species.
Prevalence per individual is coded as 0 or 1. I am interested in the
phylogenetic signal of disease prevalence across the species. One approach
that works is to simply calculate prevalence as the species-specific mean,
i.e. if 3 individuals of 6 for a species had the disease, the prevalence
would be 3/6 = 0.5. Then one can use these values with e.g. phylosig() (I
arcsin sqrt transformed these proportions here). Like the few other
published tests of phylogenetic signal in disease prevalence, there is
little signal here. I could leave it at that, because in general there are
very low detections in this dataset and it's probably not ideally suited to
address this question anyhow.

That aside however, because not all individuals of a given species always
have the disease, I wanted to incorporate measurement error. So, based on
the calculation for SE for binary data from the site:
http://www.researchgate.net/post/Can_standard_deviation_and_standard_error_be_calculated_for_a_binary_variable,
I also calculated a species-specific SEs as the
sqrt(mean(prevalence)*((1-
mean(prevalence))/individuals)).

What do people think about this? It's hardly measurement error in the sense
we normally mean it. On the other hand, I think it would be neat if there
were some way to account for variation among individuals in prevalence, and
the influence this has on phylogenetic signal.

Cheers,
Eliot

[[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] Fwd: Listing all tips with 0 length terminal branches

2013-06-17 Thread Eliot Miller
Just forwarding this alternative to the list in case anyone is interested.
As Liam pointed out, branch lengths of 0 might not be exactly what you're
after, depending on the situation. This could also be done using
cophenetic() on a phylo object and subsetting accordingly...

-- Forwarded message --
From: Roey Angel an...@mpi-marburg.mpg.de
Date: Wed, Jun 12, 2013 at 3:11 PM
Subject: Re: [R-sig-phylo] Listing all tips with 0 length terminal branches
To: Eliot Miller em...@mail.umsl.edu


 Works great, thanks.
I just wonder if it's really necessary to convert to an S4 object.

Cheers
Roey


On 06/12/2013 06:54 PM, Eliot Miller wrote:

 Is this what you want? This should return the tip labels of all taxa
connected to their most recent common ancestor by a branch length of zero.
You need to use the phylobase package and load a tree in in Newick format.

library(phylobase)

ape.phylo - read.tree(apeTree.tre)

phylobase.phylo - suppressWarnings(as(ape.phylo,phylo4))

allLengths - data.frame(phylobase.phylo@edge,
branch.length=phylobase.phylo@edge.length)

justTips - allLengths[allLengths$descendant =1  allLengths$descendant =
length(ape.phylo$tip.label),]

zeroTerminals - justTips[justTips$branch.length == 0, ]

phylobase.phylo@label[names(phylobase.phylo@label) %in%
zeroTerminals$descendant]

 If you wanted to output them in groups, you could do something like:

nodesOfInterest - unique(zeroTerminals$ancestor)

descendants(phylobase.phylo, nodesOfInterest, type=children)

 Cheers,
Eliot


On Wed, Jun 12, 2013 at 7:52 AM, Roey Angel an...@mpi-marburg.mpg.dewrote:

 Hi
 Is there a way to detect and list all tips of a tree with 0 length in
 their terminal branches (essentially duplicated sequences)?
 Would also be great if it's possible to output them in groups so that
 it's clear which tips are identical to which.

 Thanks
 Roey

 [[alternative HTML version deleted]]

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



[[alternative HTML version deleted]]

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


Re: [R-sig-phylo] Estimating ancestral states of a trait under selection

2013-04-20 Thread Eliot Miller
Hi Brian, Liam and Graham,

Thanks a lot for these three suggestions! I'm actually going to go ahead
and try all three approaches. Appreciate the help!

Cheers,
Eliot


On Fri, Apr 19, 2013 at 4:17 PM, Slater, Graham slat...@si.edu wrote:

 Hi Eliot and others,

 You can also use the code contained in the fitContinuousMCMC package
 available here -

 https://www.eeb.ucla.edu/gradstudents/slater/Graham/code.html
 And described in this paper -

 http://onlinelibrary.wiley.com/doi/10./j.1558-5646.2012.01723.x/abstrac
 t


 To place a variety of informative priors on nodes in your tree for a
 continuous trait and estimate ancestral states under a range of models of
 trait evolution. This code will be integrated into the forthcoming geiger
 2.0

 Cheers,

 Graham

 ---
 --
 Graham Slater
 Peter Buck Post-Doctoral Fellow
 Department of Paleobiology
 National Museum of Natural History
 The Smithsonian Institution [NHB, MRC 121]
 P.O. Box 37012
 Washington DC 20013-7012


 (202) 633-1316
 slat...@si.edu
 
 https://legacy.si.edu/owa/redir.aspx?C=HcyfurW5xkyXw2bWu-Td5xmRPtn7-c9I1lX
 iVWbeJqzfhgybLjvFBckclIN237FXoGKsGXlPAGg.URL=mailto%3aSlaterG%40si.edu
 www.eeb.ucla.edu/gslater
 
 https://legacy.si.edu/owa/redir.aspx?C=HcyfurW5xkyXw2bWu-Td5xmRPtn7-c9I1lX
 iVWbeJqzfhgybLjvFBckclIN237FXoGKsGXlPAGg.URL=http%3a%2f%2fwww.eeb.ucla.edu
 %2fgslater






 On 4/19/13 5:07 PM, Liam J. Revell liam.rev...@umb.edu wrote:

 If you want to do a Bayesian reconstruction for continuous traits with a
 strong prior on the root - as Brian suggests - you can do this in the
 phytools function anc.Bayes. The prior means  variances need to be
 provided in anc.Bayes(...,control=list(pr.var,pr.mean)). Unfortunately,
 you need to put priors on everything (or nothing, in which a pretty
 uninformative prior is used). If you decide this is what you want to do
  have difficulty figuring it out, please let me know.
 
 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://blog.phytools.org
 
 On 4/19/2013 4:56 PM, Brian O'Meara wrote:
  We have a method in R, TreEvo, that can allow you to do things like
 have a
  model where the optimum shifts through time according to some factor
 (like
  external data on climate) or where there are constraints that change
  through time: it's up on R-forge, and you can install the package, but
 it
  hasn't been published yet and so could have problems that won't appear
  until peers have looked at it more thoroughly. If you're fine waiting to
  publish with it until it's been vetted and is in press, feel free to
 play
  with it.
 
  Of course, another thing you could do is throw a prior on the root state
  based on your knowledge of the climate then and then do a Bayesian
  reconstruction. I don't know of any packages that do this at the moment,
  but it wouldn't be hard to write.
 
  Best,
  Brian
 
  ___
  Brian O'Meara
  Assistant Professor
  Dept. of Ecology  Evolutionary Biology
  U. of Tennessee, Knoxville
  http://www.brianomeara.info
 
  Students wanted: Applications due Dec. 15, annually
  Postdoc collaborators wanted: Check NIMBioS' website
  Calendar: http://www.brianomeara.info/calendars/omeara
 
 
  On Fri, Apr 19, 2013 at 4:00 PM, Eliot Miller eliotmil...@umsl.edu
 wrote:
 
  Hello all,
 
  I've read some past posts and tried to figure this one out myself. It
  appears that the short answer is if there are not some extinct
 lineages in
  the tree with known trait values, it's difficult to do.
 
  I have a data set of the current climatic niches of a continental
 radiation
  of taxa. If I reconstruct the ancestral state of the root using ace()
 with
  REML, I get a semi-believable answer, though obviously with wide CIs.
 My
  gut instinct is that the absolute value that is returned is slightly
 less
  than it should be.
 
  The issue is that I know the climate of the continent has changed
 radically
  (but at least consistently in one direction!) during the course of the
  radiation of the clade. An educated guess would put the magnitude of
 the
  change at 1200 to 550 mm rain per year over 60 million years. I'd guess
  that most lineages have felt this aridification as a slow and steady
  selective pressure to figure it out in increasingly dry conditions
  (there's probably also been a lot of extinction but let's skip that
 point
  for now).
 
  So, while I don't have extinct lineages with known trait values, I do
 have
  what I'd be comfortable modeling as a continuous selective pressure
  throughout the course of the radiation. I'm interested to see how doing
  this would change the actual absolute value returned by the ancestral
 state
  reconstruction. Any tips on how this might be best effected?
 
  Final note, my tree is from uncorrected molecular

[R-sig-phylo] Estimating ancestral states of a trait under selection

2013-04-19 Thread Eliot Miller
Hello all,

I've read some past posts and tried to figure this one out myself. It
appears that the short answer is if there are not some extinct lineages in
the tree with known trait values, it's difficult to do.

I have a data set of the current climatic niches of a continental radiation
of taxa. If I reconstruct the ancestral state of the root using ace() with
REML, I get a semi-believable answer, though obviously with wide CIs. My
gut instinct is that the absolute value that is returned is slightly less
than it should be.

The issue is that I know the climate of the continent has changed radically
(but at least consistently in one direction!) during the course of the
radiation of the clade. An educated guess would put the magnitude of the
change at 1200 to 550 mm rain per year over 60 million years. I'd guess
that most lineages have felt this aridification as a slow and steady
selective pressure to figure it out in increasingly dry conditions
(there's probably also been a lot of extinction but let's skip that point
for now).

So, while I don't have extinct lineages with known trait values, I do have
what I'd be comfortable modeling as a continuous selective pressure
throughout the course of the radiation. I'm interested to see how doing
this would change the actual absolute value returned by the ancestral state
reconstruction. Any tips on how this might be best effected?

Final note, my tree is from uncorrected molecular distances, so it's not
ultrametric. The analysis I'm trying to run here is tangential to my main
focus, so I'm ok with making the tree ultrametric with something like
chronopl() just out of curiosity to see what comes out. Someday I'll have a
time calibrated tree and then I can re-run this analysis.

Best wishes,
Eliot

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