Replies: 3 comments 19 replies
-
Hi @gcxxx, Instead of describing your steps in words, can you please provide the exact code that you used? Thank you. |
Beta Was this translation helpful? Give feedback.
-
Not really a bug, but if you don't pass a solution to summary it will generate a new one and this may be different from a previous one. Note that FBA solutions are generally not unique. See #1029 for some workarounds. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone! I've run some tests, out of curiosity. I could reproduce the example of @gcxxx and I may understand the confusing part. I downloaded iCHOv1 from http://bigg.ucsd.edu/models/iCHOv1. First, let's see what the code from this reply gives us: cmodel = cobra.io.read_sbml_model("iCHOv1.xml")
cmodel.solver = "cplex" # case 1
cmodel.solver = "glpk" # case 2
csol = cmodel.optimize()
print(cmodel.metabolites.g3p_c.summary()) # we use .summary()
csol.status In both cases, we get something along:
However the result of the line
So what happened? My guess is that LDH_Lm cannot carry any flux and that GLPX rounds it to 0 while CPLEX explicitly warns that it cannot carry flux. Let me note here that accessing the flux value from the reaction object is considered bad practice as stated in the documentation. You should always access fluxes from a Solution object... and it where the fun begins! The line And then comes the cmodel = cobra.io.read_sbml_model("iCHOv1.xml")
cmodel.solver = "cplex" # case 1
cmodel.solver = "glpk" # case 2
# first, we use .summary()
csol = cmodel.optimize()
print(cmodel.metabolites.g3p_c.summary())
# second, we do not use .summary()
csol = cmodel.optimize()
cmodel.reactions.LDH_Lm.flux, csol.fluxes.loc['LDH_Lm'] I get:
This is certainly confusing... but not unexpected. So what is happening? First, let's note that 1e-17 is 0 considering the solver's precision. But what about the 0.16 flux value given by CPLEX? This is where you need to understand what @cdiener said: only the objective value is guaranteed to be optimal, but several flux distributions may yield the same optimal objective value. This is fairly common (and the sign that the model is not constrained enough). Only one flux distribution is reported when you do an FBA. If you wish to get the minimal and maximal bound of each of your reactions, well, you can ask the solver for precisely that:
This is what we call a flux variability analysis (see https://cobrapy.readthedocs.io/en/latest/simulating.html#Running-FVA). Note that, usually, at step 2 you would not constrain the model's previous objective to its optimal value, but to a fraction of its optimal in order to get the fluxes variability at, say, ±5% of the optimal growth rate. Flux variability analysis can be done easily in cobra with (
You can display unconstrained fluxes with something along In your example, you will see that In terms of things we could do to improve COBRApy:
HTH |
Beta Was this translation helpful? Give feedback.
-
Hi everyone:
I load the iCHOv1(from BIGG) model into cobrapy and use model.optimize() to get fba result. Then I use model.summary() to see the profile of metabolism , # subsequently, when I try to use model.reaction.flux , an error happen
Why could that happen?
Beta Was this translation helpful? Give feedback.
All reactions