From 1ab9ddd2ea9a1af39e0a7443450daca0790020f3 Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Fri, 25 Sep 2026 20:59:03 +0200 Subject: [PATCH] docs(init): pass Human-GEM's spontaneous reactions in the Python example and explain why --- docs/guide/init.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/guide/init.md b/docs/guide/init.md index 760640e..9bfa6d1 100644 --- a/docs/guide/init.md +++ b/docs/guide/init.md @@ -133,9 +133,10 @@ prepData.mat: 159 MB ``` Human-GEM also has a wrapper, `prepHumanModelForftINIT`, which reads those -two files for you. It does **not** run against RAVEN `develop3`: its -`importTsvFile` returns the `spontaneous` column as text, so the `== 1` -inside it throws. Calling `prepINITModel` directly, as above, sidesteps that. +two files for you. Before Human-GEM 2.0.1 it did not run against RAVEN +`develop3`: `importTsvFile` returned the `spontaneous` column as text, so the +`== 1` inside it threw. From 2.0.1 on it converts the column first; with an +older Human-GEM, call `prepINITModel` directly, as above. ::: :::{tab-item} 🐍 Python :sync: python @@ -144,6 +145,7 @@ inside it throws. Calling `prepINITModel` directly, as above, sidesteps that. ```python import cobra +import pandas as pd from cobra.io import read_sbml_model from raven_toolbox.init import prep_init_model @@ -155,7 +157,11 @@ model = read_sbml_model("Human-GEM/model/Human-GEM.xml") model.solver = "gurobi" tasks = parse_task_list("Human-GEM/data/metabolicTasks/metabolicTasks_Essential.txt") -prep = prep_init_model(model, tasks, ext_comp="e") +# spontaneous reactions are flagged in the model's own annotation table +tsv = pd.read_csv("Human-GEM/model/reactions.tsv", sep="\t") +spont = tsv.loc[tsv["spontaneous"] == 1, "rxns"].tolist() + +prep = prep_init_model(model, tasks, ext_comp="e", spontaneous=spont) ``` ```text @@ -176,6 +182,20 @@ same machine and solver. Two things affect the run: ::: :::: +:::{note} Pass the spontaneous reactions +ftINIT keeps every reaction passed as +spontaneous in every extracted model, whatever the data say. Other reactions +without a gene rule are kept only where the optimisation needs them, so they can +differ from sample to sample. In Human-GEM, `spontaneous` marks reactions that need +no enzyme. That includes diffusion: transport between cytosol and nucleus through +the nuclear pores, and gases and water (O2, CO2, H2O, NH3, H2O2, NO, H2S) crossing +membranes. Leaving out the list, or using a Human-GEM older than the release that +added these flags, lets ftINIT drop such transports in some samples. The model then +falls back on other routes. For example, without the dCTP transport into the nucleus, +deoxycytidine kinase (DCK) becomes essential for DNA synthesis, which is an artefact +of the extraction rather than biology. +::: + ## 14.2 Bring in the expression data RAVEN wants one struct: the genes, the sample names, and a genes × samples matrix