dexom_python.enum_functions enumeration modules
Submodules
enumeration module
- class dexom_python.enum_functions.enumeration.EnumSolution(solutions, binary, objective_value)[source]
Bases:
objectclass for solutions of enumeration methods
- Parameters:
solutions (list) – A list of pandas dataframes containing flux values with reaction ids as index
binary (list) – A list containing binary arrays of reaction activity (0 for inactive, 1 for active)
objective_value (float) – objective value returned by the solver at the end of the optimization
- dexom_python.enum_functions.enumeration.analyze_div_enum_results(result_path, solution_path, out_path)[source]
This function calculates the average pairwise hamming distance and average next neighbour distance for each iteration - it’s very slow
- Parameters:
result_path (csv results file from diversity-enum) –
solution_path (csv solution file from diversity-enum) –
out_path (path for saving) –
- dexom_python.enum_functions.enumeration.check_reaction_weights(rw)[source]
This function raises a TypeError if the reaction-weight object is not a dictionary or a ValueError if the dictionary contains no nonzero values.
- Parameters:
rw (dict) –
- dexom_python.enum_functions.enumeration.combine_binary_solutions_and_fluxes(sol_path, solution_pattern='*solutions*.csv', out_path='')[source]
Combines several binary solution files into one
- Parameters:
sol_path (str) – folder in which binary solutions are saved
solution_pattern (str) – pattern which is used to find binary solution files
out_path (str) – path to which the combined solutions are saved
- Returns:
uniquesol
- Return type:
pandas.DataFrame
- dexom_python.enum_functions.enumeration.create_enum_variables(model, reaction_weights, eps=0.01, thr=0.001, full=False)[source]
- dexom_python.enum_functions.enumeration.get_recent_solution_and_iteration(dirpath, startsol_num=1, solution_pattern='*solution*.csv')[source]
This functions fetches a solution from a given directory. The solutions are ordered by creation time, and one solution is picked using an exponential distribution (meaning that the most recent solution has the highest probability of being chosen)
- Parameters:
dirpath (str) – a directory containing imat solutions
startsol_num (int) – the number of starting solutions present in the directory
solution_pattern (str) – pattern which is used to find the solution files
- Returns:
solution (a Solution object)
iteration (int) – calculates the current iteration, based on how many solutions are already present in the folder
rxn_enum_functions module
- class dexom_python.enum_functions.rxn_enum_functions.RxnEnumSolution(all_solutions, unique_solutions, all_binary, unique_binary, all_reactions=None, unique_reactions=None, objective_value=-1.0)[source]
Bases:
object
- dexom_python.enum_functions.rxn_enum_functions.rxn_enum(model, reaction_weights, prev_sol=None, rxn_list=None, eps=0.01, thr=0.001, obj_tol=0.001, out_path='enum_rxn', save=False)[source]
Reaction enumeration method
- Parameters:
model (cobrapy Model) –
reaction_weights (dict) – keys = reactions and values = weights
prev_sol (imat Solution object) – an imat solution used as a starting point
rxn_list (list) – a list of reactions on which reaction-enumeration will be performed. By default, all reactions are used
eps (float) – activation threshold in imat
thr (float) – detection threshold of activated reactions
obj_tol (float) – variance allowed in the objective_values of the solutions
out_path (str) – path to which the solutions are saved if save==True
save (bool) – if True, every individual solution is saved in the iMAT solution format
- Returns:
solution
- Return type:
RxnEnumSolution object
icut_functions module
- dexom_python.enum_functions.icut_functions.create_icut_constraint(model, reaction_weights, epsilon, threshold, prev_sol, name, full=False)[source]
Creates an icut constraint on the previously found solution. This solution is excluded from the solution space.
- dexom_python.enum_functions.icut_functions.icut(model, reaction_weights, prev_sol=None, eps=0.01, thr=0.001, obj_tol=0.001, maxiter=10, full=False)[source]
integer-cut method
- Parameters:
model (cobrapy Model) –
reaction_weights (dict) – keys = reactions and values = weights
prev_sol (imat Solution object) – an imat solution used as a starting point
eps (float) – activation threshold in imat
thr (float) – detection threshold of activated reactions
obj_tol (float) – variance allowed in the objective_values of the solutions
maxiter (foat) – maximum number of solutions to check for
full (bool) – if True, carries out integer-cut on all reactions; if False, only on reactions with non-zero weights
- Returns:
solution – In the case of integer-cut, all_solutions and unique_solutions are identical
- Return type:
EnumSolution object
maxdist_functions module
- dexom_python.enum_functions.maxdist_functions.create_maxdist_objective(model, reaction_weights, prev_sol, prev_sol_bin, only_ones=False, full=False)[source]
Create the new objective for the maxdist algorithm. This objective is the minimization of similarity between the binary solution vectors If only_ones is set to False, the similarity will only be calculated with overlapping ones
- dexom_python.enum_functions.maxdist_functions.maxdist(model, reaction_weights, prev_sol=None, eps=0.01, thr=0.001, obj_tol=0.001, maxiter=10, icut=True, full=False, only_ones=False)[source]
- Parameters:
model (cobrapy Model) –
reaction_weights (dict) – keys = reactions and values = weights
prev_sol (imat Solution object) – an imat solution used as a starting point
eps (float) – activation threshold in imat
thr (float) – detection threshold of activated reactions
obj_tol (float) – variance allowed in the objective_values of the solutions
maxiter (foat) – maximum number of solutions to check for
icut (bool) – if True, icut constraints are applied
full (bool) – if True, carries out integer-cut on all reactions; if False, only on reactions with non-zero weights
only_ones (bool) – if True, only the ones in the binary solution are used for distance calculation (as in dexom matlab)
- Returns:
solution
- Return type:
EnumSolution object
diversity_enum_functions module
- dexom_python.enum_functions.diversity_enum_functions.diversity_enum(model, reaction_weights, prev_sol=None, eps=0.01, thr=0.001, obj_tol=0.001, maxiter=10, dist_anneal=0.95, out_path='enum_dexom', icut=True, full=False, save=False)[source]
diversity-based enumeration
- Parameters:
model (cobrapy Model) –
reaction_weights (dict) – keys = reactions and values = weights
prev_sol (Solution instance) – a previous imat solution
eps (float) – activation threshold for highly expressed reactions
thr (float) – detection threshold of activated reactions
obj_tol (float) – variance allowed in the objective_values of the solutions
maxiter (foat) – maximum number of solutions to search for
dist_anneal (float) – parameter which influences the probability of selecting reactions
out_path (str) – path to which the solutions are saved if save==True
icut (bool) – if True, icut constraints are applied
full (bool) – if True, the full-DEXOM implementation is used
save (bool) – if True, every individual solution is saved in the iMAT solution format
- Returns:
solution (an EnumSolution object)
stats (a pandas.DataFrame containing the number of selected reactions and runtime of each iteration)
permutation_functions module
- dexom_python.enum_functions.permutation_functions.permute_genelabels(model, allgenes, geneindex=None, nperms=10, error_tol=10)[source]
This function performs a permutation test in which the labels of gene expression values are randomly shuffled, and then an iMAT solution is computed with the new geneweights.
- Parameters:
model (cobra.Model) – a cobrapy model
allgenes (pandas.Series) – index = gene IDs and values = expression values
geneindex (pandas.Series or None) – index = model gene IDs and values = allgenes gene IDs
nperms (int) – number of permutations to perform
error_tol (int) – maximum number of consecutive failed iterations before interrupting the program
- Returns:
perm_solutions (list of imat solutions)
perm_binary (pandas.Dataframe of binary solutions)
perm_recs (pandas.Dataframe of reaction-weights)
perm_genes (pandas.Dataframe of permuted gene expression values)
riptide_functions module
- dexom_python.enum_functions.riptide_functions.imat_riptide_like(model, reaction_weights=None, objective_direction='max')[source]
Modified version of the integrative Metabolic Analysis Tool with reaction weights. This function is currently still in testing phase.
- Parameters:
model (cobra.Model) – a cobrapy model
reaction_weights (dict) – keys are reaction IDs, values are weights
epsilon (float) – activation threshold for highly expressed reactions
threshold (float) – activation threshold for all reactions
full (bool) – if True, create variables for all reactions. if False, only for reactions with non-zero weights
- Returns:
solution
- Return type:
cobra.Solution