本文整理汇总了Python中MatrixUtil.m_to_R_string方法的典型用法代码示例。如果您正苦于以下问题:Python MatrixUtil.m_to_R_string方法的具体用法?Python MatrixUtil.m_to_R_string怎么用?Python MatrixUtil.m_to_R_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixUtil
的用法示例。
在下文中一共展示了MatrixUtil.m_to_R_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_response_content
# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import m_to_R_string [as 别名]
def get_response_content(fs):
"""
@param fs: a FieldStorage object containing the cgi arguments
@return: a (response_headers, response_text) pair
"""
# get the tree
tree = NewickIO.parse(fs.tree, FelTree.NewickTree)
# read the ordered labels
ordered_labels = Util.get_stripped_lines(StringIO(fs.labels))
# validate the input
observed_label_set = set(node.get_name() for node in tree.gen_tips())
if set(ordered_labels) != observed_label_set:
msg = 'the labels should match the labels of the leaves of the tree'
raise HandlingError(msg)
# get the matrix of pairwise distances among the tips
D = np.array(tree.get_distance_matrix(ordered_labels))
L = Euclid.edm_to_laplacian(D)
w, v = get_eigendecomposition(L)
C = get_contrast_matrix(w, v)
# set elements with small absolute value to zero
C[abs(C) < fs.epsilon] = 0
# start to prepare the reponse
out = StringIO()
if fs.plain_format:
print >> out, MatrixUtil.m_to_string(C)
elif fs.matlab_format:
print >> out, MatrixUtil.m_to_matlab_string(C)
elif fs.r_format:
print >> out, MatrixUtil.m_to_R_string(C)
# write the response
return out.getvalue()
示例2: get_response_content
# 需要导入模块: import MatrixUtil [as 别名]
# 或者: from MatrixUtil import m_to_R_string [as 别名]
def get_response_content(fs):
# get the tree
tree = NewickIO.parse(fs.tree, FelTree.NewickTree)
# read the ordered labels
ordered_labels = Util.get_stripped_lines(fs.labels.splitlines())
# validate the input
observed_label_set = set(node.get_name() for node in tree.gen_tips())
if set(ordered_labels) != observed_label_set:
msg = 'the labels should match the labels of the leaves of the tree'
raise HandlingError(msg)
# get the matrix of pairwise distances among the tips
C = Contrasts.get_contrast_matrix(tree, ordered_labels)
# set elements with small absolute value to zero
C[abs(C) < fs.epsilon] = 0
# return the reponse
if fs.plain_format:
return MatrixUtil.m_to_string(C) + '\n'
elif fs.matlab_format:
return MatrixUtil.m_to_matlab_string(C) + '\n'
elif fs.r_format:
return MatrixUtil.m_to_R_string(C) + '\n'