[R-sig-phylo] error with bind.tree + ladderize

2020-10-22 Thread Joseph Brown
I came across the following error: when trying to ladderize a tree that had
gone through bind.tree, the tree becomes corrupted. Specifically, I added a
single tip to an internal node (code to replicate below).

Note:
1) this error did not seem to occur when attaching the tip sister to an
original tip (i.e., an external edge).
2) when the binded tree involved multiple tips attached to the same
internal position, the same edge/edge.length issues arise (see below), but
R crashes completely when trying to plot
3) if the tree is written out and read back in prior to ladderizing, no
problems occur

tl;dr: when ladderizing the binded tree, the edge matrix and edge.length
vectors are missing rows/elements corresponding to edges of tree "y" (the
second tree) in bind.tree. forcing a reordering seems to get around things,
but cladewise ordering alone fails.

Perhaps bind.tree needs to incorporate a reordering step?

HTH.
Joseph.

#
library(ape);
set.seed(31459);
t1 <- rtree(10);

# let's add a terminal with bind.tree
term <- rtree(1, tip.label="gnu_tip");
t2 <- bind.tree(x=t1, y=term, where=12, position=0.5);

# plot
plot(t2); axisPhylo();

# looks correct. but let's ladderize to make things pretty
plot(ladderize(t2)); axisPhylo();
# Warning message:
# In yy[TIPS] <- 1:Ntip :
# number of items to replace is not a multiple of replacement length

# huh? looks like the edge matrix is incorrect
dim(t2$edge);
# [1] 20  2
dim(ladderize(t2)$edge);
# [1] 19  2
# the new terminal is missing from the edge matrix
# same with the edge.length vector:
length(t2$edge.length)
# [1] 20
length(ladderize(t2)$edge.length)
# [1] 19
# but tip.label vector is ok:
length(t2$tip.label) == length(ladderize(t2)$tip.label)
# [1] TRUE

# so: we do not have enough edges for the number of terminals

# can we fix it by reordering?
plot(ladderize(reorder(t2, "cladewise")));
# nope: same error. note that attributes(t2)$order was already "cladewise"
# i'm guessing the reorder command is ignored because of its current status?

# try a different ordering to force processing
plot(ladderize(reorder(t2, "pruningwise")));
# success

# what if we want "cladewise" ordering for downstream analyses?
# maybe we can pass it through reorder.phylo twice?
plot(ladderize(reorder(reorder(t2, "pruningwise"), "cladewise")));
# yup!

[[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 date consensus phylogeny

2019-01-23 Thread Joseph Brown
 I typically use a non-R tool like treeannotator (from the BEAST package)
to do this type of thing, especially when involving large numbers of big
trees.

HTH.
Joseph.

On Wed, Jan 23, 2019 at 4:42 PM Alina van dijk  wrote:

> Hi everyone,
>
> My name is Alina, I'm attending master degree in ecology and I have a
> little problem with my consensus phylogeny. I used 1000 phylogeny of
> birdtree to construct the consensus tree but now I need to insert the dates
> in this consensus tree.
>
> To accomplish this idea, I tried different methods:
> consensustree<-averageTree
> (tree,method="symmetric.difference") but the result is a consensus tree in
> topology, binary and rooted but not ultrametric. For this problem I used
> consensus_tree_ultrametric
> <-compute.brlen(consensustree,method="Grafen",power=1), but the edge
> lengths was altered.
>
> So, I used another method to make a consensus tree using phytools
> consensustree_another_method <- consensus.edges(multiphylo,method =
> "mean.edge") as a result, a ultrametric tree, rooted with consensus edges
> lengths, but have polytomies :(
>
> I also tried using phylobase , proposed by Brian O'Meara in this link:
>
> https://grokbase.com/t/r/r-sig-phylo/12bn9x5gv4/why-no-branch-lengths-on-consensus-trees
> ,
>  but as a result, my consensus tree wasn´t ultrametric and the
> transformation also altered the edge lengths.
>
> I only need to insert the dates based on the trees dated by Jetz in this
> consensus tree and as result, an ultrametric tree, with consensus edges
> lengths and no polytomy.
>
> Does anyone know how to solve that problem?
>
> Thanks in advance,
> Best Regards,
>
> Alina
>
> [[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] AGY coding

2018-08-24 Thread Joseph Brown
Hi Karla.

Not sure how you have your sequences stored, but if as a string you can do
it yourself:

str <- gsub("C|T", "Y", str);

As for RY vs. AGY, this paper

is very nice. Basically, if you are using them for phylogenetic inference
it may be that recoding destroys the Markovian property of the alignment,
and that may mislead you downstream. A very interesting consideration that
I feel is not widely known.

HTH.
JWB


On Fri, Aug 24, 2018 at 3:36 PM, Karla Shikev  wrote:

> Dear all,
>
> Does anyone have a function for AGY coding of nucleotides?
>
> By the way, any thoughts on using RY- vs AGY-coding?
>
> 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-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/