1. Basic operations¶
In [ ]:
Copied!
import pipeGEM as pg
from pipeGEM.data.fetching import list_models, load_remote_model
from pipeGEM.utils import get_subsystems
import cobra
import pipeGEM as pg
from pipeGEM.data.fetching import list_models, load_remote_model
from pipeGEM.utils import get_subsystems
import cobra
Get model from BiGG or Metabolic atlas¶
In [3]:
Copied!
model_list = list_models(organism="E. coli")
model_list = list_models(organism="E. coli")
In [4]:
Copied!
model_list.head()
model_list.head()
Out[4]:
| id | organism | reaction_count | metabolite_count | gene_count | database | |
|---|---|---|---|---|---|---|
| 0 | e_coli_core | Escherichia coli str. K-12 substr. MG1655 | 95 | 72 | 137 | BiGG |
| 2 | iAF1260 | Escherichia coli str. K-12 substr. MG1655 | 2382 | 1668 | 1261 | BiGG |
| 3 | iAF1260b | Escherichia coli str. K-12 substr. MG1655 | 2388 | 1668 | 1261 | BiGG |
| 11 | iAPECO1_1312 | Escherichia coli APEC O1 | 2735 | 1942 | 1313 | BiGG |
| 13 | iB21_1397 | Escherichia coli BL21(DE3) | 2741 | 1943 | 1337 | BiGG |
In [5]:
Copied!
ecoli = load_remote_model("e_coli_core")
ecoli = load_remote_model("e_coli_core")
Set parameter Username Academic license - for non-commercial use only - expires 2024-06-25
In [6]:
Copied!
ecoli
ecoli
Out[6]:
| Name | e_coli_core |
| Memory address | 286c3ad3940 |
| Number of metabolites | 72 |
| Number of reactions | 95 |
| Number of genes | 137 |
| Number of groups | 0 |
| Objective expression | 1.0*BIOMASS_Ecoli_core_w_GAM - 1.0*BIOMASS_Ecoli_core_w_GAM_reverse_712e5 |
| Compartments | extracellular space, cytosol |
Create Model object¶
In [7]:
Copied!
pg_mod = pg.Model(model=ecoli, name_tag="ecoli")
pg_mod = pg.Model(model=ecoli, name_tag="ecoli")
In [8]:
Copied!
pg_mod
pg_mod
Out[8]:
| Name | e_coli_core |
| Memory address | 286c3ad3940 |
| Number of metabolites | 72 |
| Number of reactions | 95 |
| Number of genes | 137 |
| Number of groups | 0 |
| Objective expression | 1.0*BIOMASS_Ecoli_core_w_GAM - 1.0*BIOMASS_Ecoli_core_w_GAM_reverse_712e5 |
| Compartments | extracellular space, cytosol |
In [9]:
Copied!
# basic information
pg_mod.n_rxns, pg_mod.n_genes, pg_mod.n_mets
# basic information
pg_mod.n_rxns, pg_mod.n_genes, pg_mod.n_mets
Out[9]:
(95, 137, 72)
In [10]:
Copied!
# flux analysis using get_flux
pFBA_result = pg_mod.do_flux_analysis(method="pFBA")
# flux analysis using get_flux
pFBA_result = pg_mod.do_flux_analysis(method="pFBA")
In [11]:
Copied!
pFBA_result
pFBA_result
Out[11]:
FBA_Analysis at 0x286c4e2ece0
-----------
Parameters:
{'solver': 'gurobi', 'name': 'ecoli'}
-----------
Result keys:
solution, flux_df
In [12]:
Copied!
pFBA_result.plot(rxn_ids=["PFK", "PGI", "PGK"], aspect=1)
pFBA_result.plot(rxn_ids=["PFK", "PGI", "PGK"], aspect=1)
Use index as the reaction IDs
C:\Users\qwert\miniconda3\envs\py310\lib\site-packages\seaborn\axisgrid.py:118: UserWarning: The figure layout has changed to tight self._figure.tight_layout(*args, **kwargs)
In [13]:
Copied!
# perform flux sampling
sampling_result = pg_mod.do_flux_analysis(method="sampling", n=30)
# perform flux sampling
sampling_result = pg_mod.do_flux_analysis(method="sampling", n=30)
Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpulgyhdc7.lp Reading time = 0.00 seconds : 73 rows, 190 columns, 722 nonzeros
In [16]:
Copied!
sampling_result.flux_df
sampling_result.flux_df
Out[16]:
| PFK | PFL | PGI | PGK | PGL | ACALD | AKGt2r | PGM | PIt2r | ALCD2x | ... | MALS | MALt2_2 | MDH | ME1 | ME2 | NADH16 | NADTRHD | NH4t | O2t | PDH | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 8.136455 | 2.012919 | 7.306230 | -15.589323 | 1.481313 | -0.030135 | -0.200670 | -14.596565 | 2.441216 | -0.030048 | ... | 0.169376 | 0.0 | 3.109480 | 0.135734 | 2.319586 | 33.497332 | 3.471805 | 3.653353 | 19.446378 | 7.417451 |
| 1 | 8.954002 | 0.240421 | 8.366933 | -17.139615 | 1.158407 | -0.709859 | -0.104804 | -16.124940 | 2.495111 | -0.669748 | ... | 0.089351 | 0.0 | 2.147939 | 0.824229 | 2.153128 | 34.876927 | 1.498010 | 3.771994 | 19.956436 | 10.998865 |
| 2 | 10.096441 | 1.250305 | 2.093831 | -15.423786 | 7.625897 | -1.420546 | -0.194995 | -14.443195 | 2.411297 | -0.901694 | ... | 0.595585 | 0.0 | 2.347636 | 0.477438 | 2.466342 | 42.375032 | 15.547232 | 3.600201 | 23.535431 | 9.260710 |
| 3 | 12.278966 | 0.235281 | 3.851723 | -16.069436 | 5.908252 | -1.404621 | -0.067023 | -15.083927 | 2.423389 | -1.049668 | ... | 0.209606 | 0.0 | 1.465244 | 0.540197 | 2.646111 | 39.958497 | 8.282598 | 3.658258 | 22.200222 | 9.811926 |
| 4 | 11.080502 | 0.382634 | 1.570119 | -15.294609 | 8.178705 | -0.749271 | -0.088928 | -14.311955 | 2.416368 | -0.600418 | ... | 0.048774 | 0.0 | -1.544365 | 2.018775 | 3.254201 | 41.687133 | 12.908287 | 3.715260 | 22.683485 | 9.044146 |
| 5 | 10.019731 | 0.672508 | 7.212477 | -16.935753 | 2.400832 | -0.577644 | -0.121697 | -15.943929 | 2.438920 | -0.400386 | ... | 0.614702 | 0.0 | 2.129748 | 1.471419 | 3.024100 | 39.080042 | 2.129578 | 3.727398 | 22.545303 | 10.239605 |
| 6 | 9.177922 | 0.102155 | 4.994711 | -16.178629 | 4.613388 | -0.648812 | -0.112531 | -15.180693 | 2.453948 | -0.420103 | ... | 0.556610 | 0.0 | 2.220185 | 1.837915 | 1.919416 | 40.870235 | 5.624063 | 3.694209 | 23.145570 | 10.082072 |
| 7 | 9.440105 | 1.299468 | 5.966434 | -16.573700 | 3.682486 | -0.514376 | -0.113538 | -15.577845 | 2.448832 | -0.432155 | ... | 1.301527 | 0.0 | 2.572240 | 1.498822 | 3.187130 | 41.211082 | 11.525291 | 3.988394 | 23.583873 | 10.676144 |
| 8 | 11.580519 | 0.596962 | 5.004591 | -16.488093 | 4.782244 | -0.657669 | -0.025846 | -15.495664 | 2.440406 | -0.182540 | ... | 1.162209 | 0.0 | 2.517418 | 0.959341 | 3.849965 | 44.579464 | 10.242524 | 3.903854 | 25.371990 | 11.093913 |
| 9 | 10.497716 | 0.094072 | 3.729291 | -15.911775 | 5.959669 | -0.458000 | -0.004626 | -14.927270 | 2.420921 | -0.379534 | ... | 1.138196 | 0.0 | 3.617052 | 0.235262 | 2.491668 | 43.527412 | 9.159283 | 3.904477 | 24.366599 | 10.909853 |
| 10 | 8.594738 | 0.334689 | 2.381024 | -15.610308 | 7.398913 | -0.179816 | -0.006238 | -14.623358 | 2.426933 | -0.156647 | ... | 1.720865 | 0.0 | 5.294070 | 0.066960 | 1.124705 | 45.006790 | 15.205796 | 3.948078 | 24.885829 | 10.786646 |
| 11 | 7.676377 | 0.750941 | 1.722096 | -15.458097 | 8.093573 | -0.341925 | -0.125353 | -14.476389 | 2.414043 | -0.160405 | ... | 1.971772 | 0.0 | 1.970178 | 0.911331 | 1.387143 | 37.795696 | 7.086741 | 4.051644 | 20.046288 | 10.385220 |
| 12 | 8.524917 | 2.255143 | 5.266372 | -16.475340 | 4.452593 | -0.190875 | -0.080386 | -15.491631 | 2.418965 | -0.171672 | ... | 1.589978 | 0.0 | 5.985909 | 0.674670 | 0.257122 | 39.626628 | 4.865646 | 3.931122 | 22.477175 | 9.258432 |
| 13 | 8.726486 | 0.508259 | 3.669878 | -15.977336 | 6.073240 | -0.699419 | -0.080289 | -14.989571 | 2.428939 | -0.383230 | ... | 1.065819 | 0.0 | 5.117041 | 0.902220 | 0.648532 | 44.636862 | 18.382548 | 3.801737 | 25.119418 | 10.549767 |
| 14 | 6.530685 | 0.327690 | -2.338757 | -14.052112 | 12.126658 | -0.213595 | -0.036666 | -13.066353 | 2.424003 | -0.041840 | ... | 1.252535 | 0.0 | 2.828086 | 0.193327 | 1.640627 | 46.343355 | 30.033825 | 3.653438 | 24.876430 | 8.596707 |
| 15 | 6.701907 | 1.292554 | -1.448027 | -13.992400 | 11.025024 | -0.248971 | -0.052682 | -13.003240 | 2.432370 | -0.113375 | ... | 2.364627 | 0.0 | 3.334523 | 1.163366 | 0.846579 | 40.828698 | 13.248844 | 3.626366 | 21.904270 | 8.618416 |
| 16 | 6.683623 | 0.504603 | -0.262243 | -14.296111 | 9.778741 | -0.500560 | -0.231228 | -13.313125 | 2.417187 | -0.279287 | ... | 2.655525 | 0.0 | 4.267146 | 1.233703 | 0.397984 | 41.314863 | 14.382960 | 3.805572 | 22.279086 | 9.908399 |
| 17 | 6.321001 | 0.139619 | 0.233939 | -14.847214 | 9.578719 | -0.376581 | -0.068872 | -13.792437 | 2.593721 | -0.046214 | ... | 2.686600 | 0.0 | 4.416011 | 0.699252 | 1.904393 | 45.926038 | 13.263607 | 3.916039 | 25.129547 | 11.359474 |
| 18 | 7.468760 | 0.135630 | 2.318945 | -15.474716 | 7.454056 | -0.110775 | -0.018750 | -14.419006 | 2.596017 | -0.050667 | ... | 3.841531 | 0.0 | 5.192882 | 0.659422 | 3.324699 | 45.758452 | 10.246609 | 3.851713 | 25.546962 | 12.866478 |
| 19 | 8.635064 | 1.334673 | 4.841663 | -16.183376 | 4.788767 | -0.164825 | -0.289537 | -15.197778 | 2.423608 | -0.014169 | ... | 4.070242 | 0.0 | 7.656381 | 0.084117 | 2.733826 | 44.965515 | 4.182371 | 3.599911 | 25.684798 | 13.040156 |
| 20 | 7.438722 | 0.834091 | 3.471059 | -15.968861 | 6.320180 | -0.535849 | -0.297572 | -14.966188 | 2.465596 | -0.082465 | ... | 2.921712 | 0.0 | 6.315916 | 0.858168 | 0.094941 | 41.211653 | 4.690610 | 3.717724 | 22.779483 | 11.600635 |
| 21 | 9.932326 | 0.056536 | 2.985607 | -15.496409 | 6.612082 | -0.549095 | -0.380374 | -14.501688 | 2.446043 | -0.262910 | ... | 3.255248 | 0.0 | 6.487042 | 0.544322 | 0.925062 | 42.903789 | 4.951957 | 3.762972 | 23.802483 | 12.432069 |
| 22 | 5.559067 | 1.137912 | -0.892495 | -14.122291 | 10.432131 | -0.376143 | -0.008757 | -13.137774 | 2.420949 | -0.341187 | ... | 3.283372 | 0.0 | 6.310739 | 0.539467 | 0.726783 | 45.670989 | 15.880548 | 3.758344 | 24.982303 | 10.684963 |
| 23 | 6.801159 | 2.040517 | 2.467637 | -15.440833 | 7.197741 | -0.151915 | -0.053099 | -14.448949 | 2.439065 | -0.133132 | ... | 3.841465 | 0.0 | 7.420246 | 0.067719 | 1.898980 | 44.420136 | 9.915391 | 3.759556 | 24.982808 | 11.104344 |
| 24 | 11.726714 | 0.506196 | 2.881029 | -15.507101 | 6.735412 | -0.676988 | -0.173926 | -14.521893 | 2.422651 | -0.103889 | ... | 2.617814 | 0.0 | 6.002064 | 0.195729 | 0.973592 | 42.200157 | 8.580079 | 3.690792 | 23.376864 | 11.512099 |
| 25 | 8.189568 | 3.062280 | 2.755845 | -15.465524 | 6.863114 | -0.817450 | -0.116705 | -14.477624 | 2.429270 | -0.223582 | ... | 3.882292 | 0.0 | 6.464094 | 1.325315 | 0.271023 | 38.977847 | 6.716438 | 3.782454 | 21.577993 | 10.135452 |
| 26 | 7.198730 | 2.965524 | 3.107013 | -15.707176 | 6.583788 | -0.366566 | -0.054003 | -14.722509 | 2.421320 | -0.273997 | ... | 3.889910 | 0.0 | 8.913350 | 0.130629 | 1.065421 | 44.957756 | 12.568777 | 3.672070 | 25.588623 | 11.036387 |
| 27 | 8.336019 | 0.833860 | 7.311014 | -16.956838 | 2.292328 | -0.589042 | -0.070404 | -15.968241 | 2.430983 | -0.553924 | ... | 2.688126 | 0.0 | 6.631404 | 0.300389 | 2.495469 | 42.298245 | 9.646642 | 3.632546 | 24.518691 | 12.805026 |
| 28 | 9.583324 | 0.424274 | 5.310166 | -16.373247 | 4.347281 | -0.367505 | -0.011608 | -15.380114 | 2.442137 | -0.298192 | ... | 2.525792 | 0.0 | 2.957092 | 2.228504 | 3.623146 | 44.355802 | 8.690727 | 3.651118 | 25.319376 | 12.800113 |
| 29 | 12.649507 | 0.188138 | 6.671566 | -16.752808 | 2.932795 | -0.277455 | -0.006899 | -15.769149 | 2.418841 | -0.178576 | ... | 2.208087 | 0.0 | 2.805009 | 0.115785 | 4.507240 | 39.284972 | 4.158298 | 3.606105 | 22.252459 | 12.420734 |
30 rows × 95 columns
Create Group object¶
In [17]:
Copied!
from pipeGEM.utils import random_perturb
from pipeGEM.utils import random_perturb
In [18]:
Copied!
# create different models
models = [random_perturb(ecoli,
in_place=False,
structure_ratio=0.8,
constr_ratio=0.8,
random_state=i) for i in range(9)]
# create different models
models = [random_perturb(ecoli,
in_place=False,
structure_ratio=0.8,
constr_ratio=0.8,
random_state=i) for i in range(9)]
Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpc1033azf.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmp3ahmn46r.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpgzsmgof8.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpgaz934us.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpweuxq9_q.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpcdcu6f4_.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpysqt70xh.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpmq5rm20f.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmpzcknlua9.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros
In [19]:
Copied!
# The first way to initialize Group is to use a dict of cobra.model dicts (str as keys)
grp = pg.Group({"G1": {f"m{i+1}": models[i] for i in range(3)},
"G2": {f"m{i+1}": models[i] for i in range(3, 6)},
"G3": {f"m{i+1}": models[i] for i in range(6, 9)}}, name_tag="group")
# The first way to initialize Group is to use a dict of cobra.model dicts (str as keys)
grp = pg.Group({"G1": {f"m{i+1}": models[i] for i in range(3)},
"G2": {f"m{i+1}": models[i] for i in range(3, 6)},
"G3": {f"m{i+1}": models[i] for i in range(6, 9)}}, name_tag="group")
In [20]:
Copied!
# browse the group table
grp.get_info(features=["group_name", "n_rxns", "n_mets", "n_genes"])
# browse the group table
grp.get_info(features=["group_name", "n_rxns", "n_mets", "n_genes"])
Out[20]:
| group_name | n_rxns | n_mets | n_genes | |
|---|---|---|---|---|
| m1 | G1 | 71 | 72 | 95 |
| m2 | G1 | 69 | 72 | 94 |
| m3 | G1 | 65 | 67 | 83 |
| m4 | G2 | 63 | 69 | 85 |
| m5 | G2 | 76 | 72 | 122 |
| m6 | G2 | 74 | 72 | 112 |
| m7 | G3 | 69 | 69 | 107 |
| m8 | G3 | 71 | 70 | 94 |
| m9 | G3 | 66 | 70 | 92 |
In [21]:
Copied!
# The second way to initialize Group is to use a dict of pipeGEM.Model lists
grp = pg.Group({"G1": [pg.Model(f"m{i+1}", models[i]) for i in range(3)],
"G2": [pg.Model(f"m{i+1}", models[i]) for i in range(3, 6)],
"G3": [pg.Model(f"m{i+1}", models[i]) for i in range(6, 9)]}, name_tag="group")
# The second way to initialize Group is to use a dict of pipeGEM.Model lists
grp = pg.Group({"G1": [pg.Model(f"m{i+1}", models[i]) for i in range(3)],
"G2": [pg.Model(f"m{i+1}", models[i]) for i in range(3, 6)],
"G3": [pg.Model(f"m{i+1}", models[i]) for i in range(6, 9)]}, name_tag="group")
In [22]:
Copied!
# This should return the same result with the first case
grp.get_info(features=["group_name", "n_rxns", "n_mets", "n_genes"])
# This should return the same result with the first case
grp.get_info(features=["group_name", "n_rxns", "n_mets", "n_genes"])
Out[22]:
| group_name | n_rxns | n_mets | n_genes | |
|---|---|---|---|---|
| m1 | G1 | 71 | 72 | 95 |
| m2 | G1 | 69 | 72 | 94 |
| m3 | G1 | 65 | 67 | 83 |
| m4 | G2 | 63 | 69 | 85 |
| m5 | G2 | 76 | 72 | 122 |
| m6 | G2 | 74 | 72 | 112 |
| m7 | G3 | 69 | 69 | 107 |
| m8 | G3 | 71 | 70 | 94 |
| m9 | G3 | 66 | 70 | 92 |
Group operations¶
In [23]:
Copied!
# indexing
grp["m1"]
# indexing
grp["m1"]
Out[23]:
| Name | e_coli_core |
| Memory address | 286c2ef5b10 |
| Number of metabolites | 72 |
| Number of reactions | 71 |
| Number of genes | 95 |
| Number of groups | 0 |
| Objective expression | 1.0*BIOMASS_Ecoli_core_w_GAM - 1.0*BIOMASS_Ecoli_core_w_GAM_reverse_712e5 |
| Compartments | extracellular space, cytosol |
In [24]:
Copied!
# select multiple models
grp[["m1", "m2", "m4"]].get_info()
# select multiple models
grp[["m1", "m2", "m4"]].get_info()
Out[24]:
| group_name | n_rxns | n_mets | n_genes | |
|---|---|---|---|---|
| m1 | G1 | 71 | 72 | 95 |
| m2 | G1 | 69 | 72 | 94 |
| m4 | G2 | 63 | 69 | 85 |
In [25]:
Copied!
# aggregate models with thier group name into a dict
grp_dic = grp.aggregate_models("group_name")
grp_dic
# aggregate models with thier group name into a dict
grp_dic = grp.aggregate_models("group_name")
grp_dic
create a new group containing {'m1': pipeGEM.Model [m1] (g,m,r)=(95, 72, 71)
, 'm2': pipeGEM.Model [m2] (g,m,r)=(94, 72, 69)
, 'm3': pipeGEM.Model [m3] (g,m,r)=(83, 67, 65)
}
create a new group containing {'m4': pipeGEM.Model [m4] (g,m,r)=(85, 69, 63)
, 'm5': pipeGEM.Model [m5] (g,m,r)=(122, 72, 76)
, 'm6': pipeGEM.Model [m6] (g,m,r)=(112, 72, 74)
}
create a new group containing {'m7': pipeGEM.Model [m7] (g,m,r)=(107, 69, 69)
, 'm8': pipeGEM.Model [m8] (g,m,r)=(94, 70, 71)
, 'm9': pipeGEM.Model [m9] (g,m,r)=(92, 70, 66)
}
Out[25]:
{'G1': Group [G1] containing 3 models,
'G2': Group [G2] containing 3 models,
'G3': Group [G3] containing 3 models}
In [26]:
Copied!
grp_dic["G2"].get_info()
grp_dic["G2"].get_info()
Out[26]:
| group_name | n_rxns | n_mets | n_genes | |
|---|---|---|---|---|
| m4 | G2 | 63 | 69 | 85 |
| m5 | G2 | 76 | 72 | 122 |
| m6 | G2 | 74 | 72 | 112 |
In [27]:
Copied!
# The models inside the pg.Group are pg.Models
isinstance(grp_dic["G2"]["m4"], pg.Model)
# The models inside the pg.Group are pg.Models
isinstance(grp_dic["G2"]["m4"], pg.Model)
Out[27]:
True
In [28]:
Copied!
grp = pg.Group([pg_mod, pg_mod.copy()], )
pfba_result = grp.do_flux_analysis(method="pFBA")
grp = pg.Group([pg_mod, pg_mod.copy()], )
pfba_result = grp.do_flux_analysis(method="pFBA")
Read LP format model from file C:\Users\qwert\AppData\Local\Temp\tmphgv0f41t.lp Reading time = 0.01 seconds : 72 rows, 190 columns, 720 nonzeros
In [29]:
Copied!
pfba_result
pfba_result
Out[29]:
FBA_Analysis at 0x286c77fca90
-----------
Parameters:
{'categorical': {'model'}, 'name': 'Unnamed_group', 'group_by': 'model', 'group': {'model': ['ecoli', 'copied_ecoli']}}
-----------
Result keys:
group_annotation, rxn_annotation, flux_df
In [30]:
Copied!
pfba_result.log
pfba_result.log
Out[30]:
{'categorical': {'model'},
'name': 'Unnamed_group',
'group_by': 'model',
'group': {'model': ['ecoli', 'copied_ecoli']}}
In [31]:
Copied!
pfba_result.plot(rxn_ids=["PFK", "PGI", "PGK"],
group_by="model", aspect=1.5, kind="bar")
pfba_result.plot(rxn_ids=["PFK", "PGI", "PGK"],
group_by="model", aspect=1.5, kind="bar")
C:\Users\qwert\miniconda3\envs\py310\lib\site-packages\seaborn\axisgrid.py:118: UserWarning: The figure layout has changed to tight self._figure.tight_layout(*args, **kwargs)
Comparisons¶
In [32]:
Copied!
# compare model components
grp = pg.Group({"G1": [pg.Model(f"m{i+1}", models[i]) for i in range(3)],
"G2": [pg.Model(f"m{i+1}", models[i]) for i in range(3, 6)],
"G3": [pg.Model(f"m{i+1}", models[i]) for i in range(6, 9)]}, name_tag="group")
comparison = grp.compare(method="jaccard")
# compare model components
grp = pg.Group({"G1": [pg.Model(f"m{i+1}", models[i]) for i in range(3)],
"G2": [pg.Model(f"m{i+1}", models[i]) for i in range(3, 6)],
"G3": [pg.Model(f"m{i+1}", models[i]) for i in range(6, 9)]}, name_tag="group")
comparison = grp.compare(method="jaccard")
create a new group containing {'m1': pipeGEM.Model [m1] (g,m,r)=(95, 72, 71)
, 'm2': pipeGEM.Model [m2] (g,m,r)=(94, 72, 69)
, 'm3': pipeGEM.Model [m3] (g,m,r)=(83, 67, 65)
}
create a new group containing {'m4': pipeGEM.Model [m4] (g,m,r)=(85, 69, 63)
, 'm5': pipeGEM.Model [m5] (g,m,r)=(122, 72, 76)
, 'm6': pipeGEM.Model [m6] (g,m,r)=(112, 72, 74)
}
create a new group containing {'m7': pipeGEM.Model [m7] (g,m,r)=(107, 69, 69)
, 'm8': pipeGEM.Model [m8] (g,m,r)=(94, 70, 71)
, 'm9': pipeGEM.Model [m9] (g,m,r)=(92, 70, 66)
}
In [39]:
Copied!
comparison.group_annotation
comparison.group_annotation
Out[39]:
| group_name | 0 | |
|---|---|---|
| 0 | G1 | [m1, m2, m3] |
| 1 | G2 | [m4, m5, m6] |
| 2 | G3 | [m7, m8, m9] |
In [41]:
Copied!
# visualization
comparison.plot(row_color_by="group_name", col_color_by="group_name")
# visualization
comparison.plot(row_color_by="group_name", col_color_by="group_name")
group_name 0 (0.2980392156862745, 0.4470588235294118, 0.690... 1 (0.8666666666666667, 0.5176470588235295, 0.321... 2 (0.3333333333333333, 0.6588235294117647, 0.407...
In [ ]:
Copied!
# data frame showing the jaccard values
comparison
# data frame showing the jaccard values
comparison
In [42]:
Copied!
comparison = grp.compare(method="jaccard", group_by=None)
comparison = grp.compare(method="jaccard", group_by=None)
In [44]:
Copied!
comparison.group_annotation
comparison.group_annotation
Out[44]:
| n_rxns | n_genes | n_mets | group_name | |
|---|---|---|---|---|
| m1 | 71 | 95 | 72 | G1 |
| m2 | 69 | 94 | 72 | G1 |
| m3 | 65 | 83 | 67 | G1 |
| m4 | 63 | 85 | 69 | G2 |
| m5 | 76 | 122 | 72 | G2 |
| m6 | 74 | 112 | 72 | G2 |
| m7 | 69 | 107 | 69 | G3 |
| m8 | 71 | 94 | 70 | G3 |
| m9 | 66 | 92 | 70 | G3 |
In [45]:
Copied!
comparison.plot(annot=True, row_color_by="group_name", col_color_by="group_name")
comparison.plot(annot=True, row_color_by="group_name", col_color_by="group_name")
group_name m1 (0.2980392156862745, 0.4470588235294118, 0.690... m2 (0.2980392156862745, 0.4470588235294118, 0.690... m3 (0.2980392156862745, 0.4470588235294118, 0.690... m4 (0.8666666666666667, 0.5176470588235295, 0.321... m5 (0.8666666666666667, 0.5176470588235295, 0.321... m6 (0.8666666666666667, 0.5176470588235295, 0.321... m7 (0.3333333333333333, 0.6588235294117647, 0.407... m8 (0.3333333333333333, 0.6588235294117647, 0.407... m9 (0.3333333333333333, 0.6588235294117647, 0.407...
In [46]:
Copied!
comparison = grp.compare(method="PCA", group_by=None, n_components=3)
comparison = grp.compare(method="PCA", group_by=None, n_components=3)
In [47]:
Copied!
comparison.plot(file_name="PCA.png", prefix="")
comparison.plot(file_name="PCA.png", prefix="")
saving PCA.png
In [48]:
Copied!
comparison = grp.compare(group_by="group_name", method="num")
comparison = grp.compare(group_by="group_name", method="num")
In [49]:
Copied!
comparison.plot(name_order="default")
comparison.plot(name_order="default")