本文整理汇总了Python中clustergrammer.Network.cluster方法的典型用法代码示例。如果您正苦于以下问题:Python Network.cluster方法的具体用法?Python Network.cluster怎么用?Python Network.cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clustergrammer.Network
的用法示例。
在下文中一共展示了Network.cluster方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_heatmap
# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import cluster [as 别名]
def prepare_heatmap(matrix_input, html_file, html_dir, tools_dir, categories, distance, linkage):
# prepare directory and html
os.mkdir(html_dir)
env = Environment(loader=FileSystemLoader(tools_dir + "/templates"))
template = env.get_template("clustergrammer.template")
overview = template.render()
with open(html_file, "w") as outf:
outf.write(overview)
json_output = html_dir + "/mult_view.json"
net = Network()
net.load_file(matrix_input)
if (categories['row']):
net.add_cats('row', categories['row'])
if (categories['col']):
net.add_cats('col', categories['col'])
net.cluster(dist_type=distance, linkage_type=linkage)
net.write_json_to_file('viz', json_output)
示例2: Network
# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import cluster [as 别名]
# make network object and load file
from clustergrammer import Network
net = Network()
net.load_file('mult_view.tsv')
# Z-score normalize the rows
#net.normalize(axis='row', norm_type='zscore', keep_orig=True)
# calculate clustering using default parameters
net.cluster()
# save visualization JSON to file for use by front end
net.write_json_to_file('viz', 'mult_view.json')
# needs pandas and sklearn as well
# pip install --user --upgrade clustergrammer pandas sklearn
示例3:
# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import cluster [as 别名]
net.load_file('txt/rc_two_cats.txt')
# net.load_file('txt/ccle_example.txt')
# net.load_file('txt/rc_val_cats.txt')
# net.load_file('txt/number_labels.txt')
# net.load_file('txt/mnist.txt')
# net.load_file('txt/tuple_cats.txt')
# net.load_file('txt/example_tsv.txt')
# net.enrichrgram('KEA_2015')
# optional filtering and normalization
##########################################
# net.filter_sum('row', threshold=20)
# net.normalize(axis='col', norm_type='zscore', keep_orig=True)
# net.filter_N_top('row', 250, rank_type='sum')
# net.filter_threshold('row', threshold=3.0, num_occur=4)
# net.swap_nan_for_zero()
# net.set_cat_color('col', 1, 'Category: one', 'blue')
# net.make_clust()
# net.dendro_cats('row', 5)
net.cluster(dist_type='cos',views=['N_row_sum', 'N_row_var'] , dendro=True,
sim_mat=True, filter_sim=0.1, calc_cat_pval=False, enrichrgram=
False, run_clustering=True)
# write jsons for front-end visualizations
net.write_json_to_file('viz', 'json/mult_view.json', 'indent')
net.write_json_to_file('sim_row', 'json/mult_view_sim_row.json', 'no-indent')
net.write_json_to_file('sim_col', 'json/mult_view_sim_col.json', 'no-indent')