本文整理汇总了Python中ete3.Tree.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.copy方法的具体用法?Python Tree.copy怎么用?Python Tree.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ete3.Tree
的用法示例。
在下文中一共展示了Tree.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trees
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import copy [as 别名]
spID += 1
node.sp = spID
for leaf in node:
try:
leaf.sp = spID
except AttributeError:
leaf.add_features(sp=1)
if (ms_input == True) and (ms_islands[-1] > largest_id):
sys.exit("2. The MS island structure you provided through -I does not fit the number of tips in the demography. The option might have been mispecified. Check it out!")
sys.stdout.write('S') # SpreadSpeciation
# if requested, print speciational tree
if plot_trees:
tmut = t.copy()
for leaf in tmut:
leaf.name = "["+str(leaf.sp)+"]"+leaf.name
tmut.render(ophylo+"_2MUT.png", w=183, units="mm")
#======================================================#
# CONVERT demography to phylogeny using a traversing method
# __/!\__ to be modified for non dichotomic trees (eg Lambda coalescent)
traversedNodes = set()
for node in t.traverse("preorder"):
if node not in traversedNodes:
示例2: Tree
# 需要导入模块: from ete3 import Tree [as 别名]
# 或者: from ete3.Tree import copy [as 别名]
gl = pd.read_csv(inputGLF, sep = "\t")
t = Tree(spTreeF)
t.sort_descendants(attr='O')
ts = TreeStyle()
ts.complete_branch_lines_when_necessary = False
# calculate branch colors
gainL = [] # list with all rates of gain
lossL = [] # list with all rates of loss
gm = gl.rgain.min()
gM = gl.rgain.max()
lm = gl.rloss.min()
lM = gl.rloss.max()
#bcrg = scaleCol(gl.pgain.tolist()) # Branch Colors for Rates of Gain
#bcrl = scaleCol(gl.ploss.tolist()) # Branch Colors for Rates of Loss
# make a "gain" and a "loss" copy of the tree
tg = t.copy()
tl = t.copy()
gcm = cm.ScalarMappable(norm = colors.Normalize(vmin = gm, vmax = gM), cmap = "coolwarm")
lcm = cm.ScalarMappable(norm = colors.Normalize(vmin = lm, vmax = lM), cmap = "coolwarm")
for node in tg.iter_descendants(): # do not include root
if node.up.is_root():
rgain = gl.loc[(gl.fromNode == 0) & (gl.toNode == int(node.ND)), 'rgain']
else:
rgain = gl.loc[(gl.fromNode == int(node.up.ND)) & (gl.toNode == int(node.ND)), 'rgain']
if rgain.empty:
continue
rgain = rgain.item()
style = NodeStyle()
gainString = "%.2f" % (rgain)
#pick colors
ci = colors.rgb2hex(gcm.to_rgba(rgain)[:3])