Dear Lindsey.

Thanks for sharing the code & data. It made the problem pretty easy to 
resolve.

Turns out it is a simple numerical precision issue.

I have resolved it by adding an optional argument tolwith a sensible 
default value which most users can probably ignore (but can set to tol=0 
if they want to guarantee the current behavior of locate.fossil). I 
pushed this update to /GitHub/: 
https://github.com/liamrevell/phytools/commit/f1dcddbf56a7ae6bf9bece223cd6a949a57eac5f.

To obtain this updated version of /phytools/ I recommend installing the 
package /remotes/ and then running (from a fresh R session):

remotes::install_github("liamrevell/phytools")

Let us know if this fixes everything!

All the best, Liam

Liam J. Revell
Professor of Biology, University of Massachusetts Boston
Web: http://faculty.umb.edu/liam.revell/


On 1/10/2023 4:42 PM, Lindsey Dehaan wrote:
> CAUTION: EXTERNAL SENDER
> Hey Liam,
>
> Thanks for the fast response.
>
> Attached is a simple script with the fossil I am having problems with. 
> All the files should be attached. Let me know if I missed a file or 
> you need anything else.
>
> I greatly appreciate your help on this. I have been stuck on this for 
> a while now.
>
> Best,
> Lindsey
>
>
> On Tue, Jan 10, 2023 at 4:23 PM Liam J. Revell <liam.rev...@umb.edu> 
> wrote:
>
>     Dear Lindsey.
>
>     Thanks for posting your code, but would you mind sending me (it
>     can be off-list) an example in which I can also pull your data &
>     tree and re-run it with the real data that is generating the
>     error? This might be helpful in getting to the bottom of your
>     issue. Thanks!
>
>     All the best, Liam
>
>     Liam J. Revell
>     Professor of Biology, University of Massachusetts Boston
>     Web: http://faculty.umb.edu/liam.revell/
>     
> <https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Ffaculty.umb.edu%2Fliam.revell%2F&data=05%7C01%7Cliam.revell%40umb.edu%7C9a241369fe2542ce1c0408daf3538a5b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089837406791068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Wb5zlO%2B26s185WebtNT7rh0o1w1yy0KAJg%2BzTBsycNQ%3D&reserved=0>
>
>
>     On 1/10/2023 4:20 PM, Lindsey Dehaan wrote:
>>     CAUTION: EXTERNAL SENDER
>>
>>     Hi all,
>>
>>     I have a question regarding the phytools function locate.fossil().
>>
>>     I have had a lot of success with this function but there are two fossils 
>> of
>>     mine that the function does not like. I give the function my phylogeny, a
>>     max and min age for the fossil, and the edge for the fossil to be placed
>>     on. So I basically just want the function to estimate the branch length
>>     subtending the fossil and the position of where the node subtending the
>>     fossil attaches in the phylogeny.
>>
>>     For two of my fossils I get the following error.
>>
>>
>>
>>     *Error in bind.tree(tree, tip, where = where, position = pp) :   
>> 'position'
>>     is larger than the branch length*
>>
>>     The function does not seem to like my edge constraint with these two
>>     fossils. When I remove my edge constraint it works and the fossil is 
>> placed
>>     in the correct time interval but just on a different edge estimated using
>>     ML. For one of my fossils, the edge I place my fossil on ranges from 42 
>> mya
>>     to 4 mya and the age range for the fossil is between 33 and 28 mya. I am
>>     confused why the function does not like the edge constraints I am giving
>>     it. The error that I receive makes me believe that the position the
>>     function is estimating for my fossil may be older than the edge 
>> constraint
>>     I am giving it or I could just be missing something, most likely the
>>     latter...
>>
>>     Below is my code. This code works for almost all my fossils except for 
>> two
>>     of them.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>     *fossil_to_add<-fossil_trait_data[13,] 
>> locate_fossil_data<-rbind(extant_data,
>>     fossil_to_add) # used this data in
>>     
>> locate.fossil()extant_sister_clade<-rownames(extant_data)[c(grep(fossil_info[13,7],
>>     rownames(extant_data)), grep(fossil_info[13,8],
>>     rownames(extant_data)))]mrca<-getMRCA(tree,
>>     extant_sister_clade)edge<-mrcamin_time<- depth - fossil_info[13,4] # 
>> depth
>>     is the root age of the phylogeny max_time<-depth - fossil_info[13,3] # 
>> the
>>     max and min ages are positive numbers time_constraints<-c(max_time,
>>     min_time)locate_fossil_tree<-locate.fossil(tree, locate_fossil_data,
>>     time.constraint=time_constraints,edge.constraint=edge, plot=TRUE)*
>>
>>     Any help or advice, would be greatly appreciated!
>>
>>     Best,
>>     Lindsey
>>     --
>>     Lindsey DeHaan
>>     Ph.D. Candidate
>>     Department of Earth and Environmental Sciences
>>     University of Michigan
>>
>>              [[alternative HTML version deleted]]
>>
>>     _______________________________________________
>>     R-sig-phylo mailing list -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=05%7C01%7Cliam.revell%40umb.edu%7C27cb8a8eb3dc4651433008daf35090b6%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089824617167715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=tYwyCJW%2BdLBEpy4Tn290%2BXqmQNkV6%2FdGGsJmgnBXUcU%3D&reserved=0
>>   
>> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-phylo&data=05%7C01%7Cliam.revell%40umb.edu%7C9a241369fe2542ce1c0408daf3538a5b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089837406791068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=OQZ4%2BfVRV4djYAuL2ykJRNHnZybQt6b827hgLycCu%2BQ%3D&reserved=0>
>>     Searchable archive 
>> athttps://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.mail-archive.com%2Fr-sig-phylo%40r-project.org%2F&data=05%7C01%7Cliam.revell%40umb.edu%7C27cb8a8eb3dc4651433008daf35090b6%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089824617167715%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=AGbpdEbfZDhgeTNHnQsgzRkj2%2FngM5Ud%2FCDVEFDCvnw%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=05%7C01%7Cliam.revell%40umb.edu%7C9a241369fe2542ce1c0408daf3538a5b%7Cb97188711ee94425953c1ace1373eb38%7C0%7C0%7C638089837406791068%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gJDnbSmyuBEJy5cohhnDHP62kyrbpM1Yag6GjzzrPn4%3D&reserved=0>
>
>
>
> -- 
> Lindsey DeHaan
> Ph.D. Candidate
> Department of Earth and Environmental Sciences
> University of Michigan
        [[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/

Reply via email to