Matlab sometimes hangs while running optimizeCBmodel after knocking out genes with deletemodelgenes

84 views
Skip to first unread message

Herbert Huttanus

unread,
Aug 26, 2019, 9:38:50 AM8/26/19
to COBRA Toolbox

I am generating a script that tests many different gene knockout scenarios for a model. Every time I add a new gene to the list of knockouts, I check for lethality of the knockout by executing deletemodelgenes with my updated list of knockouts followed by optimizeCBmodel. If the result has zero biomass flux, I consider the knockout to be lethal, I discard it and move to the next. Many gene knockouts are successfully identified as lethal using this method with no problem.


One run of my script performs this test hundreds of times, but one out of a thousand deletions (or about one in five times I run the script) causes matlab to hang during the optimizeCBmodel step. The hang is repeatable for a given model and a given set of upper and lower flux bounds. When Matlab hangs in this way, not even ctrl+c will abort the script and I need to force Matlab to close. I am using the GLPK solver in Matlab r2017b. I am uncertain of the COBRA version but I have attached a configReport.


I ultimately want to make this script available to the public, and having it fail completely and freeze up matlab in one out of five scenarios does not make for a very attractive script.


I wish to know how to prevent such hangs entirely, or at least, anticipate which knockout models might freeze up matlab in this way and skip past such knockout scenarios. I have also heard it suggested that adding a timer to the optimizeCBmodel could be used to abort cases in which it takes too long, but others have suggested that this will not work, because once Matlab calls the GLPK solver, it becomes unresponsive to Matlab commands that might cancel the process until after GLPK is finished.

Thank you in advance for any insight you might provide.
COBRAconfigReport.log

Diana El Assal

unread,
Aug 26, 2019, 10:18:30 AM8/26/19
to cobra-...@googlegroups.com
Hi Herbert, 

Have you tried using singleGeneDeletion? 

--

---
You received this message because you are subscribed to the Google Groups "COBRA Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbox+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/1eaac366-7ce3-493a-8732-9793ac583023%40googlegroups.com.


--

                                                                                                

Diana Charles Jordan-El Assal, PhD

Laboratory of Algal, Synthetic, and Systems Biology
Post-Doctoral Associate
Division of Science and Math

Center for Genomics and Systems Biology
New York University Abu Dhabi
P.O. Box 129188, Abu Dhabi, UAE
Email:dc...@nyu.edu 
                                                                             
(This message is confidential and may contain privileged information. It is intended for the named recipient only. If you receive it in error please notify me and permanently delete the original message and any copies.)

Herbert Huttanus

unread,
Aug 26, 2019, 10:54:52 AM8/26/19
to COBRA Toolbox
I have in earlier versions of the script, but it became clear that I need to be able to combine multiple knockouts simultaneously to effect the desired phenotype. Currently, I keep a cumulative list of genes whose knockout is beneficial and add to it as the code identifies more gene candidates. I then check if the gene in question, combined with the other knockouts is lethal so that I don't miss synthetic lethal combinations.

Is it possible to perform singleGeneDeletion multiple times sequentially to effectively knock out multiple genes. Jan Schellenberger's comments in "deleteModelGenes.m" suggested it was more appropriate to knock them all out simultaneously. 


On Monday, August 26, 2019 at 10:18:30 AM UTC-4, Diana El Assal wrote:
Hi Herbert, 

Have you tried using singleGeneDeletion? 

I am generating a script that tests many different gene knockout scenarios for a model. Every time I add a new gene to the list of knockouts, I check for lethality of the knockout by executing deletemodelgenes with my updated list of knockouts followed by optimizeCBmodel. If the result has zero biomass flux, I consider the knockout to be lethal, I discard it and move to the next. Many gene knockouts are successfully identified as lethal using this method with no problem.


One run of my script performs this test hundreds of times, but one out of a thousand deletions (or about one in five times I run the script) causes matlab to hang during the optimizeCBmodel step. The hang is repeatable for a given model and a given set of upper and lower flux bounds. When Matlab hangs in this way, not even ctrl+c will abort the script and I need to force Matlab to close. I am using the GLPK solver in Matlab r2017b. I am uncertain of the COBRA version but I have attached a configReport.


I ultimately want to make this script available to the public, and having it fail completely and freeze up matlab in one out of five scenarios does not make for a very attractive script.


I wish to know how to prevent such hangs entirely, or at least, anticipate which knockout models might freeze up matlab in this way and skip past such knockout scenarios. I have also heard it suggested that adding a timer to the optimizeCBmodel could be used to abort cases in which it takes too long, but others have suggested that this will not work, because once Matlab calls the GLPK solver, it becomes unresponsive to Matlab commands that might cancel the process until after GLPK is finished.

Thank you in advance for any insight you might provide.

--

---
You received this message because you are subscribed to the Google Groups "COBRA Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-...@googlegroups.com.


--

                                                                                                

Diana Charles Jordan-El Assal, PhD

Laboratory of Algal, Synthetic, and Systems Biology
Post-Doctoral Associate
Division of Science and Math

Center for Genomics and Systems Biology
New York University Abu Dhabi
P.O. Box 129188, Abu Dhabi, UAE
Email...@nyu.edu 
                                                                             

Diana El Assal

unread,
Aug 26, 2019, 1:50:38 PM8/26/19
to cobra-...@googlegroups.com
How about doubleGeneDeletion? 

To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbox+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/d51a0ef4-744f-4600-9f17-2bca7b97f551%40googlegroups.com.


--

                                                                                                

Diana Charles Jordan-El Assal, PhD

Laboratory of Algal, Synthetic, and Systems Biology
Post-Doctoral Associate
Division of Science and Math

Center for Genomics and Systems Biology
New York University Abu Dhabi
P.O. Box 129188, Abu Dhabi, UAE
Email:dc...@nyu.edu 
                                                                             

Herbert Huttanus

unread,
Aug 26, 2019, 4:01:19 PM8/26/19
to COBRA Toolbox
Sorry, I think I'm giving the wrong impression. My goal is not to check every possible single (or even double) gene knockout in isolation using a single command. That is not what I mean by "simultaneous". I want to test scenarios in which 50+ genes are knocked out simultaneously in a single strain and test that singular strain (a multi-KO strain) for viability. 

In fact, my script, as it is currently, can do this quite well most of the time. As an example, lets say the 100th iteration of a loop in my code has discovered another gene it would like to add to the list of 46 genes it has already deleted in previous rounds (the other 53 gene deletions resulted in a lethal combination so they were not kept). It adds the new candidate to the list of 46 non-lethal genes for a total of 47 genes. These are knocked out simultaneously using deletemodelgenes and then tested with optimizeCbModel to see if the combination of all 47 genes is lethal. This is different than checking if any of those 47 genes are lethal in isolation because of the potential for synthetic lethal interactions (which is exactly what Jan Schellenberger warns us about). This code runs to completion most of the time, sometimes generating simulated strains with over 100 knockouts. 

The problem is that sometimes, after a new gene has been added to the list of those to be deleted simultaneously and it proceeds to check for lethality using optimizeCbModel, matlab freezes and cannot be halted.

Even if I could somehow perform 50+ simultaneous knockouts using altered versions of singlegenedeletion or doublegenedeletion in order to test the same KO scenario, those scripts still call upon the same FBA function; optimizeCbModel. I guess my real question is, how do I prevent optimizeCbModel from freezing matlab? What sort of conditions cause optimizeCbModel to do this?

How about doubleGeneDeletion? 



--

                                                                                                

Diana Charles Jordan-El Assal, PhD

Laboratory of Algal, Synthetic, and Systems Biology
Post-Doctoral Associate
Division of Science and Math

Center for Genomics and Systems Biology
New York University Abu Dhabi
P.O. Box 129188, Abu Dhabi, UAE
Email...@nyu.edu 
                                                                             

Thomas Pfau

unread,
Aug 28, 2019, 5:03:06 AM8/28/19
to cobra-...@googlegroups.com

Hi Herbert,

I guess my real question is, how do I prevent optimizeCbModel from freezing matlab? What sort of conditions cause optimizeCbModel to do this?

As bad as it sounds:
I don't think you can.

The most likely place, where Matlab freezes during optimizeCbModel is while calling the solver (i.e. the external mex file for gurobi). This is kind of an atomic operation in Matlab and thus cannot be interrupted before it returns, and if it doesn't, well, than Matlab freezes.
Does it regularily freeze on the same problem? I.e. the same combination of knockouts? If so, than you could have found a very difficult problem, that the solver cannot quickly tackle (after all, LP is NP-hard, so it can potentially take ages, it just luckily doesn't most of the times). In that instance you will either have to wait, or avoid that particular problem.

What you could try is to play around a bit with the solver settings for gurobi, but even that is no guarantee to solve our issue.

Best


Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/6de7a919-5653-449c-99f0-6ace650fa711%40googlegroups.com.

Herbert Huttanus

unread,
Aug 28, 2019, 1:02:36 PM8/28/19
to COBRA Toolbox
Thomas,

Thank you. I was afraid that would be the answer. The freeze is indeed repeatable for a given problem. I'm using GLPK instead of Gurobi but I will see if there are setting adjustments that may help. As for avoiding the problem (anticipating which simulations need to be skipped because they are likely to hang matlab), I am still trying to look for any patterns, but to no avail. Some genes/reactions are easily knocked out in one scenario but freeze matlab when combined with certain other knockouts. If anyone in the community has noticed any trends for what kind of scenarios cause this error I'd love to know, but it seems like we can probably close this thread as 'completed' and just consider it an ongoing mystery. 

Thanks again,
Herbert

Herbert Huttanus

unread,
Aug 28, 2019, 4:03:02 PM8/28/19
to COBRA Toolbox
Everyone,

We have found a partial solution. GLPK has an option for enforcing a time limit of the optimization. I imagine the other solvers do as well. We have edited the code in Cobra's "solveCobraLP.m" file such that when it defines the parameters for GLPK, it specifies a time limit of 10,000 milliseconds (the comments in GLPK.m suggest that the values are in seconds but they are, in fact, milliseconds). Now my troublesome scenarios simply fail to find a solution in time and the output from optimizeCbModel even indicates this failure in the "stats" variable. We will now have our main script ignore any knockout scenarios that return a 'timeout' result.

Unfortunately, this means our script misses certain areas of the multi-knockout solution space that may be biologically relevant, but at least it won't freeze anymore.

Cheers,
Herbert

Ronan M.T. Fleming

unread,
Sep 2, 2019, 11:02:26 AM9/2/19
to COBRA Toolbox
Hi Herbert,
there are free academic licences for gurobi, which is better for more demanding applications. Any LP solver should fail gracefully, rather than hang up matlab. As such, I think this seems like a solver issue, rather than with the cobra toolbox itself.
Regards,
Ronan

To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/8341cb22-ffa4-497c-86c0-a5427d3f91ef%40googlegroups.com.


--
--
Mr. Ronan MT Fleming B.V.M.S. Dip. Math. Ph.D.
----------------------------------------------------------------------------
Assistant Professor,
Division of Systems Biomedicine and Pharmacology,
Leiden Academic Centre for Drug Research,
Faculty of Science,
Leiden University.
&
H2020 Project Coordinator
Systems Medicine of Mitochondrial Parkinson’s Disease
----------------------------------------------------------------------------
Peer-reviewed publications: https://goo.gl/FZPG23
Mobile:  +353 873 413 072
Skype: ronan.fleming
----------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages