Mercurial > repos > azomics > clustergrammer_flow
annotate clustergrammerIPG.py @ 1:c90127c2a1ae draft default tip
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
author | azomics |
---|---|
date | Sun, 27 Jun 2021 22:13:16 +0000 |
parents | fee56ee2f7ac |
children |
rev | line source |
---|---|
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
1 #!/usr/bin/env python |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
2 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
3 ###################################################################### |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
4 # Copyright (c) 2016 Northrop Grumman. |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
5 # All rights reserved. |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
6 ###################################################################### |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
7 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
8 # version 1.1 -- August 2017 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
9 # added checks for consistency between input files |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
10 # and upper limit on nb of cluster to look at |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
11 # version 1.2 -- June 2018 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
12 # added clustergrammer clustering parameters and normalization options |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
13 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
14 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
15 from __future__ import print_function |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
16 |
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
17 import os |
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
18 import sys |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
19 |
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
20 from clustergrammer import Network |
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
21 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
22 from jinja2 import Environment, FileSystemLoader |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
23 |
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
24 import pandas as pd |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
25 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
26 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
27 def is_integer(s): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
28 try: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
29 int(s) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
30 return True |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
31 except ValueError: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
32 return False |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
33 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
34 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
35 def get_indices(input_text): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
36 output_list = [] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
37 default_value = ['i.e.:1,2,5', 'i.e.:3,6,7'] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
38 if input_text in default_value: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
39 sys.exit(2) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
40 else: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
41 tmp_col = input_text.split(",") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
42 if len(tmp_col) == 1: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
43 if not tmp_col[0].strip(): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
44 sys.exit(2) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
45 elif not is_integer(tmp_col[0].strip()): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
46 sys.exit(3) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
47 else: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
48 output_list.append(int(tmp_col[0].strip()) - 1) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
49 else: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
50 for c in range(0, len(tmp_col)): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
51 if not is_integer(tmp_col[c].strip()): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
52 sys.exit(3) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
53 else: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
54 output_list.append(int(tmp_col[c].strip()) - 1) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
55 return(output_list) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
56 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
57 |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
58 def prepare_heatmap(matrix_input, html_file, html_dir, tools_dir, |
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
59 categories, distance, linkage): |
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
60 # prepare directory and html |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
61 os.mkdir(html_dir) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
62 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
63 env = Environment(loader=FileSystemLoader(tools_dir + "/templates")) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
64 template = env.get_template("clustergrammer.template") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
65 overview = template.render() |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
66 with open(html_file, "w") as outf: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
67 outf.write(overview) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
68 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
69 json_output = html_dir + "/mult_view.json" |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
70 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
71 net = Network() |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
72 net.load_file(matrix_input) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
73 if (categories['row']): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
74 net.add_cats('row', categories['row']) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
75 if (categories['col']): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
76 net.add_cats('col', categories['col']) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
77 net.cluster(dist_type=distance, linkage_type=linkage) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
78 net.write_json_to_file('viz', json_output) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
79 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
80 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
81 if __name__ == "__main__": |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
82 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
83 args = sys.argv |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
84 categories = { |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
85 'row': [], |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
86 'col': [] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
87 } |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
88 norm = {} |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
89 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
90 if (len(args) > 7): |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
91 df = pd.read_table(args[1]) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
92 names = { |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
93 'row': df.iloc[:, 0], |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
94 'col': df.columns[1:] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
95 } |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
96 |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
97 tmp_string = "-=-".join(args[8:]) |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
98 print(tmp_string + "\n") |
0
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
99 # get categories |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
100 cats = tmp_string.split("-=-new_cat-=-") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
101 for cat in cats: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
102 tmp_cat = cat.split("-=-") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
103 group = { |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
104 "title": tmp_cat[1], |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
105 "cats": {} |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
106 } |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
107 stg_groups = "--".join(tmp_cat[2:]) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
108 groups = stg_groups.split("--new_label--") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
109 cat_indices = [] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
110 for g in groups: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
111 print(g + "\n") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
112 elem = g.split("--") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
113 index_list = get_indices(elem[1]) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
114 index_names = [] |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
115 for i in index_list: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
116 if i in cat_indices: |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
117 sys.exit(4) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
118 index_names.append(str(names[tmp_cat[0]][i])) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
119 cat_indices = cat_indices + index_list |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
120 print(index_names, elem[0], sep="\t") |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
121 group["cats"][elem[0]] = index_names |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
122 categories[tmp_cat[0]].append(group) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
123 print(categories) |
fee56ee2f7ac
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit b11dfcf10d287c1da91ffb1d5d0148c7f8f61356"
azomics
parents:
diff
changeset
|
124 |
1
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
125 prepare_heatmap(args[1], args[2], args[3], |
c90127c2a1ae
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/clustergrammer_flow commit e47edffe14c2e8544fe0d00d932090657beae528"
azomics
parents:
0
diff
changeset
|
126 args[4], categories, args[5], args[6]) |