Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename dingo to dingo_walk #111

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# dingo : a python library for metabolic networks sampling and analysis
# dingo is part of GeomScale project
# dingo_walk : a python library for metabolic networks sampling and analysis
# dingo_walk is part of GeomScale project

# Copyright (c) 2021-2022 Vissarion Fisikopoulos

# Licensed under GNU LGPL.3, see LICENCE file

name: dingo-ubuntu
name: dingo_walk-ubuntu

on: [push, pull_request]

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build
dist
boost_1_76_0
dingo.egg-info
dingo_walk.egg-info
*.pyc
*.so
volestipy.cpp
Expand All @@ -12,4 +12,4 @@ volestipy.egg-info
venv
lp_solve_5.5/
.devcontainer/
.github/dependabot.yml
.github/dependabot.yml
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<p align="center"><img src="doc/logo/dingo.jpg" width="260" height="260"></p>
<p align="center"><img src="https://raw.githubusercontent.com/GeomScale/dingo/refs/heads/develop/doc/logo/dingo.jpg" width="260" height="260"></p>

**dingo** is a Python package that analyzes metabolic networks.
**dingo_walk** is a Python package that analyzes metabolic networks.
It relies on high dimensional sampling with Markov Chain Monte Carlo (MCMC)
methods and fast optimization methods to analyze the possible states of a
metabolic network. To perform MCMC sampling, `dingo` relies on the `C++` library
metabolic network. To perform MCMC sampling, `dingo_walk` relies on the `C++` library
[volesti](https://github.com/GeomScale/volume_approximation), which provides
several algorithms for sampling convex polytopes.
`dingo` also performs two standard methods to analyze the flux space of a
`dingo_walk` also performs two standard methods to analyze the flux space of a
metabolic network, namely Flux Balance Analysis and Flux Variability Analysis.

`dingo` is part of [GeomScale](https://geomscale.github.io/) project.
`dingo_walk` is part of [GeomScale](https://geomscale.github.io/) project.

[![unit-tests](https://github.com/GeomScale/dingo/workflows/dingo-ubuntu/badge.svg)](https://github.com/GeomScale/dingo/actions?query=workflow%3Adingo-ubuntu)
[![unit-tests](https://github.com/GeomScale/dingo/workflows/dingo_walk-ubuntu/badge.svg)](https://github.com/GeomScale/dingo/actions?query=workflow%3Adingo_walk-ubuntu)
[![Tutorial In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/GeomScale/dingo/blob/develop/tutorials/dingo_tutorial.ipynb)
[![Chat](https://badges.gitter.im/geomscale.png)](https://gitter.im/GeomScale/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link)

Expand All @@ -28,7 +28,7 @@ If you have a different version of Python installed, you'll need to install it (



To load the submodules that dingo uses, run
To load the submodules that dingo_walk uses, run

````bash
git submodule update --init
Expand All @@ -55,7 +55,7 @@ sudo apt-get update -y
sudo apt-get install -y libsuitesparse-dev
```

To install the Python dependencies, `dingo` is using [Poetry](https://python-poetry.org/),
To install the Python dependencies, `dingo_walk` is using [Poetry](https://python-poetry.org/),
```
curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2
poetry shell
Expand Down Expand Up @@ -98,28 +98,28 @@ python3 tests/sampling.py gurobi
## Tutorial

You can have a look at our [Google Colab notebook](https://colab.research.google.com/github/GeomScale/dingo/blob/develop/tutorials/dingo_tutorial.ipynb)
on how to use `dingo`.
on how to use `dingo_walk`.


## Documentation


It quite simple to use dingo in your code. In general, dingo provides two classes:
It quite simple to use dingo_walk in your code. In general, dingo_walk provides two classes:

- `metabolic_network` represents a metabolic network
- `polytope_sampler` can be used to sample from the flux space of a metabolic network or from a general convex polytope.

The following script shows how you could sample steady states of a metabolic network with dingo. To initialize a metabolic network object you have to provide the path to the `json` file as those in [BiGG](http://bigg.ucsd.edu/models) dataset or the `mat` file (using the `matlab` wrapper in folder `/ext_data` to modify a standard `mat` file of a model as those in BiGG dataset):
The following script shows how you could sample steady states of a metabolic network with dingo_walk. To initialize a metabolic network object you have to provide the path to the `json` file as those in [BiGG](http://bigg.ucsd.edu/models) dataset or the `mat` file (using the `matlab` wrapper in folder `/ext_data` to modify a standard `mat` file of a model as those in BiGG dataset):

```python
from dingo import MetabolicNetwork, PolytopeSampler
from dingo_walk import MetabolicNetwork, PolytopeSampler

model = MetabolicNetwork.from_json('path/to/model_file.json')
sampler = PolytopeSampler(model)
steady_states = sampler.generate_steady_states()
```

`dingo` can also load a model given in `.sbml` format using the following command,
`dingo_walk` can also load a model given in `.sbml` format using the following command,

```python
model = MetabolicNetwork.from_sbml('path/to/model_file.sbml')
Expand Down Expand Up @@ -147,10 +147,10 @@ The default option is to run the sequential [Multiphase Monte Carlo Sampling alg

#### Rounding the polytope

`dingo` provides three methods to round a polytope: (i) Bring the polytope to John position by apllying to it the transformation that maps the largest inscribed ellipsoid of the polytope to the unit ball, (ii) Bring the polytope to near-isotropic position by using uniform sampling with Billiard Walk, (iii) Apply to the polytope the transformation that maps the smallest enclosing ellipsoid of a uniform sample from the interior of the polytope to the unit ball.
`dingo_walk` provides three methods to round a polytope: (i) Bring the polytope to John position by apllying to it the transformation that maps the largest inscribed ellipsoid of the polytope to the unit ball, (ii) Bring the polytope to near-isotropic position by using uniform sampling with Billiard Walk, (iii) Apply to the polytope the transformation that maps the smallest enclosing ellipsoid of a uniform sample from the interior of the polytope to the unit ball.

```python
from dingo import MetabolicNetwork, PolytopeSampler
from dingo_walk import MetabolicNetwork, PolytopeSampler

model = MetabolicNetwork.from_json('path/to/model_file.json')
sampler = PolytopeSampler(model)
Expand All @@ -170,31 +170,31 @@ samples = sample_from_polytope(A_rounded, b_rounded)
Last you can map the samples back to steady states,

```python
from dingo import map_samples_to_steady_states
from dingo_walk import map_samples_to_steady_states

steady_states = map_samples_to_steady_states(samples, N, N_shift, Tr, Tr_shift)
```

#### Other MCMC sampling methods

To use any other MCMC sampling method that `dingo` provides you can use the following piece of code:
To use any other MCMC sampling method that `dingo_walk` provides you can use the following piece of code:

```python
sampler = polytope_sampler(model)
steady_states = sampler.generate_steady_states_no_multiphase() #default parameters (method = 'billiard_walk', n=1000, burn_in=0, thinning=1)
```

The MCMC methods that dingo (through `volesti` library) provides are the following: (i) 'cdhr': Coordinate Directions Hit-and-Run, (ii) 'rdhr': Random Directions Hit-and-Run,
The MCMC methods that dingo_walk (through `volesti` library) provides are the following: (i) 'cdhr': Coordinate Directions Hit-and-Run, (ii) 'rdhr': Random Directions Hit-and-Run,
(iii) 'billiard_walk', (iv) 'ball_walk', (v) 'dikin_walk', (vi) 'john_walk', (vii) 'vaidya_walk'.



#### Switch the linear programming solver

We use `pyoptinterface` to interface with the linear programming solvers. To switch the solver that `dingo` uses, you can use the `set_default_solver` function. The default solver is `highs` and you can switch to `gurobi` by running,
We use `pyoptinterface` to interface with the linear programming solvers. To switch the solver that `dingo_walk` uses, you can use the `set_default_solver` function. The default solver is `highs` and you can switch to `gurobi` by running,

```python
from dingo import set_default_solver
from dingo_walk import set_default_solver
set_default_solver("gurobi")
```

Expand All @@ -205,7 +205,7 @@ You can also switch to other solvers that `pyoptinterface` supports, but we reco
To apply FVA and FBA methods you have to use the class `metabolic_network`,

```python
from dingo import MetabolicNetwork
from dingo_walk import MetabolicNetwork

model = MetabolicNetwork.from_json('path/to/model_file.json')
fva_output = model.fva()
Expand Down Expand Up @@ -233,7 +233,7 @@ while the output vectors are the same with the previous example.

### Set the restriction in the flux space

FVA and FBA, restrict the flux space to the set of flux vectors that have an objective value equal to the optimal value of the function. dingo allows for a more relaxed option where you could ask for flux vectors that have an objective value equal to at least a percentage of the optimal value,
FVA and FBA, restrict the flux space to the set of flux vectors that have an objective value equal to the optimal value of the function. dingo_walk allows for a more relaxed option where you could ask for flux vectors that have an objective value equal to at least a percentage of the optimal value,

```python
model.set_opt_percentage(90)
Expand Down Expand Up @@ -273,7 +273,7 @@ steady_states = sampler.generate_steady_states()
The generated steady states can be used to estimate the marginal density function of each flux. You can plot the histogram using the samples,

```python
from dingo import plot_histogram
from dingo_walk import plot_histogram

model = MetabolicNetwork.from_json('path/to/e_coli_core.json')
sampler = PolytopeSampler(model)
Expand All @@ -288,16 +288,16 @@ plot_histogram(
)
```

The default number of bins is 60. dingo uses the package `matplotlib` for plotting.
The default number of bins is 60. dingo_walk uses the package `matplotlib` for plotting.

![histogram](./doc/e_coli_aconta.png)
![histogram](https://raw.githubusercontent.com/GeomScale/dingo/refs/heads/develop/doc/e_coli_aconta.png)

### Plot a copula between two fluxes

The generated steady states can be used to estimate and plot the copula between two fluxes. You can plot the copula using the samples,

```python
from dingo import plot_copula
from dingo_walk import plot_copula

model = MetabolicNetwork.from_json('path/to/e_coli_core.json')
sampler = PolytopeSampler(model)
Expand All @@ -312,8 +312,8 @@ data_flux1=[steady_states[13],reactions[13]]
plot_copula(data_flux1, data_flux2, n=10)
```

The default number of cells is 5x5=25. dingo uses the package `plotly` for plotting.
The default number of cells is 5x5=25. dingo_walk uses the package `plotly` for plotting.

![histogram](./doc/aconta_ppc_copula.png)
![histogram](https://raw.githubusercontent.com/GeomScale/dingo/refs/heads/develop/doc/aconta_ppc_copula.png)


2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def build(setup_kwargs):
# This function will be executed in setup.py:
def build(setup_kwargs):
# The file you want to compile
extensions = ["dingo/volestipy.pyx"]
extensions = ["dingo_walk/volestipy.pyx"]

# gcc arguments hack: enable optimizations
os.environ["CFLAGS"] = [
Expand Down
10 changes: 0 additions & 10 deletions dingo/__main__.py

This file was deleted.

16 changes: 8 additions & 8 deletions dingo/MetabolicNetwork.py → dingo_walk/MetabolicNetwork.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# dingo : a python library for metabolic networks sampling and analysis
# dingo is part of GeomScale project
# dingo_walk : a python library for metabolic networks sampling and analysis
# dingo_walk is part of GeomScale project

# Copyright (c) 2021 Apostolos Chalkis
# Copyright (c) 2021 Vissarion Fisikopoulos
Expand All @@ -11,8 +11,8 @@
import sys
from typing import Dict
import cobra
from dingo.loading_models import read_json_file, read_mat_file, read_sbml_file, parse_cobra_model
from dingo.pyoptinterface_based_impl import fba,fva,inner_ball,remove_redundant_facets
from dingo_walk.loading_models import read_json_file, read_mat_file, read_sbml_file, parse_cobra_model
from dingo_walk.pyoptinterface_based_impl import fba,fva,inner_ball,remove_redundant_facets

class MetabolicNetwork:
def __init__(self, tuple_args):
Expand Down Expand Up @@ -250,18 +250,18 @@ def set_active_bound(reaction: str, reac_index: int, bound: float) -> None:
# Turn off reactions not present in media
for rxn_id in exchange_rxns - frozen_media_rxns:
"""
is_export for us, needs to check on the S
order reactions to their lb and ub
is_export for us, needs to check on the S
order reactions to their lb and ub
"""
# is_export = rxn.reactants and not rxn.products
reac_index = self._reactions.index(rxn_id)
products = np.any(self._S[:,reac_index] > 0)
products = np.any(self._S[:,reac_index] > 0)
reactants_exist = np.any(self._S[:,reac_index] < 0)
is_export = True if not products and reactants_exist else False
set_active_bound(
rxn_id, reac_index, min(0.0, -self._lb[reac_index] if is_export else self._ub[reac_index])
)

def set_solver(self, solver: str):
self._parameters["solver"] = solver

Expand Down
10 changes: 5 additions & 5 deletions dingo/PolytopeSampler.py → dingo_walk/PolytopeSampler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# dingo : a python library for metabolic networks sampling and analysis
# dingo is part of GeomScale project
# dingo_walk : a python library for metabolic networks sampling and analysis
# dingo_walk is part of GeomScale project

# Copyright (c) 2021 Apostolos Chalkis
# Copyright (c) 2024 Ke Shi
Expand All @@ -10,14 +10,14 @@
import numpy as np
import warnings
import math
from dingo.MetabolicNetwork import MetabolicNetwork
from dingo.utils import (
from dingo_walk.MetabolicNetwork import MetabolicNetwork
from dingo_walk.utils import (
map_samples_to_steady_states,
get_matrices_of_low_dim_polytope,
get_matrices_of_full_dim_polytope,
)

from dingo.pyoptinterface_based_impl import fba,fva,inner_ball,remove_redundant_facets
from dingo_walk.pyoptinterface_based_impl import fba,fva,inner_ball,remove_redundant_facets

from volestipy import HPolytope

Expand Down
Loading