本文整理汇总了Python中ete3.Tree.iter_descendants方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.iter_descendants方法的具体用法?Python Tree.iter_descendants怎么用?Python Tree.iter_descendants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.iter_descendants方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import iter_descendants [as 别名]
outputF = arg
else:
print("Unknown argument" + arg)
print(usage)
sys.exit(1)
glsF = pd.read_table(gainLossSumF, sep = "\t", index_col = False)
# normalize by branch length
t = Tree(spTreeF)
# Sum pgij for each i j and
# sum kgij*ng for each ij
# build node pairs and br lenght
branches = {}
for node in t.iter_descendants():
fromNode = node.up.ND
toNode = node.ND
key = "|".join(sorted([n for n in node.get_leaf_names()]))
branches[(fromNode, toNode)] = {'brlen' : float(node.dist),
'leaves': key}
sumpgijGain = {}
sumpgijLoss = {}
sumNK = {}
sumIK = {}
for k in branches:
rowIndexes = (glsF['fromNode']==int(k[0])) & (glsF['toNode']==int(k[1]))
sumpgijGain[k] = glsF.loc[rowIndexes,'pcijGain'].sum()
sumpgijLoss[k] = glsF.loc[rowIndexes,'pcijLoss'].sum()
sumNK[k] = (glsF.loc[rowIndexes, 'ng'] * glsF.loc[rowIndexes, 'kij']).sum()