10. freeflux¶
10.1. Submodules¶
10.2. Attributes¶
10.3. Classes¶
Define Metabolite object which constitutes a Reaction. |
|
Define Reaction object which constitute a Model. |
|
Model class is the fundamental class of FreeFlux hosting operations for 13C MFA. |
|
Define EMU (i.e., elementary metabolite unit) object and its operations. |
|
Define MDV (i.e., mass isotopomer distribution vector) object and its operations. |
10.4. Functions¶
|
Calculate the MDV of an unlabeled fragment. |
|
Calculate the MDV of a fragment from labeled substrate. |
|
Perform convolution between two MDVs. |
10.5. Package Contents¶
- class freeflux.Metabolite(id, atoms=None)[source]¶
Define Metabolite object which constitutes a Reaction.
Metabolites are considered identical when they have the same IDs and atoms.
- Parameters:
- atoms_info¶
equivalent => coefficient, e.g., {‘abcd’: 1.0} or {‘abcd’: 0.5, ‘dcba’: 0.5}.
- Type:
- id¶
- atoms = None¶
- host_reactions = None¶
- __eq__(other)[source]¶
- Parameters:
other (Metabolite)
- property atoms_info¶
- property n_carbons¶
- class freeflux.Reaction(id, reversible=True)[source]¶
Define Reaction object which constitute a Model.
Duplicate substrates or products could appear in one reaction, but with different atoms.
- substrates_info¶
Index are substrate IDs (there could be duplicate substrates), columns are Metabolite object and its stoichiometric number.
- Type:
df
- products_info¶
Index are product IDs (there could be duplicate products), columns are Metabolite object and stoichiometrc number.
- Type:
df
- _substrates_atom_mapping¶
For example, reactants like: A({‘ab’: 0.5, ‘ba’: 0.5}) + B({‘c’: 1}) will be transformed to [{‘a’: [A, 1, 0.5], ‘b’: [A, 2, 0.5], ‘c’: [C, 1, 1]},
{‘a’: [A, 2, 0.5], ‘b’: [A, 1, 0.5], ‘a’: [C, 1, 1]}]
- _products_atom_mapping¶
For example, reactants like: A({‘ab’: 0.5, ‘ba’: 0.5}) + B({‘c’: 1}) will be transformed to [{‘a’: [A, 1, 0.5], ‘b’: [A, 2, 0.5], ‘c’: [C, 1, 1]},
{‘a’: [A, 2, 0.5], ‘b’: [A, 1, 0.5], ‘a’: [C, 1, 1]}]
- flux(fflux and bflux for reversible reaction)¶
Reaction flux (forward flux and backward flux for reversible reaction).
- Type:
Symbol
- id¶
- reversible = True¶
- substrates_info¶
- products_info¶
- host_models = None¶
- add_substrates(substrates, stoichiometry)[source]¶
- Parameters:
substrates (Metabolite or list of Metabolite)
stoichiometry (float or list of float) – Stoichiometric number(s) of corresponding substrate(s).
- add_products(products, stoichiometry)[source]¶
- Parameters:
products (Metabolite or list of Metabolite.)
stoichiometry (float or list of float) – stoichiometric number(s) of corresponding product(s).
- remove_substrates(substrates)[source]¶
- Parameters:
substrates (Metabolite or list of Metabolite)
- remove_products(products)[source]¶
- Parameters:
products (Metabolite or list of Metabolite)
- property substrates¶
- property products¶
- property substrates_with_atoms¶
- property products_with_atoms¶
- _atom_mapping(reactant)[source]¶
- Parameters:
reactant (str,) – ‘substrate’ or ‘product’
Notes
Reactants like: A({‘ab’: 0.5, ‘ba’: 0.5}) + B({‘c’: 1}) will be transformed to [{‘a’: [A, 1, 0.5], ‘b’: [A, 2, 0.5], ‘c’: [C, 1, 1]},
{‘a’: [A, 2, 0.5], ‘b’: [A, 1, 0.5], ‘a’: [C, 1, 1]}].
- property _substrates_atom_mapping¶
- property _products_atom_mapping¶
- class freeflux.Model(name='unnamed')[source]¶
Model class is the fundamental class of FreeFlux hosting operations for 13C MFA. A model can be built by adding reactions one by one or reading set of reactions from .tsv or .xlsx file.
- Parameters:
name (str) – Model name.
- reactions_info¶
Reaction ID => Reaction.
- Type:
OrderedDict
- _full_net_stoichiometric_matrix[source]¶
Complete stoichiometric matrix for net reaction with all metabolites in rows, net reactions in columns.
- Type:
df
- _full_total_stoichiometric_matrix[source]¶
Complete stoichiometric matrix for total reaction with all metabolites in rows, total reactions in columns.
- Type:
df
- metabolite_adjacency_matrix¶
Metabolite adjacency matrix (MAM). Metabolites with atoms are in index and columns (no duplicates). List of Reactions are in cells if reactions exists between (sub, pro), [] otherwise.
- Type:
df
- net_fluxes_range¶
Reaction ID => estimeted [lb, ub]. All required net fluxes are included.
- Type:
- concentrations¶
Concentrations, metabolite ID => float.
- Type:
ser
- concentrations_range¶
Metabolite ID => [lb, ub]. All required concentrations are included.
- Type:
- total_fluxes¶
Total fluxes, fluxe ID (e.g., ‘v1_f’ or ‘v2’) => float.
- Type:
ser
- substrate_MDVs_der_p¶
Substrate EMU => derivatives of substrate MDV w.r.t. variables in shape of (len(MDV), # of vars). # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.
- Type:
- initial_matrix_Xs¶
Size => initial MDVs of EMU in matrix X, i.e., the natural MDVs. The initial MDV matrix has the same shape of matrix X.
- Type:
- initial_matrix_Ys¶
Size => initial MDVs of EMU in matrix Y, i.e., either natural MDVs or labeled MDVs. The initial MDV matrix has the same shape of matrix Y.
- Type:
- initial_matrix_Xs_der_p, initial_matrix_Ys_der_p
Size => 3-D array in shape of (# of vars), X(Y).shape[0], X(Y).shape[1]) which is the initial MDV derivatives of EMUs in matrix X(Y) w.r.t. variables. # of vars = # of free fluxes + # of concentrations for INST MFA.
- Type:
- matrix_As, matrix_Bs
Size => [lambdified matrix A(B), [flux IDs], [EMUs]].
- Type:
- matrix_As_der_p, matrix_Bs_der_p
Size => 3-D array in shape of (# of vars, A(B).shape[0], A(B).shape[1]) which is the derivatives of matrix A(B) w.r.t. variables. # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.
- Type:
- matrix_Ms_der_p¶
Size => 3-D array in shape of (# of vars, M.shape[0], M.shape[1]), which is the derivatives of matrix M w.r.t. variables. # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.
- Type:
- label_atom¶
Labeled atom, i.e., the base atom in MDV, currently only supprts “H”, “C” and “N”.
- Type:
- measured_MDVs_inv_cov¶
Inversed covariance matrix of measured MDVs with variances on the diagnol, other elements are zero.
- Type:
array
- measured_fluxes_inv_cov¶
Inversed covariance matrix of measured fluxes with variances on the diagnol, other elements are zero.
- Type:
array
- measured_fluxes_der_p¶
Derivative of measured fluxes w.r.t. variables in shape of (# of measured fluxes, # of vars), # of vars = # of free fluxes for steady state MFA; # of vars = # of free fluxes + # of concentrations for INST MFA.
- Type:
array
- measured_inst_MDVs¶
EMU ID (metabolite ID + ‘_’ + atom NOs) => {timepoint => [means of MDV, SDs of MDV]}.
- Type:
- measured_inst_MDVs_inv_cov¶
Inversed covariance matrix of measured concatenated MDVs with variances on the diagnol, other elements are zero. Timepoints are concatenated except t0.
- Type:
array
- null_space¶
Null space of total stoichiometric matrix.
- Type:
2-D array
- transform_matrix¶
Transform matrix letting vnet = transform_matrix*v.
- Type:
2-D array
- name = 'unnamed'¶
- reactions_info¶
- target_EMUs = []¶
- timepoints = []¶
- substrate_MDVs¶
- substrate_MDVs_der_p¶
- EAMs¶
- matrix_As¶
- matrix_Bs¶
- matrix_Ms¶
- matrix_As_der_p¶
- matrix_Bs_der_p¶
- matrix_Ms_der_p¶
- null_space = None¶
- transform_matrix = None¶
- initial_matrix_Xs¶
- initial_matrix_Ys¶
- initial_matrix_Xs_der_p¶
- initial_matrix_Ys_der_p¶
- initial_sim_MDVs¶
- label_atom = None¶
- labeling_strategy¶
- measured_MDVs¶
- measured_fluxes¶
- measured_inst_MDVs¶
- measured_MDVs_inv_cov = None¶
- measured_inst_MDVs_inv_cov = None¶
- measured_fluxes_inv_cov = None¶
- measured_fluxes_der_p = None¶
- unbalanced_metabolites¶
- net_fluxes_bounds¶
- net_fluxes_range¶
- concentrations_bounds¶
- concentrations_range¶
- total_fluxes¶
- concentrations¶
- read_from_file(file)[source]¶
- Parameters:
file (file path) –
tsv or excel file with reactions with fields “reaction_ID”, “substrate_IDs(atom)”, “product_IDs(atom)” and “reversibility”.
Header line starts with “#”, and will be skiped.
- property metabolites_info¶
returns: metabsInfo – metabolite ID => list of Metabolites :rtype: dict
- property metabolites¶
- property metabolites_with_atoms¶
- property reactions¶
- property n_metabolites¶
- property n_reactions¶
- _full_net_stoichiometric_matrix(metabolites, reactions)[source]¶
Re-estimate stoichiometric matrix if metabolites or reactions changes.
- _full_total_stoichiometric_matrix(metabolites, reactions)[source]¶
Re-estimate stoichiometric matrix if metabolites or reactions changes.
- property end_substrates¶
- property end_products¶
- property netfluxids¶
- property totalfluxids¶
- property concids¶
- property metabolite_adjacency_matrix¶
- returns: MAM – Metabolite adjacency matrix (MAM). Metabolites with atoms are in index and columns
(no duplicates). List of Reactions are in cells if reactions exists between sub (index) and pro (columns), [] otherwise
- Return type:
df
- _replace_list_item(iterable, toReplace, value)[source]¶
- Parameters:
iterable (iterable) – Iterable can be nested.
toReplace (scalar) – Value to be replaced.
value (scalar) – Value that replaces toReplace.
- Returns:
newLst – New tuple with toReplace recursively replaced.
- Return type:
- _uniquify_dataFrame_index(df)[source]¶
- Parameters:
df (df) – DataFrame to be uniquify.
- Returns:
uniqueDf – DataFrame with duplicate rows combined (summated).
- Return type:
df
- _combine_equivalent_EMUs(EAMs)[source]¶
- Parameters:
EAMs (dict of df) – Size => original EMU adjacency matrix (EAM), cells are symbolic expression of flux.
- Returns:
combinedEAMs – Size => EAM with equivalent EMUs combined, cells are symbolic expression of flux.
- Return type:
dict df
- get_emu_adjacency_matrices(iniEMU, lump=True)[source]¶
- Parameters:
- Returns:
EAMs – Size => EMU adjacency matrix (EAM) after lumping of linear EMUs and combination of equivalent EMUs. Index and columns are EMUs, cells are symbolic expression of flux.
- Return type:
dict of df
Notes
EMUs in sequential reactions can not be lumped in transient MFA.
- _merge_EAMs(EAM1, EAM2)[source]¶
- Parameters:
EAM1 (df) – EMU adjacency matrix (EAM) to merge
EAM2 (df) – EMU adjacency matrix (EAM) to merge
- Returns:
mergedEAM – merged EAM
- Return type:
df
- _decompose_network(metabolites, atom_nos, lump=True, n_jobs=1)[source]¶
- Parameters:
metabolites (list of str) – List of metabolite IDs from which initial EMU will be generated to start the decomposition.
atom_nos (list of str) – Atom NOs of corresponding metabolites, len(atom_nos) should be equal to len(metabolites).
lump (bool) – Whether to lump linear EMUs.
n_jobs (int) – # of jobs to run in parallel.
- Returns:
mergedEAMs – Size => merged EMU adjacency matrix (EAM).
- Return type:
dict of df
Notes
EMUs in sequential reactions can not be lumped in transient MFA.
- decompose_network(ini_emus, lump=True, n_jobs=1)[source]¶
- Parameters:
- Returns:
mergedEAMs – Size => merged EMU adjacency matrix (EAM)
- Return type:
dict of df
Notes
EMUs in sequential reactions can not be lumped in transient MFA.
- class freeflux.EMU(id, metabolite, atom_nos)[source]¶
Define EMU (i.e., elementary metabolite unit) object and its operations.
EMUs in the same metabolite and with the same atom NOs are considered as identical, while metabolites which they derived from could be different.
EMUs can be compared based self.metabolite_id and self.atom_nos. EMU and iterable object of EMUs can also be compared. In this case EMU will be put into the same iterable object with single item, and comparison between two iterables are performed.
Currently only binary equivalents are considered.
- Parameters:
- metabolite¶
Which metabolite the EMU comes from.
- Type:
- id¶
- size¶
- property equivalent_atom_nos¶
returns: equivAtomNOs – Equivalent atom NOs, sorted by number. :rtype: list of int or None
- property equivalent¶
returns: EMU – Equivalent of current EMU. :rtype: EMU
- class freeflux.MDV(fractions, nonnegative=True, normalize=True, base_atom='C')[source]¶
Define MDV (i.e., mass isotopomer distribution vector) object and its operations.
Convolution between mdv1 and mdv2 can be performed in three ways: 1. mdv1.conv(mdv2); 2. mdv1*mdv2; 3. mdv.conv(mdv1, mdv2).
The zero element for convolution is MDV([0]), and the identity element is MDV([1]).
Scalar multiplication (a*mdv) and MDV addition (mdv1 + mdv2) are also supported. In these cases, the resulting MDV are not automatically normalized.
In addition to C, MDV can be built based on H, N, O, Si, and S.
- Parameters:
- value¶
MDV vector.
- Type:
array
- value¶
- base_atom = 'C'¶
- correct_for_natural_abundance(atom_dict)[source]¶
- Parameters:
atom_dict (dict) – element needs to be corrected => # of corresponding atoms in metabolite (fragment).
- correct_for_inoculum(fraction)[source]¶
- Parameters:
fraction (float in [0, 1]) – Fraction of inoculum in biomass measured.
- property n_atoms¶
- property fl¶
- fractional_labeling¶
- freeflux.get_natural_MDV(n_atoms, base_atom='C')[source]¶
Calculate the MDV of an unlabeled fragment.
- freeflux.get_substrate_MDV(atom_nos, labeling_pattern, percentage, purity, label_atom='C')[source]¶
Calculate the MDV of a fragment from labeled substrate. Currently this function only supports H, C or N-labeled substrate.
- Parameters:
labeling_pattern (str or list of str) –
Labeling pattern of substrate, ‘0’ for unlabeled atom, ‘1’ for labeled atom, e.g., ‘100000’ for 1-13C glucose.
List if tracer with multiple labeling patterns are used.
Natural substrate (with all ‘0’s) don’t need to be explicitly set.
If str, labeling_pattern should not be natural substrate.
percentage (float or list of float) –
Molar percentage (in range of [0,1]) of corresponding tracer. Sum of percentage should be <= 1, and the rest will be considered as natural substrate.
List if tracer with multiple labeling patterns are used.
If list, len(percentage) should be equal to len(labeling_pattern).
If float, labeling_pattern should not be natural substrate.
purity (float or list of float) –
Labeled atom purity (in range of [0,1]) of corresponding tracer.
List if tracer with multiple labeling patterns are used.
If list, len(purity) should be equal to len(labeling_pattern).
If float, labeling_pattern should not be natural substrate.
label_atom (str) – Labeled atom, i.e., base atom in the MDV. Currently supports only “H”, “C” and “N”.