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


Python Network.save_dict_to_json方法代码示例

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


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

示例1: mock_g2e_json

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

  ''' 
  A json of signatures from g2e, for enrichment vectoring, should look like this

  {
    "signature_ids":[
      {"col_title":"title 1", "enr_id_up":###, "enr_id_dn":###},
      {"col_title":"title 2", "enr_id_up":###, "enr_id_dn":###}
    ],
    "background_type":"ChEA_2015"
  }
  '''

  net = Network()

  g2e_post = {}
  sig_ids = []

  # I have to get user_list_ids from Enrichr 
  tmp = 1
  for inst_gl in gl:

    inst_sig = {}
    inst_sig['col_title'] = 'Sig-'+str(tmp)
    tmp = tmp+1

    # submit to enrichr and get user_list_ids
    for inst_updn in inst_gl:
      inst_list = inst_gl[inst_updn]
      inst_id = enr_fun.enrichr_post_request(inst_list)
      inst_sig['enr_id_'+inst_updn] = inst_id

    sig_ids.append(inst_sig)

  g2e_post['signature_ids'] = sig_ids

  g2e_post['background_type'] = 'ChEA_2015'

  net.save_dict_to_json(g2e_post,'json/g2e_enr_vect.json','indent')
开发者ID:ErwanDavid,项目名称:clustergrammer.js,代码行数:44,代码来源:make_enr_vect_clust.py

示例2: make_json

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

  row_num = 200
  num_columns = 20

  # make up all names for all data 
  row_names = make_up_names(row_num)

  # initialize vect_post 
  vect_post = {}

  vect_post['title'] = 'Some-Clustergram'
  vect_post['link'] = 'some-link'
  vect_post['filter'] = 'N_row_sum'
  vect_post['is_up_down'] = False
  vect_post['columns'] = []


  split = True

  # fraction of rows in each column - 1 means all columns have all rows 
  inst_prob = 1


  # make column data 
  for col_num in range(num_columns):

    inst_col = {}

    col_name = 'Col-' + str( col_num+1 ) + ' make name longer'

    inst_col['col_name'] = col_name
    inst_col['link'] = 'col-link'

    if col_num < 5:
      inst_col['cat'] = 'brain'
    else:
      inst_col['cat'] = 'lung'

    # save to columns 
    inst_col['data'] = [] #vector

    # get random subset of row_names 
    vect_rows = get_subset_rows(row_names, inst_prob)

    # generate vectors 
    for inst_row in vect_rows:

      # genrate values 
      ##################

      # add positive/negative values 
      if random.random() > 0.5:
        value_up = 10*random.random()
      else: 
        value_up = 0

      if random.random() > 0.5:
        value_dn = -10*random.random()
      else: 
        value_dn = 0

      value = value_up + value_dn

      # # generate vector component 
      # #############################
      # vector.append([ inst_row, value ])
      # vector_up.append([ inst_row, value_up ])
      # vector_dn.append([ inst_row, value_dn ])

      # define row object - within column 
      row_obj = {}
      row_obj['row_name'] = inst_row
      row_obj['val'] = value
      row_obj['val_up'] = value_up
      row_obj['val_dn'] = value_dn

      inst_col['data'].append(row_obj)


    # if split:
    #   inst_col['vector_up'] = vector_up
    #   inst_col['vector_dn'] = vector_dn


    # save columns to vect_post
    vect_post['columns'].append(inst_col)

  net.save_dict_to_json(vect_post, 'fake_vect_post.json', indent='indent')
开发者ID:ErwanDavid,项目名称:clustergrammer.js,代码行数:93,代码来源:fake_vect_post.py

示例3: save_dict_to_json

# 需要导入模块: from clustergrammer import Network [as 别名]
# 或者: from clustergrammer.Network import save_dict_to_json [as 别名]
def save_dict_to_json(inst_dict):
  print('save to cell_line_info_dict.json\n')
  from clustergrammer import Network
  net = Network()

  net.save_dict_to_json(inst_dict, 'cell_line_info_dict.json', indent='indent')
开发者ID:MaayanLab,项目名称:cst_drug_treatment,代码行数:8,代码来源:make_cell_line_info_dict.py

示例4: main

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

  from clustergrammer import Network
  net = Network()

  row_num = 200
  num_columns = 20

  # make up all names for all data
  row_names = make_up_names(row_num)

  # initialize vect_post
  vect_post = {}

  vect_post['title'] = 'Some-Clustergram'
  vect_post['link'] = 'some-link'
  vect_post['filter'] = 'N_row_sum'
  vect_post['is_up_down'] = True
  vect_post['columns'] = []

  # fraction of rows in each column - 1 means all columns have all rows
  inst_prob = 1

  # make column data
  for col_num in range(num_columns):

    inst_col = {}

    if col_num < 5:
      col_name = "('Columns: Col-" + str( col_num+1 ) + "', 'tissue: brain')"
    else:
      col_name = "('Columns: Col-" + str( col_num+1 ) + "', 'tissue: lung')"

    inst_col['col_name'] = col_name
    inst_col['link'] = 'col-link'

    # save to columns
    inst_col['data'] = [] #vector

    # get random subset of row_names
    vect_rows = get_subset_rows(row_names, inst_prob)

    # generate vectors
    for inst_row in vect_rows:

      # genrate values
      ##################

      # add positive/negative values
      if random.random() > 0.5:
        value_up = 10*random.random()
      else:
        value_up = 0

      if random.random() > 0.5:
        value_dn = -10*random.random()
      else:
        value_dn = 0

      value = value_up + value_dn

      # define row object - within column
      row_obj = {}
      row_obj['row_name'] = inst_row
      row_obj['val'] = value
      row_obj['val_up'] = value_up
      row_obj['val_dn'] = value_dn

      inst_col['data'].append(row_obj)

    # save columns to vect_post
    vect_post['columns'].append(inst_col)

  net.save_dict_to_json(vect_post, 'json/fake_vect_post.json', indent='indent')
开发者ID:ZiweiMeng,项目名称:clustergrammer.js,代码行数:76,代码来源:fake_vect_post.py


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