-
Notifications
You must be signed in to change notification settings - Fork 1
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
Create Sankey Diagram #2
Comments
Sankey Network diagrams with cyclic graphs (recursive connections) is only supported by plotly-JS Sankey diagrams. I think this is a really good way for debugging connectivity issues, as you only want to see the proportions of connectivity between populations of cells, rather than wanting to view all one-to-one connections. For now the node labels are wrong, but at least the approach seems to produce a useable output. The graph is interactive too, with nice mouse over labels appearing. Inside the code file test/multilayer_potjans-diesmann2015.jl connections = Dict()
conn_map_pre_density = Dict()
conn_map_post_density = Dict()
for i in eachindex(pre_layer_names)
for j in eachindex(post_layer_names)
pre = pre_layer_names[i]
post = post_layer_names[j]
p = conn_probs[j, i]
J = conn_j[j, i]
sym = J>=0 ? :ge : :gi
μ = abs(J)
if J>=0
s = SNN.SpikingSynapse(neurons[pre], neurons[post], sym; μ = μ, p=p, σ=0, delay_dist=delay_dist_exc)
else
s = SNN.SpikingSynapse(neurons[pre], neurons[post], sym; μ = -μ, p=p, σ=0, delay_dist=delay_dist_inh)
end
keyed = Symbol(string(pre,post))
if haskey(conn_map_pre_density, keyed)
conn_map_pre_density[keyed] += length(s.I)
conn_map_post_density[keyed] += length(s.J)
else
conn_map_pre_density[keyed] = length(s.I) # or set to some default value
conn_map_post_density[keyed] = length(s.J)
end
conn_map_pre_density[Symbol(string(pre,post))] += length(s.I)
connections[Symbol(string(i,"_",pre,"_",j,"_",post))] = s
end
end function sankey_applied(pre_layer_names,post_layer_names,conn_map_pre_density)
labels = []
connections = []
for i in eachindex(pre_layer_names)
for j in eachindex(post_layer_names)
pre = pre_layer_names[i]
post = post_layer_names[j]
push!(labels,string(pre))
push!(connections,(i,j,conn_map_pre_density[Symbol(string(pre,post))]))
end
end
@save "sankey_data.jld" pre_layer_names post_layer_names connections labels
end In its own seperate file called using PlotlyJS # messes with Plots/Makie backends so compartmentalise by keeping in its own file.
using ElectronDisplay
using JLD2
function sankey_applied()
@load "sankey_data.jld" pre_layer_names post_layer_names connections labels
sankey_trace = sankey(
arrangement = "snap",
node = attr(
label = labels,
pad = 15,
thickness = 20,
line = attr(color = "black", width = 0.5)
),
link = attr(
source = [i[1] for i in connections],
target = [i[2] for i in connections],
value = [i[3] for i in connections]
)
)
plt = plot(sankey_trace)
ElectronDisplay.display(plt) # opens a new Electron window
end
sankey_applied() |
PlotlyJS has a good sankey, but it tries to take over your whole plotting environment/backend.
Firstly not a registered project, so this line is required
The text was updated successfully, but these errors were encountered: