Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BiGG dataset: reversed directionality of some reactions/hyperedges #458

@pietrotraversa

Description

@pietrotraversa

Hello, I saw that you implemented a function to read the BiGG dataset as a directed hypergraph. I have been working with this dataset for some months and I have some comments that hopefully could be useful. I believe that some reactions are not being read with the correct direction in the BiGG dataset.
For example, in the e_coli_core.json model, the reaction “FORt: 1for_c -> 1for_e” is currently read by putting for_c in the head and for_e in the tail of the hyperedge (you can check the correct directionality of this reaction here or here.). This happens because xgi relies just on the stoichiometry weights when reading reactions, indeed r['metabolites']={'for_c': 1.0, 'for_e': -1.0} for FORt. Xgi should also look at the values of r["lower_bound"] and r["upper_bound"]. In the case of FORt the lower_bound= -1000 and upper_bound = 0, indicating that the real orientation of the reaction is the reversed one.
Here is a code I wrote to reorder the direction of the reactions:

def reorder_reactions_df(reactions_df, verbose = True):
    reordered = [False]*len(reactions_df)
    for i in reactions_df.index:
        if reactions_df['lower_bound'].get(i)<0 and reactions_df['upper_bound'].get(i)<=0: # so the direction is <---
            mets = reactions_df['metabolites'][i].keys()
            for met in mets:
                reactions_df['metabolites'][i][met] *= -1  ## now the direction is correct
            reordered[i] = True 
            if verbose:
                print(reactions_df['id'][i], 'has been reordered')
            ## update the bound
            reactions_df.loc[i,'lower_bound'] *= -1
            reactions_df.loc[i,'upper_bound'] *= -1
    return reordered

where, I believe, reactions_df is equivalent to the xgi d_model["reactions”].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions