Skip to content

Commit

Permalink
Merge pull request #11 from BioSystemsUM/develop
Browse files Browse the repository at this point in the history
Nitrate Ratio
  • Loading branch information
LucianaMartins26 authored Nov 15, 2024
2 parents 68f8310 + 2480ae1 commit 5274beb
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 30 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ With this in mind, this package aims to accelerate this process by being able to
## Installation
### Pip

``` pip install diel_models==1.1.2 ```
``` pip install diel_models==1.2.2 ```

## Getting Started
Using this package, you can handle generic or multi-tissue models by:

* Assigning day and night;
* Inserting specified metabolites into the storage pool allowing their transition between day and night, and vice versa;
* Supressing the photon reaction flux at night;
* Setting the flux of the nitrate reactions to 3:2 according to the literature;
* Setting the flux of the nitrate reactions to 3:2 by default (according to the literature) or other desired ratio;
* (optional) Taking the day and night biomass reactions and creating a total biomass reaction resulting from the junctions of both. Supressing at the same time the flow of the individual reactions to zero and setting the total biomass reaction as the objective function.

If each method is to be applied individually it is essential that the first 3 steps are applied in that order specifically.
Expand All @@ -59,6 +59,21 @@ storage_pool_metabolites = ['Metabolite_ID_1', 'Metabolite_ID_2', 'Metabolite_ID
diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID')
```

where the nitrate uptake ratio is 3:2, since _day_ratio_value_ is 3 and _night_ratio_value_ is 2.

Alternatively, the ratio value can be set to a value other than 3:2.

```python
import cobra
from diel_models.diel_models_creator import diel_models_creator

model = cobra.io.read_sbml_model('.../.../desired_single_tissue_model.xml')

storage_pool_metabolites = ['Metabolite_ID_1', 'Metabolite_ID_2', 'Metabolite_ID_3']

diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID', day_ratio_value=desired_value_1, night_ratio_value=desired_value_2)
```

- Multi-tissue model:

```python
Expand All @@ -74,7 +89,9 @@ tissues = ['Tissue_ID_1', 'Tissue_ID_2']
diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID', tissues)
```

This is possible due to the created *Pipeline* class that derives from a *Step* class with abstract methods - both present in this package, in the [pipeline.py](src/diel_models/pipeline.py) file.
where the nitrate uptake ratio is 3:2, but it's also possible to adjust this ratio to different values.

Running the entire pipeline is possible due to the created *Pipeline* class that derives from a *Step* class with abstract methods - both present in this package, in the [pipeline.py](src/diel_models/pipeline.py) file.

## Expanding the pipeline

Expand Down Expand Up @@ -120,7 +137,8 @@ from diel_models.new_class import NewClass
from diel_models.pipeline import Pipeline

def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photon_reaction_id: List[str],
nitrate_exchange_reaction: List[str], param1, biomass_reaction_id: str = None, tissues: List[str] = None) -> Model:
nitrate_exchange_reaction: List[str], param1, biomass_reaction_id: str = None, tissues: List[str] = None,
day_ratio_value: int = 3, night_ratio_value: int = 2) -> Model:

storage_pool_metabolites_with_day = [metabolite + "_Day" for metabolite in storage_pool_metabolites]
photon_reaction_id_night = [photon_night_reaction + "_Night" for photon_night_reaction in photon_reaction_id]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
project = 'diel_models'
copyright = '2023, Luciana Martins and João Capela'
author = 'Luciana Martins and João Capela'
release = 'v1.1.0'
release = 'v1.2.2'

sys.path.insert(0, os.path.abspath('../src/'))

Expand Down
58 changes: 49 additions & 9 deletions docs/diel_models_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ Python 3.12
```

### Description
*diel_models* is a python package generated from this project and has its own [ReadtheDocs](https://dielmodels.readthedocs.io/) file.

Despite numerous successful studies, modeling plant metabolism remains challenging for several reasons, such as limited information, incomplete annotations, and dynamic changes in plant metabolism that occur under different conditions, including night and day.
In particular, the integration of these day-night cycles (diel cycles) is complex, laborious, and time-consuming.

With this in mind, this package aims to accelerate this process by being able to transform a non-diel model into a diel model.

### Installation
## Installation

``` pip install diel_models==1.1.2 ```
``` pip install diel_models==1.2.2 ```

### Getting Started
## Getting Started
Using this package, you can handle generic or multi-tissue models by:

* Assigning day and night;
* Inserting specified metabolites into the storage pool allowing their transition between day and night, and vice versa;
* Supressing the photon reaction flux at night;
* Setting the flux of the nitrate reactions to 3:2 according to the literature;
* Setting the flux of the nitrate reactions to 3:2 by default (according to the literature) or other desired ratio;
* (optional) Taking the day and night biomass reactions and creating a total biomass reaction resulting from the junctions of both. Supressing at the same time the flow of the individual reactions to zero and setting the total biomass reaction as the objective function.

If each method is to be applied individually it is essential that the first 3 steps are applied in that order specifically.
Expand All @@ -49,6 +50,21 @@ storage_pool_metabolites = ['Metabolite_ID_1', 'Metabolite_ID_2', 'Metabolite_ID
diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID')
```

where the nitrate uptake ratio is 3:2, since _day_ratio_value_ is 3 and _night_ratio_value_ is 2.

Alternatively, the ratio value can be set to a value other than 3:2.

```python
import cobra
from diel_models.diel_models_creator import diel_models_creator

model = cobra.io.read_sbml_model('.../.../desired_single_tissue_model.xml')

storage_pool_metabolites = ['Metabolite_ID_1', 'Metabolite_ID_2', 'Metabolite_ID_3']

diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID', day_ratio_value=desired_value_1, night_ratio_value=desired_value_2)
```

- Multi-tissue model:

```python
Expand All @@ -64,9 +80,11 @@ tissues = ['Tissue_ID_1', 'Tissue_ID_2']
diel_models_creator(model, storage_pool_metabolites, ['Photon_Reaction_ID'], ['Nitrate_Reaction_ID'], 'Biomass_Reaction_ID', tissues)
```

This is possible due to the created *Pipeline* class that derives from a *Step* class with abstract methods - both present in this package, in the pipeline.py file.
where the nitrate uptake ratio is 3:2, but it's also possible to adjust this ratio to different values.

Running the entire pipeline is possible due to the created *Pipeline* class that derives from a *Step* class with abstract methods - both present in this package, in the [pipeline.py](src/diel_models/pipeline.py) file.

### Expanding the pipeline
## Expanding the pipeline

It is possible to add other classes to the *diel_models_creator* function, if desired, for example to create a different adjustment that needs to be taken into account in the diel models.
To expand the pipeline, it is necessary to create a new class that inherits from the *Step* class and implement the abstract methods.
Expand Down Expand Up @@ -98,7 +116,7 @@ class NewClass(Step):
pass
```

Then you need to adjust the *diel_models_creator* function to integrate the new class. This function is in the diel_models_creator.py file.
Then you need to adjust the *diel_models_creator* function to integrate the new class. This function is in the [diel_models_creator.py](src/diel_models/diel_models_creator.py) file.

```python
from typing import List
Expand All @@ -110,7 +128,8 @@ from diel_models.new_class import NewClass
from diel_models.pipeline import Pipeline

def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photon_reaction_id: List[str],
nitrate_exchange_reaction: List[str], param1, biomass_reaction_id: str = None, tissues: List[str] = None) -> Model:
nitrate_exchange_reaction: List[str], param1, biomass_reaction_id: str = None, tissues: List[str] = None,
day_ratio_value: int = 3, night_ratio_value: int = 2) -> Model:

storage_pool_metabolites_with_day = [metabolite + "_Day" for metabolite in storage_pool_metabolites]
photon_reaction_id_night = [photon_night_reaction + "_Night" for photon_night_reaction in photon_reaction_id]
Expand All @@ -128,4 +147,25 @@ def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photo

Finally, you can run the *diel_models_creator* function with the new class.

Just as you can expand methods in the pipeline, you can modify or remove others.
Just as you can expand methods in the pipeline, you can modify or remove others.

## Where to find the publication results

### AraGEM:

* Details about the fluxes in the AraGEM diel model reactions in the day and night phases, as well as in the original model where calculated in [aragem_reactions_fluxes.py](validation/arabidopsis/aragem_reactions_fluxes.py) file.
* Validation of the metabolites exchange reactions through simulation using pFBA where performed in [simulation_sp.py](validation/arabidopsis/simulation_sp/simulation_sp.py) file.
* [DFA file](DFA/differential_flux_analysis.py) and respective [Test file](tests/integration_tests/test_dfa.py).
* [Plot](tests/reconstruction_results/MODEL1507180028/results_troppo/DielModel/dfa/diel_model_DFA_pathway_result.png) from the pathway enrichment method representing the amount of differentially expressed reactions between day and night in each pathway.
* [PCA](PCA/gráfico_pca_df_filtrado.png) plot with the sampling values filtered by the differentially expressed reactions.

### _Quercus suber_:

* Details about the fluxes in the _Quercus suber_ diel model reactions in the day and night phases, as well as in the original model where calculated in [quercus_reactions_fluxes.py](validation/quercus/quercus_reactions_fluxes.py) file.
* Slight adjustments to the biomass reaction in the generated diel model can be found [here](validation/quercus/comparison/auxiliar_model_change.py).
* Validation of the metabolites exchange reactions through simulation using pFBA where performed in [simulation_sp_multi_quercus.py](validation/quercus/simulation_sp/simulation_sp_multi_quercus.py) file.
* The comparison between the flux of the biomass reaction for both diel multi-tissue models are in the [quercus_diel_models_comparison.py](validation/quercus/comparison/quercus_multi_tissue_diel_models_comparison.py) file.

### QY for the several models:

* The scripts for quantum yield and assimilation quotient calculation for the _Zea mays L._ (2011), _Arabidopsis thaliana_ (2010), _Populus trichocarpa_ (2020), _Solanum lycopersicum_ (2015), _Solanum lycopersicum_ (2022) and _Solanum tuberosum_ (2018) models can be found in the [QY](validation/QY) folder.
9 changes: 1 addition & 8 deletions docs/requirements_rtd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@ rst-to-myst
sphinx-rtd-theme
sphinx-autobuild
myst-parser
cobra~=0.26.2
pandas~=1.5.3
statsmodels~=0.13.5
matplotlib~=3.7.1
numpy>=1.22
scipy~=1.10.1
setuptools~=65.6.3
scikit-learn~=1.2.2
cobra
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = diel_models
version = 1.1.2
version = 1.2.2
description = diel_models:
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
13 changes: 10 additions & 3 deletions src/diel_models/diel_models_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photon_reaction_id: List[str],
nitrate_exchange_reaction: List[str], biomass_reaction_id: str = None, tissues: List[str] = None) -> Model:
nitrate_exchange_reaction: List[str], biomass_reaction_id: str = None, tissues: List[str] = None,
day_ratio_value: int = 3, night_ratio_value: int = 2) -> Model:
"""
Function that allows you to run the pipeline in one go,
returning the resulting model, where the arguments are all relative to the original model.
Expand All @@ -30,6 +31,10 @@ def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photo
id for biomass_reaction, defaults to None in case no biomass reaction defined.
tissues: List[str], optional
List of tissues in the multi-tissue model, defaults to None for generic models.
day_ratio_value: int, optional
The ratio of nitrate uptake during the day, default is 3.
night_ratio_value: int, optional
The ratio of nitrate uptake during the night, default is 2.
Returns
-------
Expand All @@ -49,15 +54,17 @@ def diel_models_creator(model: Model, storage_pool_metabolites: List[str], photo
StoragePoolGenerator(model, storage_pool_metabolites_with_day, tissues),
PhotonReactionInhibitor(model, photon_reaction_id_night),
BiomassAdjuster(model, biomass_day_id, biomass_night_id),
NitrateUptakeRatioCalibrator(model, nitrate_exchange_reaction_day, nitrate_exchange_reaction_night)
NitrateUptakeRatioCalibrator(model, nitrate_exchange_reaction_day, nitrate_exchange_reaction_night,
day_ratio_value=day_ratio_value, night_ratio_value=night_ratio_value)
]

else:
steps = [
DayNightCreator(model),
StoragePoolGenerator(model, storage_pool_metabolites_with_day, tissues),
PhotonReactionInhibitor(model, photon_reaction_id_night),
NitrateUptakeRatioCalibrator(model, nitrate_exchange_reaction_day, nitrate_exchange_reaction_night)
NitrateUptakeRatioCalibrator(model, nitrate_exchange_reaction_day, nitrate_exchange_reaction_night,
day_ratio_value=day_ratio_value, night_ratio_value=night_ratio_value)
]

pipeline = Pipeline(model, steps)
Expand Down
15 changes: 11 additions & 4 deletions src/diel_models/nitrate_uptake_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class NitrateUptakeRatioCalibrator(Step):

def __init__(self, model: Model, id_nitrate_uptake_reaction_day: List[str],
id_nitrate_uptake_reaction_night: List[str]) -> None:
id_nitrate_uptake_reaction_night: List[str], day_ratio_value: int = 3, night_ratio_value: int = 2) -> None:
"""
Constructor
Expand All @@ -19,14 +19,21 @@ def __init__(self, model: Model, id_nitrate_uptake_reaction_day: List[str],
Identification of day nitrate uptake reaction(s) - in case of for example, multi tissue models.
id_nitrate_uptake_reaction_night: List[str]
Identification of night nitrate uptake reaction(s) - in case of for example, multi tissue models.
day_ratio_value: int, optional
The ratio of nitrate uptake during the day, default is 3.
night_ratio_value: int, optional
The ratio of nitrate uptake during the night, default is 2.
"""
self.model: Model = model
self.id_nitrate_uptake_reaction_day: List[str] = id_nitrate_uptake_reaction_day
self.id_nitrate_uptake_reaction_night: List[str] = id_nitrate_uptake_reaction_night
self.day_ratio_value: int = day_ratio_value
self.night_ratio_value: int = night_ratio_value

def ratio_set(self) -> None:
"""
This function establishes a 3:2 ratio of nitrate uptake between day and night, respectively.
This function establishes a 3:2 ratio (by default) of nitrate uptake between day and night, respectively.
The ratio can be changed.
Raises:
ValueError: If the nitrate uptake reaction ID is not present in the given model.
Expand All @@ -39,8 +46,8 @@ def ratio_set(self) -> None:
nitrate_uptake_reaction_night = self.model.reactions.get_by_id(nitrate_uptake_night_reaction)

same_flux = self.model.problem.Constraint(
nitrate_uptake_reaction_day.flux_expression * 2 -
nitrate_uptake_reaction_night.flux_expression * 3, lb=0, ub=0)
nitrate_uptake_reaction_day.flux_expression * self.night_ratio_value -
nitrate_uptake_reaction_night.flux_expression * self.day_ratio_value, lb=0, ub=0)
self.model.add_cons_vars(same_flux)

else:
Expand Down

0 comments on commit 5274beb

Please sign in to comment.