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


Python Network.write_json_to_file方法代码示例

本文整理汇总了Python中clustergrammer.Network.write_json_to_file方法的典型用法代码示例。如果您正苦于以下问题:Python Network.write_json_to_file方法的具体用法?Python Network.write_json_to_file怎么用?Python Network.write_json_to_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clustergrammer.Network的用法示例。


在下文中一共展示了Network.write_json_to_file方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_enr_vect_clust

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def make_enr_vect_clust():
  import enrichr_functions as enr_fun 
  from clustergrammer import Network

  net = Network()

  g2e_post = net.load_json_to_dict('json/g2e_enr_vect.json')

  net = enr_fun.make_enr_vect_clust(g2e_post, 0.001, 1)

  net.write_json_to_file('viz','json/enr_vect_example.json')
开发者ID:ErwanDavid,项目名称:clustergrammer.js,代码行数:13,代码来源:make_enr_vect_clust.py

示例2: make_viz_json

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def make_viz_json(inst_df, name):
  from clustergrammer import Network
  net = Network()

  filename = 'json/'+name
  load_df = {}
  load_df['mat'] = inst_df
  net.df_to_dat(load_df)
  net.swap_nan_for_zero()
  net.make_clust(views=[])
  net.write_json_to_file('viz', filename, 'no-indent')
开发者ID:MaayanLab,项目名称:IDG_poster_2016,代码行数:13,代码来源:make_hgram_poster_image.py

示例3: cluster

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def cluster():
  from clustergrammer import Network

  net = Network()

  vect_post = net.load_json_to_dict('fake_vect_post.json')  

  net.load_vect_post_to_net(vect_post)

  net.swap_nan_for_zero()
  
  # net.N_top_views()
  net.make_clust(dist_type='cos',views=['N_row_sum','N_row_var'], dendro=True)

  net.write_json_to_file('viz','json/large_vect_post_example.json','indent')  
开发者ID:ErwanDavid,项目名称:clustergrammer.js,代码行数:17,代码来源:fake_vect_post.py

示例4: clustergrammer_load

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def clustergrammer_load():
  # import network class from Network.py
  from clustergrammer import Network

  net = Network()

  net.pandas_load_file('mat_cats.tsv')  

  net.make_clust(dist_type='cos',views=['N_row_sum','N_row_var'])

  net.write_json_to_file('viz','json/mult_cats.json','indent')  

  print('\n**********************')
  print(net.dat['node_info']['row'].keys())

  print('\n\n')
开发者ID:ErwanDavid,项目名称:clustergrammer.js,代码行数:18,代码来源:make_mult_categories.py

示例5: main

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def main():

  import time
  start_time = time.time()
  import pandas as pd
  import StringIO

  # import network class from Network.py
  from clustergrammer import Network

  net = Network()

  # load data to dataframe 
  # net.load_tsv_to_net('txt/example_tsv_network.txt')
  # net.load_tsv_to_net('txt/mat_1mb.txt')

  # choose file 
  ################
  # file_buffer = open('txt/col_categories.txt')
  file_buffer = open('txt/example_tsv_network.txt'  )


  buff = StringIO.StringIO( file_buffer.read() )
  net.pandas_load_tsv_to_net(buff)

  # filter rows 
  views = ['filter_row_sum','N_row_sum']

  # distance metric 
  dist_type = 'cosine'

  # linkage type 
  linkage_type = 'average'


  net.make_clust(dist_type=dist_type, views=views, calc_col_cats=True,\
  linkage_type=linkage_type)

  net.write_json_to_file('viz', 'json/mult_view.json', 'no-indent')

  elapsed_time = time.time() - start_time
  print('\n\n\nelapsed time: '+str(elapsed_time))
开发者ID:jjdblast,项目名称:clustergrammer.js,代码行数:44,代码来源:mock_web_app_load.py

示例6: prepare_heatmap

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [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)
开发者ID:ImmPortDB,项目名称:immport-galaxy,代码行数:22,代码来源:clustergrammerIPG.py

示例7: make_json_from_tsv

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def make_json_from_tsv(name):
  '''
  make a clustergrammer json from a tsv file
  '''
  from clustergrammer import Network

  print('\n' + name)

  net = Network()

  filename = 'txt/'+ name + '.txt'

  net.load_file(filename)

  df = net.dat_to_df()

  net.swap_nan_for_zero()

  # zscore first to get the columns distributions to be similar
  net.normalize(axis='col', norm_type='zscore', keep_orig=True)

  # filter the rows to keep the perts with the largest normalizes values
  net.filter_N_top('row', 1000)

  num_rows = net.dat['mat'].shape[0]
  num_cols = net.dat['mat'].shape[1]

  print('num_rows ' + str(num_rows))
  print('num_cols ' + str(num_cols))

  if num_cols < 50 or num_rows < 1000:

    views = ['N_row_sum']
    net.make_clust(dist_type='cos', views=views)
    export_filename = 'json/' + name + '.json'
    net.write_json_to_file('viz', export_filename)

  else:
    print('did not cluster, too many columns ')
开发者ID:MaayanLab,项目名称:LINCS_GCT,代码行数:41,代码来源:process_gct_and_make_jsons.py

示例8: make_viz_from_df

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
def make_viz_from_df(df, filename):
  from clustergrammer import Network

  net = Network()

  net.df_to_dat(df)
  net.swap_nan_for_zero()

  # zscore first to get the columns distributions to be similar
  net.normalize(axis='col', norm_type='zscore', keep_orig=True)

  # filter the rows to keep the perts with the largest normalizes values
  net.filter_N_top('row', 2000)

  num_coluns = net.dat['mat'].shape[1]

  if num_coluns < 50:
    # views = ['N_row_sum', 'N_row_var']
    views = ['N_row_sum']
    net.make_clust(dist_type='cos', views=views)

    filename = 'json/' + filename.split('/')[1].replace('.gct','') + '.json'

    net.write_json_to_file('viz', filename)
开发者ID:MaayanLab,项目名称:LINCS_GCT,代码行数:26,代码来源:old_load_gct.py

示例9: Network

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [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
开发者ID:unreno,项目名称:observations,代码行数:27,代码来源:create_clustergrammer_json.py

示例10:

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
net.load_file('txt/rc_two_cats.txt')
# net.load_file('txt/example_tsv.txt')
# net.load_file('txt/col_categories.txt')
# net.load_file('txt/mat_cats.tsv')
# net.load_file('txt/mat_1mb.Txt')
# net.load_file('txt/mnist.txt')
# net.load_file('txt/sim_mat_4_cats.txt')

views = ['N_row_sum','N_row_var']

# # filtering rows and cols by sum 
# net.filter_sum('row', threshold=20)
# net.filter_sum('col', threshold=30)
  
# # keep top rows based on sum 
# net.filter_N_top('row', 10, 'sum')

net.make_clust(dist_type='cos',views=views , dendro=True,
               sim_mat=True, filter_sim=0.1)

# net.produce_view({'N_row_sum':10,'dist':'euclidean'})

net.write_json_to_file('viz', 'json/mult_view.json', 'no-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')

elapsed_time = time.time() - start_time

print('\n\nelapsed time')
print(elapsed_time)
开发者ID:jjdblast,项目名称:clustergrammer.js,代码行数:32,代码来源:make_clustergrammer.py

示例11: Network

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
from clustergrammer import Network
net = Network()

# choose tsv file
####################
inst_name = 'Tyrosine'
# net.load_file('txt/phos_ratios_all_treat_no_geld_ST.txt')
net.load_file('txt/phos_ratios_all_treat_no_geld_Tyrosine.txt')


net.swap_nan_for_zero()

# net.normalize(axis='row', norm_type='zscore', keep_orig=True)

print(net.dat.keys())

views = ['N_row_sum', 'N_row_var']

net.make_clust(dist_type='cos',views=views , dendro=True,
               sim_mat=True, filter_sim=0.1, calc_cat_pval=False)
               # run_enrichr=['KEA_2015'])
               # run_enrichr=['ENCODE_TF_ChIP-seq_2014'])
               # run_enrichr=['GO_Biological_Process_2015'])

net.write_json_to_file('viz', 'json/'+inst_name+'.json', 'no-indent')
net.write_json_to_file('sim_row', 'json/'+inst_name+'_sim_row.json', 'no-indent')
net.write_json_to_file('sim_col', 'json/'+inst_name+'_sim_col.json', 'no-indent')

elapsed_time = time.time() - start_time
print('\n\nelapsed time: '+str(elapsed_time))
开发者ID:MaayanLab,项目名称:cst_drug_treatment,代码行数:32,代码来源:make_drug_treatment_figures.py

示例12: Network

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
import time
start_time = time.time()

# import network class from Network.py
from clustergrammer import Network

net = Network()

net.load_tsv_to_net('txt/example_tsv.txt')

net.make_filtered_views(dist_type='cos',views=['N_row_sum','pct_row_sum'])

net.write_json_to_file('viz', 'json/mult_view.json', 'indent')

# your code
elapsed_time = time.time() - start_time

print('\n\n\nelapsed time')
print(elapsed_time)
开发者ID:msyinmei,项目名称:clustergrammer.js,代码行数:21,代码来源:make_clustergram.py

示例13: Network

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import write_json_to_file [as 别名]
# import network class from Network.py
from clustergrammer import Network

# get instance of Network
net = Network()
print(net.__doc__)
print('make tsv clustergram')

# load network from tsv file
##############################
net.load_tsv_to_net('txt/example_tsv_network.txt')

inst_filt = 0.001
inst_meet = 1
net.filter_network_thresh(inst_filt,inst_meet)

# cluster
#############
net.cluster_row_and_col('cos')

# export data visualization to file
######################################
net.write_json_to_file('viz', 'json/default_example.json', 'indent')
开发者ID:msyinmei,项目名称:clustergrammer.js,代码行数:25,代码来源:make_clust.py


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