Hi Elvira.
In your Newick string those NaN are branch lengths, not taxon labels.
What do you mean by 'delete' the NaNs? You can set them to zero, as follows:
tree$edge.length[is.na(tree$edge.length)]<-0
but then you get a tree that looks like this:
http://www.phytools.org/blog/Elvira-tree.png
so it's kind of hard to tell which taxa are extinct....
Sorry I can't be of more help! All the best, Liam
Liam J. Revell
University of Massachusetts Boston
Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org
Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile
On 8/25/2020 9:00 PM, Elvira D`bastiani wrote:
**[EXTERNAL SENDER]
Hi Liam
Also thank you for your informative answer. However, I don't want to
simulate trees. For example one of my trees looks like this:
(2:17, (3: 258, (4: 1, (5: 1, ((7:47, (8:13, ((11: 1, (13: 46,9: 60):
35): 35): 26, (10: 3, (12: 7, ((15: 4,14: 17): NaN, 6: NaN): - 904):
53): 0): 34): 31): NaN, 1: NaN): - 621): 1): 138): 53);
Here, I need to delete these NaN from the phylo file.
I believe that with these functions I am unable to delete these NaN or
extract only the surviving species.
Thank you for the help.
Elvira.
Em ter., 25 de ago. de 2020 às 17:33, Liam J. Revell
<liam.rev...@umb.edu <mailto:liam.rev...@umb.edu>> escreveu:
Dear Elvira.
I'm not sure what's going on with the NaN values, but one issue that I
see with your example is that ape::drop.fossil identifies fossil
lineages by finding those that end before the present. Since rtree just
splits the tree randomly & samples the edge lengths from a uniform
distribution, this will leave you with only one lineage!
To see how the function should work you could try something like:
set.seed(99)
tree<-pbtree(n=15,b=1,d=0.2)
plotTree(tree)
plotTree(pruned<-drop.fossil(tree))
Hopefully this leaves things a bit clearer.
For fun, also try:
par(mfrow=c(1,1),mar=c(5.1,4.1,2.1,2.1),bty="n")
ltt(tree,lty="dashed",log.lineages=FALSE,log="y")
ltt(pruned,lty="solid",add=TRUE,log.lineages=FALSE,
log="y")
legend("topleft",c("observed","reconstructed"),
lty=c("dashed","solid"),bty="n")
All the best, Liam
Liam J. Revell
University of Massachusetts Boston
Universidad Católica de la Ssma Concepción
web: http://faculty.umb.edu/liam.revell/, http://www.phytools.org
<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.phytools.org%2F&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615417539&sdata=5%2F1PtYD6DMW7gK7ef3QiRvXSeI0bozADU5lgrW9qPq0%3D&reserved=0>
Academic Director UMass Boston Chile Abroad:
https://www.umb.edu/academics/caps/international/biology_chile
On 8/25/2020 4:21 PM, Elvira D`bastiani wrote:
> [EXTERNAL SENDER]
>
> Hi,
>
> I'm a beginner with phylogeny analysis. I'm having trouble
extracting only
> the surviving species from the phylogenies of my model.
>
> I used the drop.fossil (fPar) functions from ape and the drop.extinct
> (fPar) from geiger. But it is not deleting the way I need it.
>
> Running example correctly:
> my.tree = rtree (15, rooted = TRUE, tip.label = NULL, br = runif)
#random
> tree in phylo format
> class (my.tree)
> my.tree $ edge.length #I need this information without NaN.
>
>> my.tree$edge.length [1] 0.53879430 0.71471795 0.40579050
0.15278814 0.34023276 0.62665485
> [7] 0.05737268 0.85166764 0.21264535 0.53946203 0.13648759
0.32486514
> [13] 0.62107629 0.25598225 0.63487580 0.48567211 0.93817692
0.85750154
> [19] 0.37088354 0.31420183 0.82853436 0.45184151 0.31587841
0.09780854
> [25] 0.06490054 0.68945737 0.66805060 0.90454665
>
>
> However in the same tree format (phylo format) in my analysis the
> edge.length comes out with NaN. Even after using the drop.fossil
(fPar) or
> drop.extinct (fPar) functions. It looks like this:
>
>> fPar$edge.length [1] 17 53 258 138 1 1 1 -621
NaN 47 31 13 34 26
> [15] 1 35 46 60 0 3 53 7 -904 NaN 4 17
NaN NaN
>
>
> Is there any way to delete these NaN?
>
>
> Thanks in advance for the answer
>
> Best wishes
>
> e.
>
> --
>
> *Elvira D'Bastiani*Doutoranda em Ecologia e Conservação
> Laboratório de Interações Biológicas
> Universidade Federal do Paraná (UFPR), Curitiba, Paraná, Brasil
>
*https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevo&data=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977&sdata=u5GV45faTYzUsRhhQpCQc9C5%2BSLDcrzE6mcyNlRNVUU%3D&reserved=0
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevo&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615427534&sdata=sbljMhPeAIouSR2%2BKxEcRLpN34jrH99wtt5eOu3jLzY%3D&reserved=0>
>
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevo&data=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977&sdata=u5GV45faTYzUsRhhQpCQc9C5%2BSLDcrzE6mcyNlRNVUU%3D&reserved=0
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevo&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615427534&sdata=sbljMhPeAIouSR2%2BKxEcRLpN34jrH99wtt5eOu3jLzY%3D&reserved=0>>*
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-phylo mailing list - R-sig-phylo@r-project.org
<mailto:R-sig-phylo@r-project.org>
>
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo&data=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977&sdata=IdKD9kLK5Xh3yt1BDkA8n1srFFr5paq%2BSJAfivocP%2B4%3D&reserved=0
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615437526&sdata=5cHozKE2yAxgIAicWfbSuoCPOTUDUJxnxzk62d2vDHo%3D&reserved=0>
> Searchable archive at
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F&data=02%7C01%7Cliam.revell%40umb.edu%7C40eeed8a082f4da7db1008d8493475c7%7Cb97188711ee94425953c1ace1373eb38%7C0%7C1%7C637339836973837977&sdata=5poPu09PsiPLuPYLC4itm9ouYfTXHC7ZNapkveNlkBU%3D&reserved=0
<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615457511&sdata=GWxl8BY1kA5Ub5wVDkvaZ1FqxZ7CWEnWpS5JHb4XcZQ%3D&reserved=0>
>
--
*Elvira D'Bastiani
*Doutoranda em Ecologia e Conservação
Laboratório de Interações Biológicas
Universidade Federal do Paraná (UFPR), Curitiba, Paraná, Brasil
_https://elviradbastiani.wixsite.com/ecoevo
<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Felviradbastiani.wixsite.com%2Fecoevo&data=02%7C01%7Cliam.revell%40umb.edu%7Ce8848bf509ed41e5115408d8495b7db0%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C637340004615467512&sdata=BB8HoI1MISexdx94U14vY3K3ix8Tf6SA%2BZ9EZU0%2FLTM%3D&reserved=0>_
_______________________________________________
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/