veg / hyphy

HyPhy: Hypothesis testing using Phylogenies
http://www.hyphy.org
Other
201 stars 68 forks source link

RELAX Internal Error: Likelihood function evaluation & ComputeTreeBlockByBranch #1614

Closed philsteinberg closed 11 months ago

philsteinberg commented 1 year ago

Hello,

I have been running the hyphy RELAX tool (using a Snakemake file) for several codon alignments. For most fasta files the command executes successfully. However, some – examples depicted below – fail to create the *RELAX.json output.

Tree file used: species_TimeTree_renamed_3.nwk

((rn5:11.64917000,mm10{Foreground}:11.64917000)'14':75.55083000,hg19:87.20000000);

Example 1

Fasta file ENSMUST00000141446.7_1_5_NT_CLEAN.fa:

>mm10
ATGGAGGAAGAGGCTGAGAAGCTAAAGGAGCTACAAAACGAGGTAGAGAAGCAGATGAATATGAGTCCACCCCCAGGCAAT--G
>rn5
ATGGAGGAAGAGGCTGAGAAGCTAAAGGAGCTACAAAACGAGGTAGAGAAACAGATGAATATGAGTCCACCCCCAGGCAAT--G
>hg19
ATGGAGGAAGAAGCTGAGAAGCTAAAGGAGCTACAGAACGAGGTAGAGAAGCAGATGAATATGAGTCCACCTCCAGGCAAT--G

(not all sequences that fail with this error have gaps)

Command:

hyphy LIBPATH=/<user_path>/opt/anaconda3/envs/runhyphy/share/hyphy relax \
--alignment/<user_path>/ENSMUST00000141446.7_1_5_NT_CLEAN.fa \
--tree /<user_path>/species_TimeTree_renamed_3.nwk --test Foreground \
--output /<user_path>/snakemake_files/output/data/ENSMUST00000141446.7_1_5_RELAX.json

Error message:

(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
Removing output files of failed job relax since they might be corrupted:
/Users/philippasteinberg/Desktop/Research/SudmantLab/mouse_alignment/snakemake_files/output/data/ENSMUST00000141446.7_1_5_RELAX.json
Error:
Internal error 
Likelihood function evaluation encountered a NaN at calculation #8017 (probably due to a parameterization error or a bug).
Function call stack
1 :  [namespace = XaxzvQL_] Optimize(mles, ^lf_id);
-------

2 :  relax.general_descriptive.fit=estimators.FitExistingLF(relax.general_descriptive.fit[terms.likelihood_function],relax.model_object_map);
-------

# errors.log
Error:Internal error 
Likelihood function evaluation encountered a NaN at calculation #8017 (probably due to a parameterization error or a bug).
Internal error 
Likelihood function evaluation encountered a NaN at calculation #8017 (probably due to a parameterization error or a bug).r and indicates some serious COVFEFE taking place.ter.sites*3==relax.codon_data.sites, error_msg);

Example 2

Fasta file ENSMUST00000214179.1_1_5_NT_CLEAN.fa:

>mm10
ATGAGCCAAGGAGACTCGAACCCAGCAGCTATTCCACATGCCGCAGAAGATATTCAAGGAGATGACAGGTGGATGTCTCAG
>rn5
ATGAGCCAAGGAGACTCAAACCCAGCAGCTATTCCACATGCAGCAGAAGATATTCAAGGAGATGACAGGTGGATGTCTCAG
>hg19
ATGAGCCAAGGAGACTCAAACCCAGCAGCTATTCCGCATGCAGCAGAAGATATTCAAGGAGATGACCGATGGATGTCTCAG

Command:

hyphy LIBPATH=/<user_path>/opt/anaconda3/envs/runhyphy/share/hyphy relax \
--alignment /<user_path>/ENSMUST00000214179.1_1_5_NT_CLEAN.fa \
--tree /<user_path>/species_TimeTree_renamed_3.nwk --test Foreground \
--output /<user_path>/snamemake_files/output/data/ENSMUST00000214179.1_1_5_RELAX.json

Error message:

(one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)
Removing output files of failed job relax since they might be corrupted:
/<user_path>/snakemake_files/output/data/ENSMUST00000214179.1_1_5_RELAX.json
Error:
Internal error 
Site 1 evaluated to a NaN probability in ComputeTreeBlockByBranch; this is not a recoverable error and indicates some serious COVFEFE taking place.
Function call stack
1 :  [namespace = chyyodGA] Optimize(mles, likelihoodFunction);
-------
2 :  relax.general_descriptive.fit=estimators.FitLF(relax.filter_names,relax.trees,{"0":{"DEFAULT":"relax.ge"}},relax.grid_search.results,relax.model_object_map,{terms.run_options.apply_user_constraints:"relax.init.k",terms.run_options.retain_lf_object:TRUE,terms.run_options.optimization_log:relax.optimization_log_file(".GE-2-log.json")});

### errors.log file ###
Error:Internal error 
Site 1 evaluated to a NaN probability in ComputeTreeBlockByBranch; this is not a recoverable error and indicates some serious COVFEFE taking place.
Internal error 
Site 1 evaluated to a NaN probability in ComputeTreeBlockByBranch; this is not a recoverable error and indicates some serious COVFEFE taking place.ter.sites*3==relax.codon_data.sites, error_msg);

Is this an error in how I am running RELAX in my Snakemake pipeline, an error with the sample fasta, or an error with the RELAX command/tool?

Thank you!!

spond commented 1 year ago

Dear @philsteinberg,

Thanks for such a great bug report. I am able to replicate the errors; will look into it and report back. It's definitely a bug on our end, because some of the runs terminate with a seg-fault.

Best, Sergei

spond commented 1 year ago

Dear @philsteinberg,

I have identified the issue and will release a fix in the next version. Basically, for these examples, there was strong numerical instability (short sequences, ω values running off to infinity). I'll release a patch in the next minor version update.

Thanks for bringing this to my attention.

Best, Sergei

philsteinberg commented 1 year ago

Thank you so much @spond !

github-actions[bot] commented 11 months ago

Stale issue message