Mercurial > repos > azomics > clustergrammer_flow
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 0:fee56ee2f7ac | 1:c90127c2a1ae |
|---|---|
| 11 # version 1.2 -- June 2018 | 11 # version 1.2 -- June 2018 |
| 12 # added clustergrammer clustering parameters and normalization options | 12 # added clustergrammer clustering parameters and normalization options |
| 13 | 13 |
| 14 | 14 |
| 15 from __future__ import print_function | 15 from __future__ import print_function |
| 16 | |
| 17 import os | |
| 16 import sys | 18 import sys |
| 17 import os | 19 |
| 20 from clustergrammer import Network | |
| 18 | 21 |
| 19 from jinja2 import Environment, FileSystemLoader | 22 from jinja2 import Environment, FileSystemLoader |
| 23 | |
| 20 import pandas as pd | 24 import pandas as pd |
| 21 from clustergrammer import Network | |
| 22 | 25 |
| 23 | 26 |
| 24 def is_integer(s): | 27 def is_integer(s): |
| 25 try: | 28 try: |
| 26 int(s) | 29 int(s) |
| 50 else: | 53 else: |
| 51 output_list.append(int(tmp_col[c].strip()) - 1) | 54 output_list.append(int(tmp_col[c].strip()) - 1) |
| 52 return(output_list) | 55 return(output_list) |
| 53 | 56 |
| 54 | 57 |
| 55 def prepare_heatmap(matrix_input, html_file, html_dir, tools_dir, categories, distance, linkage): | 58 def prepare_heatmap(matrix_input, html_file, html_dir, tools_dir, |
| 59 categories, distance, linkage): | |
| 56 # prepare directory and html | 60 # prepare directory and html |
| 57 os.mkdir(html_dir) | 61 os.mkdir(html_dir) |
| 58 | 62 |
| 59 env = Environment(loader=FileSystemLoader(tools_dir + "/templates")) | 63 env = Environment(loader=FileSystemLoader(tools_dir + "/templates")) |
| 60 template = env.get_template("clustergrammer.template") | 64 template = env.get_template("clustergrammer.template") |
| 89 'row': df.iloc[:, 0], | 93 'row': df.iloc[:, 0], |
| 90 'col': df.columns[1:] | 94 'col': df.columns[1:] |
| 91 } | 95 } |
| 92 | 96 |
| 93 tmp_string = "-=-".join(args[8:]) | 97 tmp_string = "-=-".join(args[8:]) |
| 94 print (tmp_string + "\n") | 98 print(tmp_string + "\n") |
| 95 # get categories | 99 # get categories |
| 96 cats = tmp_string.split("-=-new_cat-=-") | 100 cats = tmp_string.split("-=-new_cat-=-") |
| 97 for cat in cats: | 101 for cat in cats: |
| 98 tmp_cat = cat.split("-=-") | 102 tmp_cat = cat.split("-=-") |
| 99 group = { | 103 group = { |
| 116 print(index_names, elem[0], sep="\t") | 120 print(index_names, elem[0], sep="\t") |
| 117 group["cats"][elem[0]] = index_names | 121 group["cats"][elem[0]] = index_names |
| 118 categories[tmp_cat[0]].append(group) | 122 categories[tmp_cat[0]].append(group) |
| 119 print(categories) | 123 print(categories) |
| 120 | 124 |
| 121 | 125 prepare_heatmap(args[1], args[2], args[3], |
| 122 prepare_heatmap(args[1], args[2], args[3], args[4], categories, args[5], args[6]) | 126 args[4], categories, args[5], args[6]) |
