|
| 1 | +### A Pluto.jl notebook ### |
| 2 | +# v0.20.1 |
| 3 | + |
| 4 | +using Markdown |
| 5 | +using InteractiveUtils |
| 6 | + |
| 7 | +# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). |
| 8 | +macro bind(def, element) |
| 9 | + quote |
| 10 | + local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end |
| 11 | + local el = $(esc(element)) |
| 12 | + global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) |
| 13 | + el |
| 14 | + end |
| 15 | +end |
| 16 | + |
| 17 | +# ╔═╡ 172d1c64-9528-11ef-1455-69f3dc33e1c4 |
| 18 | +using DrWatson |
| 19 | + |
| 20 | +# ╔═╡ 49710c05-a20a-473f-9569-0579a35b8093 |
| 21 | +@quickactivate |
| 22 | + |
| 23 | +# ╔═╡ 1d98adb9-5beb-476c-84db-5e6ccaf8841b |
| 24 | +using DataFrames |
| 25 | + |
| 26 | +# ╔═╡ a65b8474-8d7c-423a-9700-fda5a13e3622 |
| 27 | +using JLD2 |
| 28 | + |
| 29 | +# ╔═╡ 15b53ea1-57cb-45a6-9f15-e18bd9b8df29 |
| 30 | +using DynamicalSystems |
| 31 | + |
| 32 | +# ╔═╡ 7f760eb1-a3ab-4599-8d24-58696e67c36d |
| 33 | +using Plots |
| 34 | + |
| 35 | +# ╔═╡ 77d6b0bc-cd28-46ed-b2f5-56eb94efc659 |
| 36 | +using PlutoUI |
| 37 | + |
| 38 | +# ╔═╡ 6b843080-264a-4e30-a1fb-d05fb77ae526 |
| 39 | +function split_state_space(trajectory::StateSpaceSet) |
| 40 | + # split into pairs of input (all values) and output (changed value) |
| 41 | + input_output_pairs_per_node = Dict{Int,Set{Tuple{Vector{Int},Int}}}() |
| 42 | + for i = 1:length(trajectory)-1 |
| 43 | + changed = findfirst(trajectory[i+1] .!= trajectory[i]) |
| 44 | + # only proceed if there was a change |
| 45 | + if !isnothing(changed) |
| 46 | + |
| 47 | + # in real data we don't know the direction of the transition |
| 48 | + # was it from i -> i+1 or i+1 -> i, we only know that two |
| 49 | + # states are adjacent, so for gathering data, we add both |
| 50 | + # directions as IO pairs |
| 51 | + # 1. state `i` and the new value of the single variable in |
| 52 | + # the state that changed |
| 53 | + # 2. state `i+1` and the previous value of the single variable |
| 54 | + # in the state that changed |
| 55 | + |
| 56 | + new_value = trajectory[i+1][changed] |
| 57 | + old_value = trajectory[i][changed] |
| 58 | + existing_pairs = |
| 59 | + get(input_output_pairs_per_node, changed, Set{Tuple{Vector{Int},Int}}()) |
| 60 | + push!( |
| 61 | + existing_pairs, |
| 62 | + (trajectory[i], new_value), # 1 |
| 63 | + (trajectory[i+1], old_value), # 2 |
| 64 | + ) |
| 65 | + input_output_pairs_per_node[changed] = existing_pairs |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + return input_output_pairs_per_node |
| 70 | +end |
| 71 | + |
| 72 | +# ╔═╡ 85379de4-3258-4471-b43c-75c65aea0b10 |
| 73 | +fname = "id=189_iterations=1000_n_trajectories=1000.jld2" |
| 74 | + |
| 75 | +# ╔═╡ f2c8a3fa-61b5-4f39-b5f6-3329eba23ede |
| 76 | +pname = joinpath(datadir("sims", "biodivine_trajectories"), fname) |
| 77 | + |
| 78 | +# ╔═╡ 59dafbbe-086d-4fe6-b01c-e13ab8dc7d80 |
| 79 | +res = load(pname) |
| 80 | + |
| 81 | +# ╔═╡ 1ce04619-14b1-4a4b-bc65-40dfdcae2c74 |
| 82 | +anim = @animate for i in eachindex(res["trajectories"]) |
| 83 | + heatmap(Matrix(res["trajectories"][i])) |
| 84 | +end |
| 85 | + |
| 86 | +# ╔═╡ b36271d5-f908-4e65-b0fa-9175e8c2416c |
| 87 | +# gif(anim) |
| 88 | + |
| 89 | +# ╔═╡ 436fc3d5-fbf5-46b4-a6fd-3f8c97a00a47 |
| 90 | +traj = res["trajectories"] |
| 91 | + |
| 92 | +# ╔═╡ 25966e19-4f35-4b3e-b60a-238cc182fbc9 |
| 93 | +@bind ind Slider(1:1000) |
| 94 | + |
| 95 | +# ╔═╡ de871eaa-0991-4b3d-8c81-fd8afb284df7 |
| 96 | +heatmap(Matrix(res["trajectories"][ind])) |
| 97 | + |
| 98 | +# ╔═╡ fe295564-151a-4325-9c4a-f47963ede398 |
| 99 | +split_applied = [split_state_space(t) for t in traj] |
| 100 | + |
| 101 | +# ╔═╡ 17f352fc-6f4e-4d7d-ad7a-d6d2ac049ada |
| 102 | +begin |
| 103 | + name = tempname() |
| 104 | + name *= ".jld2" |
| 105 | + save(name, @strdict split_applied) |
| 106 | +end |
| 107 | + |
| 108 | +# ╔═╡ 947a965d-54f5-40e3-b703-4a18bf671d9c |
| 109 | +filesize(name) * 1e-6 |
| 110 | + |
| 111 | +# ╔═╡ 3c443200-79f9-4288-8989-6c06408240d5 |
| 112 | +filesize(pname) * 1e-6 |
| 113 | + |
| 114 | +# ╔═╡ 5ca0375d-d325-4831-85c4-17e871dc5a8b |
| 115 | +name |
| 116 | + |
| 117 | +# ╔═╡ Cell order: |
| 118 | +# ╠═172d1c64-9528-11ef-1455-69f3dc33e1c4 |
| 119 | +# ╠═49710c05-a20a-473f-9569-0579a35b8093 |
| 120 | +# ╠═1d98adb9-5beb-476c-84db-5e6ccaf8841b |
| 121 | +# ╠═a65b8474-8d7c-423a-9700-fda5a13e3622 |
| 122 | +# ╠═15b53ea1-57cb-45a6-9f15-e18bd9b8df29 |
| 123 | +# ╠═7f760eb1-a3ab-4599-8d24-58696e67c36d |
| 124 | +# ╠═6b843080-264a-4e30-a1fb-d05fb77ae526 |
| 125 | +# ╠═85379de4-3258-4471-b43c-75c65aea0b10 |
| 126 | +# ╠═f2c8a3fa-61b5-4f39-b5f6-3329eba23ede |
| 127 | +# ╠═59dafbbe-086d-4fe6-b01c-e13ab8dc7d80 |
| 128 | +# ╠═1ce04619-14b1-4a4b-bc65-40dfdcae2c74 |
| 129 | +# ╠═b36271d5-f908-4e65-b0fa-9175e8c2416c |
| 130 | +# ╠═436fc3d5-fbf5-46b4-a6fd-3f8c97a00a47 |
| 131 | +# ╠═77d6b0bc-cd28-46ed-b2f5-56eb94efc659 |
| 132 | +# ╠═25966e19-4f35-4b3e-b60a-238cc182fbc9 |
| 133 | +# ╠═de871eaa-0991-4b3d-8c81-fd8afb284df7 |
| 134 | +# ╠═fe295564-151a-4325-9c4a-f47963ede398 |
| 135 | +# ╠═17f352fc-6f4e-4d7d-ad7a-d6d2ac049ada |
| 136 | +# ╠═947a965d-54f5-40e3-b703-4a18bf671d9c |
| 137 | +# ╠═3c443200-79f9-4288-8989-6c06408240d5 |
| 138 | +# ╠═5ca0375d-d325-4831-85c4-17e871dc5a8b |
0 commit comments