文氏图:用封闭曲线(内部区域)表示集合及其关系的图形。(Venn Diagram,也称韦恩图)。
在线生成网站:
1. http://bioinfogp.cnb.csic.es/tools/venny/ (推荐) 可以最多支持四组数据对比,如: 2. http://www.bioinformatics.lu/venn.php 最多支持三组数据,但可以回收绘图后的数据,如: 3. 理论上支持无限组数据比较的Python小程序(代码高亮来自http://tohtml.com/python/): #! /usr/bin/env python import os import sys USAGE = ''' Descript: Venn Diagram Version: V1.0 Author: tudyzhb(at)gmail.com Data: 2013.05.08 USAGE: venn.py <file1 [file2 ...]> [out_dir] fileX FILE content of a list of IDs. out_dir DIR output dir. ''' SPLIT = '-' def make_dir(_dir): if os.path.exists(_dir): return True try: os.makedirs(_dir) return True except: return False def unique(file_name, debug = False): org = [] for line in open(file_name): key = line.rstrip().split('\t')[0] if key: org.append(key) res = tuple(set(org)) if debug: print >> sys.stderr, "'%s': input %d, unique elements %d" % ( file_name, # os.path.basename(file_name) len(org), len(res), ) return res def main(file_lis, out_dir = '', debug = True): container = [unique(file_name, debug = True) for file_name in file_lis] res = {} for i, con in enumerate(container):# destribution elements idx = str(i + 1)# offset 1 for el in con: if el in res: if idx in res[el]: res[el][idx] += 1 else: res[el][idx] = 1 else: res[el] = {idx:1} res_r = {} for v in res:# key to value key = SPLIT.join(sorted(res[v])) if key in res_r: res_r[key].append(v) else: res_r[key] = [v] res = res_r key_order = sorted([x for x in res]) if debug: print >> sys.stderr, "\n**PS\t%s**\n" % ', '.join( ["%d:'%s'" % (x + 1, y) for x, y in enumerate(file_lis)]) for key in key_order:# unique result elements res[key] = tuple(set(res[key])) if debug: print >> sys.stderr, ">%s:\t%d" % (key, len(res[key])) if out_dir:# output elements if make_dir(out_dir): for key in key_order: out = os.path.join(out_dir, "%s.txt" % key) try: open(out, 'w').write('\n'.join(res[key]) + '\n') if debug: print >> sys.stderr, "output:\t'%s'" % out except: pass if __name__ == '__main__': argv_len = len(sys.argv) - 1 if argv_len: argv = sys.argv[1:] if not os.path.isfile(argv[-1]) and argv_len >= 2: main(argv[0:-1], argv[-1]) else: main(argv) else: print USAGE |
生物信息学 | bioinfomatic >