Re: [R-sig-phylo] Error in phytools - locate.fossil?

2023-01-11 Thread Lindsey Dehaan
Great! Thanks for all the help!

Lindsey

On Wed, Jan 11, 2023 at 9:33 AM Liam J. Revell  wrote:

> Dear Lindsey.
>
> You should not adjust tol at all -- use the default. Sorry I wasn't clear
> on that. It is just an (arbitrarily) small value that helps us avoid
> evaluating solutions that are not "legal." (E.g., in your case, trying to
> attach a tip to an edge *below* its parent node.)
>
> All the best, Liam
> Liam J. Revell
> Professor of Biology, University of Massachusetts Boston
> Web: http://faculty.umb.edu/liam.revell/
>
>
> On 1/11/2023 7:58 AM, Lindsey Dehaan wrote:
>
> CAUTION: EXTERNAL SENDER
> Hey Liam,
>
> Thanks alot! I really appreciate it! I installed the new version and I saw
> your edits to the locate.fossil function on github.
>
> I just have one more question, I am new to the tol argument and I am not
> sure what the default should be set to. I've set it to a couple numbers
> (ex, 0.5, 0.1 0.01) and my fossil now places correctly but could you
> possibly tell me what this argument means and what I should be setting it
> to?
>
> Best,
> Lindsey
>
> On Tue, Jan 10, 2023 at 6:07 PM Liam J. Revell 
> wrote:
>
>> 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 tol with 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 
>> 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/
>>> 
>>>
>>>
>>> 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) :   

Re: [R-sig-phylo] Error in phytools - locate.fossil?

2023-01-11 Thread Liam J. Revell
Dear Lindsey.

You should not adjust tol at all -- use the default. Sorry I wasn't 
clear on that. It is just an (arbitrarily) small value that helps us 
avoid evaluating solutions that are not "legal." (E.g., in your case, 
trying to attach a tip to an edge /below/ its parent node.)

All the best, Liam

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


On 1/11/2023 7:58 AM, Lindsey Dehaan wrote:
> CAUTION: EXTERNAL SENDER
> Hey Liam,
>
> Thanks alot! I really appreciate it! I installed the new version and I 
> saw your edits to the locate.fossil function on github.
>
> I just have one more question, I am new to the tol argument and I am 
> not sure what the default should be set to. I've set it to a couple 
> numbers (ex, 0.5, 0.1 0.01) and my fossil now places correctly but 
> could you possibly tell me what this argument means and what I should 
> be setting it to?
>
> Best,
> Lindsey
>
> On Tue, Jan 10, 2023 at 6:07 PM Liam J. Revell  
> wrote:
>
> 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
>>  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/
>> 
>> 
>>
>>
>> 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
>>> 

Re: [R-sig-phylo] Error in phytools - locate.fossil?

2023-01-11 Thread Lindsey Dehaan
Hey Liam,

Thanks alot! I really appreciate it! I installed the new version and I saw
your edits to the locate.fossil function on github.

I just have one more question, I am new to the tol argument and I am not
sure what the default should be set to. I've set it to a couple numbers
(ex, 0.5, 0.1 0.01) and my fossil now places correctly but could you
possibly tell me what this argument means and what I should be setting it
to?

Best,
Lindsey

On Tue, Jan 10, 2023 at 6:07 PM Liam J. Revell  wrote:

> 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 tol with 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 
> 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/
>> 
>>
>>
>> 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