veg / hyphy-analyses

HyPhy standalone analyses
MIT License
37 stars 17 forks source link

Fit94MG: Failed to dereference <seq> with --type local #12

Closed gwct closed 3 years ago

gwct commented 3 years ago

Hello, I am trying to estimate branch specific dN, dS, and dN/dS to compare distributions of rates among genes between certain partitions of chromosomes (i.e. do genes on chromosome A generally have lower or higher dS than genes on chromosome B? dN? dN/dS?).

I am running the following command:

hyphy hyphy-analyses/FitMG94/FitMG94.bf --alignment <alignment file>.fa --tree <unrooted newick tree file>.tre --type local --output test.json --save-fit test.txt

HyPhy was downloaded from bioconda earlier today:

hyphy --version
HYPHY 2.5.22(MP) for Linux on x86_64

And the hyphy-analyses repo was cloned today as well.

The command finishes successfully without the --type local option, however I don't think that is the analysis I want to run. Using the --type local option results in the following error from errors.log:

Error:Failed to dereference 'cgri.{
 "empirical":9,
 "global":{
   "Substitution rate from nucleotide A to nucleotide C":"HHcvUBmy.model_MGREV.theta_AC",
   "Substitution rate from nucleotide A to nucleotide G":"HHcvUBmy.model_MGREV.theta_AG",
   "Substitution rate from nucleotide A to nucleotide T":"HHcvUBmy.model_MGREV.theta_AT",
   "Substitution rate from nucleotide C to nucleotide G":"HHcvUBmy.model_MGREV.theta_CG",
   "Substitution rate from nucleotide C to nucleotide T":"HHcvUBmy.model_MGREV.theta_CT",
   "Substitution rate from nucleotide G to nucleotide T":"HHcvUBmy.model_MGREV.theta_GT"
  },
 "local":{
   "non-synonymous rate":"beta",
   "synonymous rate":"alpha"
  }
}.null'
Failed to dereference 'cgri.{
 "empirical":9,
 "global":{
   "Substitution rate from nucleotide A to nucleotide C":"HHcvUBmy.model_MGREV.theta_AC",
   "Substitution rate from nucleotide A to nucleotide G":"HHcvUBmy.model_MGREV.theta_AG",
   "Substitution rate from nucleotide A to nucleotide T":"HHcvUBmy.model_MGREV.theta_AT",
   "Substitution rate from nucleotide C to nucleotide G":"HHcvUBmy.model_MGREV.theta_CG",
   "Substitution rate from nucleotide C to nucleotide T":"HHcvUBmy.model_MGREV.theta_CT",
   "Substitution rate from nucleotide G to nucleotide T":"HHcvUBmy.model_MGREV.theta_GT"
  },
 "local":{
   "non-synonymous rate":"beta",
   "synonymous rate":"alpha"
  }
}.null'

cgri is one of the species labels from the alignment and the tree. Do you have any ideas what could be causing this error? Apologies if this is something super basic -- just getting started with HyPhy.

Thanks for your help! -Gregg

spond commented 3 years ago

Dear @gwct,

Thanks for reporting this issue. Let me see if I can replicate it and suggest a fix. We have been actively working on improving HyPhy core performance and analysis libraries -- sometimes this causes errors to crop up in analyses that used to work before.

Best, Sergei

spond commented 3 years ago

Dear @gwct,

Issue fixed (library functions changed, had to update FitMG94.bf) via 2eed635. Please pull the update and try again.

Best, Sergei

gwct commented 3 years ago

Awesome, it is working now. Thank you!

As a quick follow up, when using this local model I don't see where the branch specific omega estimates are reported. From the json file for a branch in my tree:

     "psun":{
       "Confidence Intervals":{
         "LB":0.003747960154497382,
         "MLE":0.06567634942936271,
         "UB":0.2897848280602529
        },
       "Nucleotide GTR":0.00710406000702358,
       "Standard MG94":0.007294182652111244,
       "nonsynonymous":0.001164054450446855,
       "original name":"psun",
       "synonymous":0.006130128201664391
      }

Are one of these the dN/dS estimate or is it appropriate to simply divide the nonsynonymous and synonymous estimates? If there is a resource that explains this output please feel free to send the link.

Thanks! -Gregg

spond commented 3 years ago

Dear @gwct,

It's the MLE in

"Confidence Intervals":{
         "LB":0.003747960154497382,
         "MLE":0.06567634942936271,
         "UB":0.2897848280602529
        }

LB and UB are "approximate" profile likelihood confidence interval bounds on the estimate.

Best, Sergei

gwct commented 3 years ago

Got it. Thank you!

gwct commented 3 years ago

Hello again, Sorry to re-open this but I've hit another error with this same analysis after not running the FitMG94 model for a couple of months:

hyphy hyphy-analyses/FitMG94/FitMG94.bf --alignment <alignment file>.fa --tree <unrooted newick tree file>.tre --type local --output test.json --save-fit test.txt

Now results in:

### Fitting Standard MG94
* Log(L) = -2068.99, AIC-c =  4211.05 (36 estimated parameters)
Error:
User-defined function 'profile_ci' needs 4 parameters, but 3 were supplied .

Function call stack
1 :  [namespace = ELcybJBd] result[_branch_name]=Call(callback,tree_name,_branch_name,(model_descriptions[map[_branch_name]])[utility.getGlobalValue("terms.parameters")]);

-------
2 :  estimators.TraverseLocalParameters(fitter.results[terms.likelihood_function],fitter.results[utility.getGlobalValue("terms.model")],"profile_ci");
-------

Check errors.log for execution error details.

Check messages.log for diagnostic messages.

Without using --type local I get a different error:

### Fitting Standard MG94
* Log(L) = -2074.78, AIC-c =  4202.13 (26 estimated parameters)
Error:
Parsing error (Parameter list is out of context  in the following context: 'fitter.n,<ERROR HERE>fitter.b') while compiling the statement: fitter.n,fitter.b

Function call stack
1 :  fitter.n,fitter.b;

-------

Check errors.log for execution error details.

Check messages.log for diagnostic messages.

errors.log only has the same text about the errors.

I pulled the latest hyphy-analyses updates just now and updated hyphy through conda as well and still get the same error.

hyphy --version HYPHY 2.5.2(MP) for Linux on x86_64

Please let me know if you need any more info. Thanks! -Gregg

spond commented 3 years ago

Dear @gwct,

The current version of HyPhy is 2.5.28 (Conda has 2.5.26 https://anaconda.org/bioconda/hyphy). Version 2.5.2 has outdated library modules no longer compatible with hyphy-analyses. I failed to update version requirements for FitMG94.bf, so you were not warned about this.

Can you confirm that a more recent version of HyPhy works?

Best, Sergei

gwct commented 3 years ago

Ok that makes sense. Not sure why the conda update didn't take, but a fresh install did the trick. --version shows 2.2.25 now (though the bioconda site says 2.2.26) and the analysis runs.

hyphy --version
HYPHY 2.5.25(MP) for Linux on x86_64

Thanks!

AnaValero commented 2 years ago

Dear @spond,

I'm having the same issue when running --type local. My hyphy version is: HYPHY 2.5.8(MP) for Linux on x86_64 (Although anaconda says 2.5.39). It is fresh intalled today, as Fit94MG94.bf

command: hyphy -i ~/Escritorio/programas/hyphy/FitMG94.bf --alignment spike_NT_align.fasta --tree spike_NT_align.nwk --type local --save-fit Adeno_fit.txt --output spike_FitMG94.json

Error: User-defined function 'profile_ci' needs 4 parameters, but 3 were supplied

When running --type global everythins seems normal. Is there anything we can configure in FitMG94.bf to synchronyze with hyphy version?

Thanks! Ana