zakandrewking / escher

Build, share, and embed visualizations of metabolic pathways.
https://escher.github.io
Other
210 stars 78 forks source link

How to plot binary data? #315

Closed willigott closed 5 years ago

willigott commented 5 years ago

Let's say I want to visualize flux values with only two colors, e.g. positive fluxes and negative fluxes (all the same value, e.g. 10 and -10, respectively). How would I do this?

I tried:


from escher import Builder
import os

json_repr = os.path.join('maps', 'iMM904.Central carbon metabolism.json')

reaction_data = {'PGI': 10, 'HEX1': -10}

rea_scale = [
    {'type': 'min', 'color': '#FF0000', 'size': 12},
    {'type': 'max', 'color': '#008000', 'size': 12}
]

b = Builder(
    map_json=json_repr,
    reaction_data=reaction_data,
    reaction_scale=rea_scale
)

b.display_in_browser(scroll_behavior='zoom', never_ask_before_quit=True)

However, I still then get only one color:

Screenshot from 2019-07-17 22-21-01

Also the color scale looks strange to me as the minimal value is set to 8 and not -10, the max value is 12 and not 10, but on the map itself it is displayed correctly.

Am I using it correctly? Is there a way to accomplish this programmatically?

zakandrewking commented 5 years ago

try turning off absolute value:

b = Builder(
    map_json=json_repr,
    reaction_data=reaction_data,
    reaction_scale=rea_scale,
    reaction_styles=['color', 'style'], # no 'abs'
)

Described here: https://escher.readthedocs.io/en/latest/javascript_api.html#escher.Builder.options.reaction_styles

It's also in the settings menu under the bar.

willigott commented 5 years ago

Thanks a lot; that indeed did the trick!