| 492 | 1 # Flux Simulation | 
|  | 2 | 
| 547 | 3 Simulate flux distributions from constraint-based metabolic models using different optimization or sampling strategies. | 
| 492 | 4 | 
|  | 5 ## Overview | 
|  | 6 | 
| 547 | 7 Two types of analysis are available: | 
|  | 8 - **flux optimization** | 
|  | 9 - **flux sampling** | 
|  | 10 | 
|  | 11 For flux optimization, one of the following methods can be performed: parsimonious-FBA, Flux Variability Analysis, Biomass sensitivity analysis (single reaction knock-out) | 
|  | 12 The objective function, a linear combination of fluxes weighted by specific coefficients, depends on the provided metabolic network. | 
|  | 13 | 
|  | 14 For flux sampling, one of the following methods can be performed: CBS (Corner-based sampling), OPTGP (Improved Artificial Centering Hit-and-Run sampler). | 
| 492 | 15 | 
| 547 | 16 ## Galaxy Interface | 
|  | 17 | 
|  | 18 In Galaxy: **COBRAxy → Flux Simulation** | 
| 492 | 19 | 
| 547 | 20 1. Select model and upload bounds files | 
|  | 21 2. Choose algorithm (CBS/OPTGP) and sampling parameters | 
|  | 22 3. Click **Run tool** | 
|  | 23 | 
|  | 24 ## Command-line console | 
| 492 | 25 | 
|  | 26 ```bash | 
| 547 | 27 flux_simulation -ms ENGRO2 \ | 
|  | 28                 -in bounds/*.tsv \ | 
|  | 29                 -ni Sample1,Sample2,Sample3 \ | 
| 492 | 30                 -a CBS \ | 
|  | 31                 -ns 1000 \ | 
| 547 | 32                 -idop output/ | 
| 492 | 33 ``` | 
|  | 34 | 
|  | 35 ## Parameters | 
|  | 36 | 
|  | 37 | Parameter | Flag | Description | Default | | 
|  | 38 |-----------|------|-------------|---------| | 
| 547 | 39 | Model Selector | `-ms` | ENGRO2, Recon, or Custom | ENGRO2 | | 
|  | 40 | Input Format | `--model_and_bounds` | Separate files (true) or complete models (false) | true | | 
|  | 41 | Input Bounds | `-in` | Bounds files | - | | 
|  | 42 | Name Input | `-ni` | Sample names (comma-separated) | - | | 
|  | 43 | Algorithm | `-a` | CBS or OPTGP | CBS | | 
|  | 44 | Num Samples | `-ns` | Number of samples per batch | 1000 | | 
|  | 45 | Num Batches | `-nb` | Number of batches | 1 | | 
|  | 46 | Thinning | `-th` | OPTGP thinning parameter | 100 | | 
|  | 47 | Output Type | `-ot` | mean, median, quantiles, fluxes | mean,median | | 
|  | 48 | FVA Optimality | `--perc_opt` | Optimality fraction (0.0-1.0) | 0.90 | | 
|  | 49 | Output Path | `-idop` | Output directory | flux_simulation/ | | 
| 492 | 50 | 
|  | 51 ## Algorithms | 
|  | 52 | 
| 547 | 53 ### CBS (Corner-Based Sampling) | 
|  | 54 - Random objective optimization | 
|  | 55 - Requires GLPK (recommended) or COBRApy solver | 
| 492 | 56 - Suitable for large models | 
|  | 57 | 
| 547 | 58 ### OPTGP (MCMC Sampling) | 
|  | 59 - Markov Chain Monte Carlo | 
|  | 60 - Uniform sampling guarantee | 
|  | 61 - Requires thinning parameter | 
| 492 | 62 | 
| 547 | 63 ## Input Modes | 
|  | 64 | 
|  | 65 The tool supports two different input formats: | 
| 492 | 66 | 
| 547 | 67 ### Mode 1: Model + Bounds (default, `--model_and_bounds true`) | 
|  | 68 Upload one base model + multiple bound files (one per sample/context): | 
|  | 69 - Base model: Tabular file with reaction structure (from Import Metabolic Model) | 
|  | 70 - Bounds: Individual TSV files with sample-specific constraints (from RAS to Bounds) | 
|  | 71 - Use when you have RAS-derived bounds for multiple samples | 
| 492 | 72 | 
| 547 | 73 ### Mode 2: Multiple Complete Models (`--model_and_bounds false`) | 
|  | 74 Upload pre-built model files, each already containing integrated bounds: | 
|  | 75 - Each file is a complete tabular model with reaction structure + bounds | 
|  | 76 - Use when models are already prepared with specific constraints | 
|  | 77 - Useful for comparing different modelling scenarios | 
| 492 | 78 | 
| 547 | 79 ## Input Format | 
| 492 | 80 | 
| 547 | 81 Bounds files (TSV): | 
| 492 | 82 | 
|  | 83 ``` | 
| 547 | 84 reaction	lower_bound	upper_bound | 
|  | 85 R00001	-125.0	125.0 | 
|  | 86 R00002	-65.0	65.0 | 
| 492 | 87 ``` | 
|  | 88 | 
| 547 | 89 **File Format Notes:** | 
|  | 90 - Use **tab-separated** values (TSV) | 
|  | 91 - Column headers must be: reaction, lower_bound, upper_bound | 
|  | 92 - Reaction IDs must match model reaction IDs | 
|  | 93 - Numeric values for bounds | 
| 492 | 94 | 
| 547 | 95 ## Sampling Outputs | 
| 492 | 96 | 
| 547 | 97 The tool can generate different types of output from flux sampling: | 
| 492 | 98 | 
| 547 | 99 | Output Type | Description | | 
|  | 100 |-------------|-------------| | 
|  | 101 | **mean** | Mean flux across all samples | | 
|  | 102 | **median** | Median flux across all samples | | 
|  | 103 | **quantiles** | 25th, 50th, 75th percentiles | | 
|  | 104 | **fluxes** | Complete flux distributions (all samples, all reactions) | | 
| 492 | 105 | 
| 547 | 106 **Note**: The `fluxes` output can be very large for many samples. Use summary statistics (mean/median/quantiles) unless you need the complete distribution. | 
|  | 107 | 
|  | 108 ## Optimization Methods | 
|  | 109 | 
|  | 110 In alternative to sampling, the tool can perform optimization analyses: | 
| 492 | 111 | 
| 547 | 112 | Method | Description | Output | | 
|  | 113 |--------|-------------|--------| | 
|  | 114 | **FVA** | Flux Variability Analysis | Min/max flux ranges for each reaction | | 
|  | 115 | **pFBA** | Parsimonious FBA | Flux distribution with minimal total flux | | 
|  | 116 | **sensitivity** | Reaction knockout analysis | Biomass impact of single reaction deletions | | 
| 492 | 117 | 
| 547 | 118 ### FVA Optimality Fraction | 
| 492 | 119 | 
| 547 | 120 The `--perc_opt` parameter (default: 0.90) controls the optimality constraint for FVA: | 
|  | 121 - **1.0**: Only optimal solutions (100% of maximum biomass) | 
|  | 122 - **0.90**: Allow suboptimal solutions (≥90% of maximum biomass) | 
|  | 123 - **Lower values**: Explore broader flux ranges | 
|  | 124 | 
|  | 125 ## Output | 
| 492 | 126 | 
| 547 | 127 - `mean.csv`: Mean flux values | 
|  | 128 - `median.csv`: Median flux values | 
|  | 129 - `quantiles.csv`: Flux quantiles (25%, 50%, 75%) | 
|  | 130 - `fluxes/`: Complete flux distributions (if requested) | 
|  | 131 - `fva.csv`: FVA results (if requested) | 
|  | 132 - `pfba.csv`: pFBA results (if requested) | 
|  | 133 - `sensitivity.csv`: Knockout sensitivity analysis (if requested) | 
|  | 134 - `*.log`: Processing log | 
| 492 | 135 | 
|  | 136 ## Examples | 
|  | 137 | 
|  | 138 ### Basic CBS Sampling | 
|  | 139 | 
|  | 140 ```bash | 
| 547 | 141 flux_simulation -ms ENGRO2 \ | 
|  | 142                 -in bounds/*.tsv \ | 
| 492 | 143                 -ni Sample1,Sample2 \ | 
|  | 144                 -a CBS \ | 
|  | 145                 -ns 1000 \ | 
| 547 | 146                 -idop output/ | 
| 492 | 147 ``` | 
|  | 148 | 
| 547 | 149 ### OPTGP Sampling | 
| 492 | 150 | 
|  | 151 ```bash | 
| 547 | 152 flux_simulation -ms ENGRO2 \ | 
|  | 153                 -in bounds/*.tsv \ | 
|  | 154                 -ni Sample1,Sample2 \ | 
|  | 155                 -a OPTGP \ | 
|  | 156                 -ns 1000 \ | 
|  | 157                 -th 200 \ | 
|  | 158                 -idop output/ | 
|  | 159 ``` | 
| 492 | 160 | 
| 547 | 161 ### Custom Model with CBS Sampling | 
| 492 | 162 | 
| 547 | 163 ```bash | 
|  | 164 flux_simulation -ms Custom \ | 
|  | 165                 -mo custom_model.xml \ | 
|  | 166                 -in bounds/*.tsv \ | 
|  | 167                 -ni Sample1 \ | 
|  | 168                 -a CBS \ | 
|  | 169                 -ns 2000 \ | 
|  | 170                 -idop output/ | 
| 492 | 171 ``` | 
|  | 172 | 
|  | 173 ## Troubleshooting | 
|  | 174 | 
| 547 | 175 | Error | Solution | | 
|  | 176 |-------|----------| | 
|  | 177 | "GLPK solver failed" | Install GLPK libraries | | 
|  | 178 | "Model infeasible" | Check bounds constraints | | 
| 492 | 179 | 
|  | 180 ## See Also | 
|  | 181 | 
| 547 | 182 - [RAS to Bounds](tools/ras-to-bounds) | 
|  | 183 - [Flux to Map](tools/flux-to-map) | 
|  | 184 - [Built-in Models](reference/built-in-models) |