gpt4 book ai didi

python - 通量变异性分析仅适用于隔间之间的传输 react ?

转载 作者:太空宇宙 更新时间:2023-11-04 02:24:37 25 4
gpt4 key购买 nike

我只想对选定的 react 进行 FVA,在我的例子中是关于隔室之间的传输 react (例如细胞质和线粒体之间)。我知道我可以像这样在 doFVA 中使用 selected_reactions:

import cbmpy as cbm

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

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

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

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

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

可以解析。

最佳答案

没有针对此类任务的内置函数。正如您已经提到的,依赖 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)

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

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

因此,您传递模型对象和隔间列表,然后针对每个 react 检查指定隔间中是否至少有一种试剂。

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

# 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 列表将包含所有需要的 react ID(也是您在问题中指定的两个),然后您可以将其传递给 doFVA 函数。

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

# 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,他/她可以通过访问组成员轻松地为相同的 react 运行 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')

现在您可以轻松查询数据框并找到组内灵活和不灵活的 react :

# 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)")

关于python - 通量变异性分析仅适用于隔间之间的传输 react ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50737364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com