Skip to content

Commit

Permalink
pre-defining cat_colors in viz json, working on re-using category col…
Browse files Browse the repository at this point in the history
…ors for multiple clustergrams and manually defining cat_colors
  • Loading branch information
cornhundred committed Mar 13, 2017
1 parent 8529f3e commit 9407293
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 9 deletions.
130 changes: 127 additions & 3 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@
"deletable": true,
"editable": true
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"1\n",
"0\n",
"1\n",
"0\n",
"1\n",
"2\n",
"3\n",
"4\n"
]
}
],
"source": [
"net.load_file('txt/rc_two_cats.txt')"
]
Expand Down Expand Up @@ -94,12 +110,120 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {
"collapsed": true,
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"int('1')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"tmp = 'something: something'"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"tmp2 = tmp"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"tmp2 = tmp2.split(': ')[0]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'something'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tmp2"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"'something: something'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tmp"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
Expand Down
2 changes: 0 additions & 2 deletions clustergrammer/calc_clust.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ def cluster_row_and_col(net, dist_type='cosine', linkage_type='average',
if calc_cat_pval is True:
cat_pval.main(net)

print(net.viz.keys())

# make the visualization json
make_viz.viz_json(net, dendro, links)

Expand Down
15 changes: 14 additions & 1 deletion clustergrammer/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ def dict_cat(net, define_cat_colors=False):
# loop through each category name and assign a color
for tmp_name in cat_names:

inst_color = get_cat_color(cat_number)
# using the same rules as the front-end to define cat_colors
inst_color = get_cat_color(cat_number + cat_names.index(tmp_name))

check_name = tmp_name

# check for default non-color
if ': ' not in check_name:
check_name = check_name.split(': ')[1]

if check_name == 'False':
inst_color = '#eee'

if 'Not ' in check_name:
inst_color = '#eee'

cat_colors[inst_rc][cat_index][tmp_name] = inst_color

Expand Down
2 changes: 0 additions & 2 deletions clustergrammer/make_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ def viz_json(net, dendro=True, links=False):
from . import calc_clust
import numpy as np

print(net.viz.keys())

all_dist = calc_clust.group_cutoffs()

for inst_rc in net.dat['nodes']:
Expand Down
2 changes: 1 addition & 1 deletion json/mult_view.json

Large diffs are not rendered by default.

0 comments on commit 9407293

Please sign in to comment.