Skip to content

Commit 08cc693

Browse files
authored
Add lab presentation notebook (#22)
1 parent 2d5561e commit 08cc693

File tree

2 files changed

+275
-0
lines changed

2 files changed

+275
-0
lines changed
473 KB
Loading
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
### A Pluto.jl notebook ###
2+
# v0.20.1
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# ╔═╡ 1575b3cc-b786-11ef-34ef-dd6f58044fcc
8+
using DrWatson
9+
10+
# ╔═╡ 0306d9f3-c210-4236-b9db-9ecb29787f08
11+
@quickactivate
12+
13+
# ╔═╡ 8579e700-ef01-4ab9-a117-21bbf559d3dd
14+
using GraphRecipes, Plots, DataFrames, Random, GraphDynamicalSystems, Graphs, MetaGraphsNext
15+
16+
# ╔═╡ 63b200cc-ae46-468e-ab25-e6d6ab58874b
17+
using DynamicalSystems: Attractors, trajectory, StateSpaceSets
18+
19+
# ╔═╡ 90852030-deae-43d3-a573-124749d19d44
20+
md"""
21+
# Synthesizing Graph Dynamical Systems
22+
23+
PONY Lab Group Meeting, 11/12/2024
24+
"""
25+
26+
# ╔═╡ 04361d06-11c1-468a-a97d-04a41b5d606a
27+
md"""
28+
## What's a GDS?
29+
30+
A model represented by
31+
32+
- A graph
33+
- Each vertex in the graph has a function
34+
- Edges in the graph denote which vertices are inputs to others
35+
- Each vertex has a state
36+
- Dynamics of the system depend on
37+
- Vertices' functions
38+
- The order you update them (_schedule_)
39+
"""
40+
41+
# ╔═╡ 4a95f701-cf79-4800-aa5a-72c6ee4c2e13
42+
md"""
43+
## Example GDS: Boolean Network
44+
"""
45+
46+
# ╔═╡ e59b989c-2e88-4063-88d0-a2a4e3aae567
47+
md"""
48+
## Why do we care about them?
49+
50+
- Executable models for bio, for example
51+
- Can use to study the effect of a drug on a biological system
52+
53+
![BMA](https://github.com/user-attachments/assets/486bd9a9-a2a9-4dd3-8b55-00f7c8f1462a)
54+
"""
55+
56+
# ╔═╡ c01be032-ec3f-4b7b-9698-90c7555cac50
57+
md"""
58+
## Why synthesize?
59+
60+
- Constructing by hand is time consuming
61+
- Basically amounts to guess-and-check
62+
63+
To understand how we synthesize, let's return to our example network. What kind of information can we extract from it?
64+
"""
65+
66+
# ╔═╡ 2092c9f8-515e-4674-ad76-fdb2f22c0439
67+
md"""
68+
## Data from our BN
69+
70+
State space/single cell measurements
71+
"""
72+
73+
# ╔═╡ 9d09bc34-043c-4793-96f6-c7db927fed42
74+
md"""
75+
Steady state/mutation experiments
76+
"""
77+
78+
# ╔═╡ 124b39da-e8a7-45d0-9a67-82dd08d16672
79+
md"""
80+
## Types of Schedules
81+
82+
- **Asynchronous**
83+
- Choose a vertex at random from the network
84+
- Run its function to update its value
85+
- Synchronous
86+
- Run all vertices' functions to update their values
87+
- Bounded Asynchrony
88+
- Run subsets of the vertices at the same time
89+
- Tricky case, probably will ignore this for today
90+
"""
91+
92+
# ╔═╡ b608b534-4753-4529-8852-089aff34fab9
93+
md"""
94+
## Async BN
95+
96+
The `dynamic rule` is the asynchronous schedule mentioned before.
97+
"""
98+
99+
# ╔═╡ aab65a05-e256-4140-ae83-6547985e01a2
100+
md"""
101+
## State Space
102+
"""
103+
104+
# ╔═╡ 04ed17cb-69bd-48eb-b294-af120fe26b19
105+
mg = MetaGraph(SimpleDiGraph(), label_type = String)
106+
107+
# ╔═╡ 8955d1d1-3cd0-4691-9c7f-f6179cc6e048
108+
md"""
109+
## Steady State(s)
110+
"""
111+
112+
# ╔═╡ bf0a7add-f668-4fcc-87d4-ad535bf93b12
113+
md"""
114+
## Synthesizing
115+
116+
From the two types of data, two kinds of specifications:
117+
- State space specifies how a specific vertex's function should transform the state
118+
- Steady state specifies how a collection of vertex functions should behave
119+
120+
Refering to these as _local_ and _global_ constraints.
121+
"""
122+
123+
# ╔═╡ 80136458-da57-4ea9-943c-bd6692fad780
124+
md"""
125+
## "Global" Constraint
126+
127+
> The steady state of the model is `[1, 0, 0, 1, 1]`
128+
129+
This is a constraint on the steady state of the model when combining synthesized functions for all vertices.
130+
"""
131+
132+
# ╔═╡ 606d1e0e-ee79-4b12-964a-c5d597508761
133+
md"""
134+
## Discussion Question #1
135+
136+
If an incorrect steady-state is reached, which vertex is to blame?
137+
"""
138+
139+
# ╔═╡ 1f02a380-2f17-44d2-a0a7-e4f7f3974c4c
140+
begin
141+
mg2 = deepcopy(mg)
142+
bad_v = string([1, 0, 1, 1, 1])
143+
add_vertex!(mg2, bad_v)
144+
add_edge!(mg2, string([1, 0, 0, 1, 1]), bad_v)
145+
plot(
146+
mg2.graph;
147+
names = mg2.vertex_labels,
148+
nodesize = 0.06,
149+
nodecolor = [:lightblue, :lightblue, :lightblue, :red],
150+
)
151+
end
152+
153+
# ╔═╡ a1759c77-2ff3-4722-a65c-25ecf50ac279
154+
md"""
155+
## Discussion Question #2
156+
157+
Assuming a synchronous schedule, how can we reconstruct the state space like we saw before?
158+
"""
159+
160+
# ╔═╡ 8a243870-3d53-4312-b4d5-056f2372eb68
161+
md"""
162+
## Extras
163+
"""
164+
165+
# ╔═╡ 5879d4f1-6bba-4675-b34b-9a1fcc023441
166+
seed = 42
167+
168+
# ╔═╡ a217cd51-8c4b-4e74-90d3-b8d22daa6d62
169+
Random.seed!(seed)
170+
171+
# ╔═╡ 964fca0e-b28d-4ebd-a2ad-3daf2ba2d4cd
172+
network = BooleanNetworks.sample_boolean_network(5, 3, seed)
173+
174+
# ╔═╡ 452fda7d-e2f7-4162-a3d3-eef13ff3bdfc
175+
plot(network.graph; names = network.vertex_labels, nodesize = 0.2)
176+
177+
# ╔═╡ 230f34b5-c160-4f06-b560-8306ae62e51e
178+
[(k => v[2]) for (k, v) in network.vertex_properties]
179+
180+
# ╔═╡ d207a020-97e1-40ab-8f9b-8503cca9acf3
181+
plot(network.graph; names = network.vertex_labels, nodesize = 0.2)
182+
183+
# ╔═╡ 51c331eb-77ef-4fcb-afff-c62fbf77d398
184+
async_bn = BooleanNetworks.abn(network)
185+
186+
# ╔═╡ 6811c128-1aff-48e6-8af6-6946ebf7e6c1
187+
trjs = [trajectory(async_bn, 100) for _ = 1:1000]
188+
189+
# ╔═╡ a52b6f33-bd36-4dae-9e90-4201e30bab78
190+
trjs[1][1][1:5]
191+
192+
# ╔═╡ 8aeb938e-8cd2-4f0c-9bfc-9b35457b4e5d
193+
trjs[1]
194+
195+
# ╔═╡ a16f15fe-491d-43a4-b41f-5e3b82c0ec85
196+
ssp = begin
197+
for t in trjs
198+
for (f, s) in zip(t[1][1:end-1], t[1][2:end])
199+
add_vertex!(mg, string(f))
200+
add_vertex!(mg, string(s))
201+
add_edge!(mg, string(f), string(s))
202+
end
203+
end
204+
plot(mg.graph; names = mg.vertex_labels, nodesize = 0.05)
205+
end
206+
207+
# ╔═╡ d7a3067a-5b81-4409-bcf7-0254bcd591fb
208+
ssp
209+
210+
# ╔═╡ 8d39c39f-0897-43e8-942a-9a7884eb1dd4
211+
ssp
212+
213+
# ╔═╡ 320ce9dc-5390-42eb-9b09-3e73f1bdd28b
214+
attr = begin
215+
grid = Tuple(range(0, 1) for _ = 1:5)
216+
mapper = Attractors.AttractorsViaRecurrences(async_bn, grid)
217+
for _ = 1:1000
218+
mapper(rand(0:1, 5))
219+
end
220+
Attractors.extract_attractors(mapper)
221+
end
222+
223+
# ╔═╡ e99505e5-6697-42c5-b763-77e5ee3d0158
224+
attr[1]
225+
226+
# ╔═╡ 743cb689-469e-48f1-82cc-f7e2abeadf9a
227+
md"""
228+
## Local Constraint
229+
230+
> In: `[1, 0, 0, 1, 1]`, out: `[1, 0, 0, 0, 1]`
231+
232+
This is a constraint on vertex `4`'s update function.
233+
234+
A satisfying function would be $(string(network.vertex_properties[4][2])[26:end])
235+
"""
236+
237+
# ╔═╡ Cell order:
238+
# ╟─90852030-deae-43d3-a573-124749d19d44
239+
# ╟─04361d06-11c1-468a-a97d-04a41b5d606a
240+
# ╟─4a95f701-cf79-4800-aa5a-72c6ee4c2e13
241+
# ╟─452fda7d-e2f7-4162-a3d3-eef13ff3bdfc
242+
# ╟─230f34b5-c160-4f06-b560-8306ae62e51e
243+
# ╟─e59b989c-2e88-4063-88d0-a2a4e3aae567
244+
# ╟─c01be032-ec3f-4b7b-9698-90c7555cac50
245+
# ╟─d207a020-97e1-40ab-8f9b-8503cca9acf3
246+
# ╟─2092c9f8-515e-4674-ad76-fdb2f22c0439
247+
# ╟─a52b6f33-bd36-4dae-9e90-4201e30bab78
248+
# ╟─9d09bc34-043c-4793-96f6-c7db927fed42
249+
# ╟─e99505e5-6697-42c5-b763-77e5ee3d0158
250+
# ╟─124b39da-e8a7-45d0-9a67-82dd08d16672
251+
# ╟─b608b534-4753-4529-8852-089aff34fab9
252+
# ╠═51c331eb-77ef-4fcb-afff-c62fbf77d398
253+
# ╟─aab65a05-e256-4140-ae83-6547985e01a2
254+
# ╟─6811c128-1aff-48e6-8af6-6946ebf7e6c1
255+
# ╠═8aeb938e-8cd2-4f0c-9bfc-9b35457b4e5d
256+
# ╠═04ed17cb-69bd-48eb-b294-af120fe26b19
257+
# ╟─a16f15fe-491d-43a4-b41f-5e3b82c0ec85
258+
# ╟─8955d1d1-3cd0-4691-9c7f-f6179cc6e048
259+
# ╟─320ce9dc-5390-42eb-9b09-3e73f1bdd28b
260+
# ╟─d7a3067a-5b81-4409-bcf7-0254bcd591fb
261+
# ╟─bf0a7add-f668-4fcc-87d4-ad535bf93b12
262+
# ╟─743cb689-469e-48f1-82cc-f7e2abeadf9a
263+
# ╟─80136458-da57-4ea9-943c-bd6692fad780
264+
# ╟─606d1e0e-ee79-4b12-964a-c5d597508761
265+
# ╟─1f02a380-2f17-44d2-a0a7-e4f7f3974c4c
266+
# ╟─a1759c77-2ff3-4722-a65c-25ecf50ac279
267+
# ╟─8d39c39f-0897-43e8-942a-9a7884eb1dd4
268+
# ╟─8a243870-3d53-4312-b4d5-056f2372eb68
269+
# ╠═1575b3cc-b786-11ef-34ef-dd6f58044fcc
270+
# ╠═0306d9f3-c210-4236-b9db-9ecb29787f08
271+
# ╠═a217cd51-8c4b-4e74-90d3-b8d22daa6d62
272+
# ╠═5879d4f1-6bba-4675-b34b-9a1fcc023441
273+
# ╠═964fca0e-b28d-4ebd-a2ad-3daf2ba2d4cd
274+
# ╠═8579e700-ef01-4ab9-a117-21bbf559d3dd
275+
# ╠═63b200cc-ae46-468e-ab25-e6d6ab58874b

0 commit comments

Comments
 (0)