Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reversible reaction arrows not showing #5

Closed
jchitpin opened this issue Jul 29, 2022 · 4 comments
Closed

Reversible reaction arrows not showing #5

jchitpin opened this issue Jul 29, 2022 · 4 comments

Comments

@jchitpin
Copy link

Hi again,

It's been a while since I've used Escher.jl for visualizing networks and am having issues with reversible reactions only showing arrowheads in one direction. I updated to Escher.jl version v0.6.5 and was following your tutorial with the E. coli core model from Bigg/Escher. From what I remember, there was no issue the first time you implemented reaction directions, but I haven't done any regression testing.

using Escher, CairoMakie, ColorSchemes
rd = Dict(
    "PGM" => (Dict("3pg_c" => 1, "2pg_c" => -1), :r),
    "PYK" => (Dict("pep_c" => -1, "adp_c" => -1, "h_c" => -1.0, "atp_c" => 1.0, "pyr_c" => 1), :f)

f = Figure(resolution = (1200, 800));
ax = Axis(f[1, 1]);
escherplot!(
    ax,
    "/path/to/escher-map-file/e_coli_core.Core metabolism.json",
    reaction_directions = rd,
    reaction_arrow_size = 12,
    reaction_show_text = true,
)
hidexdecorations!(ax)
hideydecorations!(ax)

The resulting plot is identical to yours with only a single arrow head for the reversible PGM reaction.

@stelmo
Copy link
Owner

stelmo commented Jul 29, 2022

Ah, this is definitely something I broke! I'm just on holiday at the moment, I will fix it once I get back in about a week.

@jchitpin
Copy link
Author

No worries! Enjoy your holiday and take your time.

@stelmo
Copy link
Owner

stelmo commented Aug 7, 2022

Hi there, can you check out branch #6 and see if it works? You can add directionality with :forward, :backward and :bidirectional as shown here:

rd = Dict(
    "PGM" => (Dict("3pg_c" => 1, "2pg_c" => -1), :backward),
    "PYK" => (Dict("pep_c" => -1, "adp_c" => -1, "h_c" => -1.0, "atp_c" => 1.0, "pyr_c" => 1), :forward),
    "ENO" => (Dict("2pg_c" => 1, "pep_c" => -1, "h2o_c" => -1), :bidirectional),
)

f = Figure(resolution = (1200, 800));
ax = Axis(f[1, 1]);
escherplot!(
    ax,
    joinpath(pkgdir(Escher), "data", "core-map.json");
    reaction_directions = rd,
    reaction_arrow_size = 12,
    reaction_show_text = true,
)
hidexdecorations!(ax)
hideydecorations!(ax)
f

@jchitpin
Copy link
Author

jchitpin commented Aug 8, 2022

Hi again. Can confirm that branch 6 works perfectly. I did the following to generate rd for an entire Bigg/Escher network. Many thanks :)

# rev is the reaction vector with 1=reversible reaction and 0 otherwise.
rev_dict = Dict(zip([0, 1], [:forward, :bidirectional]))

model = load_model("/bigg-models/e_coli_core.json")
rd = Dict(#
  String(model.rxns[k]["id"]) => (#
    Dict{String,Float64}(model.rxns[k]["metabolites"]),
    rev_dict[rev[k]]
  )
  for k in 1:length(model.rxns)
)

@jchitpin jchitpin closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants