资源简介
Python RWR 可重启随机游走代码。
Python RWR,可重启的随机游走源代码,可重启的随机游走源代码
随机游走

代码片段和文件信息
“““
Main script for running tissue-specific graph walk experiments to convergence.
“““
import sys
import argparse
from walker import Walker
def generate_seed_list(seed_file):
“““ Read seed file into a list. “““
seed_list = []
try:
fp = open(seed_file “r“)
except IOError:
sys.exit(“Error opening file {}“.format(seed_file))
for line in fp.readlines():
info = line.rstrip().split()
if len(info) > 1:
seed_list.append(info[1])
else:
seed_list.append(info[0])
fp.close()
return seed_list
def get_node_list(node_file):
node_list = []
try:
fp = open(node_file ‘r‘)
except IOError:
sys.exit(‘Could not open file: {}‘.format(node_file))
# read the first (i.e. largest) connected component
cur_line = fp.readline()
while cur_line and not cur_line.isspace():
if cur_line:
node_list.append(cur_line.rstrip())
cur_line = fp.readline()
fp.close()
return node_list
def main(argv):
# set up argument parsing
parser = argparse.ArgumentParser()
parser.add_argument(‘input_graph‘ help=‘Original graph input file in\
edge list format‘)
parser.add_argument(‘seed‘ help=‘Seed file to pull start nodes from‘)
parser.add_argument(‘-e‘ ‘--restart_prob‘ type=float default=0.7
help=‘Restart probability for random walk‘)
parser.add_argument(‘-l‘ ‘--low_list‘ nargs=‘?‘ default=None
help=‘ List of genes expressed and\
unexpressed in the current tissue if applicable‘)
parser.add_argument(‘-n‘ ‘--node_list‘ nargs=‘?‘ default=None
help=‘ Order of output probs‘)
parser.add_argument(‘-o‘ ‘--original_graph_prob‘ type=float default=0.1
help=‘Probability of walking on the original (non-\
tissue specific) graph if applicable‘)
parser.add_argument(‘-r‘ ‘--remove‘ nargs=‘+‘
help=‘ Nodes to remove from the graph if any‘)
opts = parser.parse_args()
seed_list = generate_seed_list(opts.seed)
node_list = get_node_list(opts.node_list) if opts.node_list else []
# filter nodes we want to remove out of the starting seed if any
remove_list = opts.remove if opts.remove else []
if remove_list:
seed_list = [s for s in seed_list if s not in remove_list]
# run the experiments and write a rank list to stdout
wk = Walker(opts.input_graph opts.low_list remove_list)
wk.run_exp(seed_list opts.restart_prob
opts.original_graph_prob node_list)
if __name__ == ‘__main__‘:
main(sys.argv)
# main(testdata/test_network.ppitestdata/test_seed.txt)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 0 2019-03-26 12:53 Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?
文件 110229 2018-07-29 19:30 Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?WechatIMG2.jpeg
目录 0 2019-03-26 12:53 __MACOSX\
文件 0 2019-03-26 12:53 __MACOSX\Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?
文件 266 2018-07-29 19:30 __MACOSX\Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?._WechatIMG2.jpeg
文件 6148 2019-03-26 12:53 Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?.DS_Store
文件 120 2019-03-26 12:53 __MACOSX\Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?._.DS_Store
文件 2880 2019-03-26 11:08 Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?run_walker.py
文件 708 2019-03-26 11:08 __MACOSX\Python RWR 鍙噸鍚殢鏈烘父璧颁唬鐮?._run_walker.py
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- 一个简单的python爬虫
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- Python Machine Learning Case Studies
- python获取硬件信息
评论
共有 条评论