通量变异性分析仅适用于隔室之间的运输反应?

时间:2018-06-07 09:11:24

标签: python cbmpy

我想仅针对选定的反应进行FVA,在我的情况下,隔室之间的运输反应(例如细胞质和线粒体之间)。我知道我可以在selected_reactions中使用doFVA,如下所示:

import cbmpy as cbm

mod = cbm.CBRead.readSBML3FBC('iMM904.xml.gz')

cbm.doFVA(mod, selected_reactions=['R_FORtm', 'R_CO2tm'])

有没有办法获得整个运输反应列表,不仅是我手动添加的两个?我想过 根据结尾tm选择反应但'R_ORNt3m'失败(也可能是其他反应)。

我想与其他人分享这个模型。将信息存储在SBML文件中的最佳方法是什么? 目前,我将信息存储在反应注释中,如下所示 this answer。例如

mod.getReaction('R_FORtm').setAnnotation('FVA', 'yes') 

可以解析。

1 个答案:

答案 0 :(得分:2)

此类任务没有内置功能。正如您已经提到的,依赖ID通常不是一个好主意,因为不同的数据库,模型和组之间可能存在差异(例如,如果有人决定只列举r1rn和/或代谢物的反应从m1mm,基于ID的过滤失败)。相反,人们可以利用物种的compartment场。在CBMPy中,您可以通过

访问物种的隔间
import cbmpy as cbm
import pandas as pd

mod = cbm.CBRead.readSBML3FBC('iMM904.xml.gz')

mod.getSpecies('M_atp_c').getCompartmentId()
# will return 'c'

# run a FBA
cbm.doFBA(mod)

这可用于查找隔室之间的所有通量,因为可以检查其试剂所在的隔室中的每个反应。可能的实现可能如下所示:

def get_fluxes_associated_with_compartments(model_object, compartments, return_values=True):

    # check whether provided compartment IDs are valid
    if not isinstance(compartments, (list, set) or not set(compartments).issubset(model_object.getCompartmentIds())):
        raise ValueError("Please provide valid compartment IDs as a list!")
    else:
        compartments = set(compartments)

    # all reactions in the model
    model_reactions = model_object.getReactionIds()

    # check whether provided compartments are identical with the ones of the reagents of a reaction
    return_reaction_ids = [ri for ri in model_reactions if compartments == set(si.getCompartmentId() for si in
                           model_object.getReaction(ri).getSpeciesObj())]

    # return reaction along with its value
    if return_values:
        return {ri: model_object.getReaction(ri).getValue() for ri in return_reaction_ids}

    # return only a list with reaction IDs
    return return_reaction_ids

因此,您传递模型对象和隔室列表,然后针对每个反应检查是否至少有一个试剂位于指定的隔室中。

在您的情况下,您将按如下方式使用它:

# compartment IDs for mitochondria and cytosol
comps = ['c', 'm']

# you only want the reaction IDs; remove the ', return_values=False' part if you also want the corresponding values
trans_cyt_mit = get_fluxes_associated_with_compartments(mod, ['c', 'm'], return_values=False)

列表trans_cyt_mit将包含所有您想要的反应ID(也就是您在问题中指定的两个),然后您可以将其传递给doFVA函数。

关于问题的第二部分。我强烈建议将这些反应存储在一个组中而不是使用注释:

# create an empty group
mod.createGroup('group_trans_cyt_mit')

# get the group object so that we can manipulate it
cyt_mit = mod.getGroup('group_trans_cyt_mit')

# we can only add objects to a group so we get the reaction object for each transport reaction
reaction_objects = [mod.getReaction(ri) for ri in trans_cyt_mit]

# add all the reaction objects to the group
cyt_mit.addMember(reaction_objects)

现在导出模型时,例如使用

cbm.CBWrite.writeSBML3FBCV2(mod, 'iMM904_with_groups.xml')

该组也将存储在SBML中。如果同事再次阅读SBML,他/她可以通过访问组成员轻松运行FVA以获得相同的反应,这比解析注释要容易得多:

# do an FVA; fva_res: Reaction, Reduced Costs, Variability Min, Variability Max, abs(Max-Min), MinStatus, MaxStatus
fva_res, rea_names = cbm.doFVA(mod, selected_reactions=mod.getGroup('group_trans_cyt_mit').getMemberIDs())
fva_dict = dict(zip(rea_names, fva_res.tolist()))

# store results in a dataframe which makes the selection of reactions easier
fva_df = pd.DataFrame.from_dict(fva_dict, orient='index')
fva_df = fva_df.rename({0: "flux_value", 1: "reduced_cost_unscaled", 2: "variability_min", 3: "variability_max",
                       4: "abs_diff_var", 5: "min_status", 6: "max_status"}, axis='columns')

现在,您可以轻松查询数据框,并在组内找到灵活而非灵活的反应:

# filter the reactions with flexibility
fva_flex = fva_df.query("abs_diff_var > 10 ** (-4)")

# filter the reactions that are not flexible
fva_not_flex = fva_df.query("abs_diff_var <= 10 ** (-4)")