当前位置: 首页>>代码示例>>Python>>正文


Python Tree.copy方法代码示例

本文整理汇总了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:
开发者ID:sunyatin,项目名称:vanaprabhava,代码行数:32,代码来源:VPB.py

示例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])
开发者ID:,项目名称:,代码行数:33,代码来源:


注:本文中的ete3.Tree.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。