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

Error in building MetaGraph from DataFrames. #6

Open
niccolo99mandelli opened this issue Jun 19, 2023 · 1 comment
Open

Error in building MetaGraph from DataFrames. #6

niccolo99mandelli opened this issue Jun 19, 2023 · 1 comment

Comments

@niccolo99mandelli
Copy link
Collaborator

Hi, I'm working on the spatial-input branch and I've added some features related to reading and translating DataFrames in MetaGraph. Specifically, I've created some nearly identical function in Start.jl for initiating the simulation, in J_Space.jl for loading DataFrames and in DataFrameGraphBridge.jl for building the MetaGraph. To generate the MetaGraph, I'm using the function metagraph_from_dataframe_JHistint and passing the following parameters:
G_meta = DataFrameGraphBridge.metagraph_from_dataframe_JHistint(MetaGraph, df_edges, :origin, :destination, :weight, :weight, df_labels, :label).
Here, df_edges is a DataFrame containing information about the edges (:origin, :destination, :weight), and df_labels is a DataFrame containing information about the vertices (:label, :position, :color).
In the metagraph_from_dataframe_JHistint function, I have removed the following part because the input DataFrame (df_edges) does not have the columns defined as :Child, :Time, Subpop_Child :

    #add times on graph
    times_df = df[:,[:Child, :Time]]
    vertex_names = leftjoin(vertex_names, times_df, on = :name => :Child)
    #add subpop_child on graph
    subpop_df = df[:,[:Child, :Subpop_Child]]
    vertex_names = leftjoin(vertex_names, subpop_df, on = :name => :Child)
    # Set vertex names and attributes
    attr_names = propertynames(vertex_names[!, Not(:vertex_id)])
    for r in eachrow(vertex_names)
        set_props!(mg, r[:vertex_id], Dict([a => r[a] for a in attr_names]))
    end

I'm not sure if it's related to this change or to the function's structure itself, but when I try to launch the simulation, I encounter the following error in the third step during RUN DYNAMIC:

julia> J-SPACE: START... (SlideExample_mini_1.tif)
J-SPACE: CREATE/LOAD GRAPH... (SlideExample_mini_1.tif)
[:weight]J-SPACE: RUN DYNAMIC... (SlideExample_mini_1.tif)
┌ Warning: Executing simulationButton_clicked_callback:
└ @ Gtk.GLib ~/.julia/packages/Gtk/oo3cW/src/GLib/signals.jl:106
ERROR: DimensionMismatch: column :Driver has length 0 and column :Fitness has length 1
Stacktrace:
  [1] DataFrames.DataFrame(columns::Vector{Any}, colindex::DataFrames.Index; copycols::Bool)
    @ DataFrames ~/.julia/packages/DataFrames/LteEl/src/dataframe/dataframe.jl:206
  [2] DataFrame
    @ ~/.julia/packages/DataFrames/LteEl/src/dataframe/dataframe.jl:187 [inlined]
  [3] DataFrames.DataFrame(; kwargs::Base.Pairs{Symbol, Vector, Tuple{Symbol, Symbol}, NamedTuple{(:Driver, :Fitness), Tuple{Vector{Any}, Vector{Float64}}}})
    @ DataFrames ~/.julia/packages/DataFrames/LteEl/src/dataframe/dataframe.jl:326
  [4] Start_J_Space(filepath_reference::String, filepath_matrix::String, filepath_file::String, filpeath_plot::String, slide_id::SubString{String}, filepath_dataframe_edges::String, filepath_dataframe_labels::String)
    @ J_Space ~/.julia/packages/J_Space/IGCAi/src/Start.jl:521
  [5] (::var"#simulationButton_clicked_callback#5")(widget::GtkButtonLeaf)
    @ Main ~/SOPHYSM/src/main.jl:84
  [6] (::Gtk.GLib.var"#90#92"{Ptr{Gtk.GLib.GValue}, UInt32, Ptr{Gtk.GLib.GValue}, Vector{Any}, Bool, var"#simulationButton_clicked_callback#5", Ptr{Any}})()
    @ Gtk.GLib ~/.julia/packages/Gtk/oo3cW/src/GLib/signals.jl:87
  [7] g_siginterruptible(f::Gtk.GLib.var"#90#92"{Ptr{Gtk.GLib.GValue}, UInt32, Ptr{Gtk.GLib.GValue}, Vector{Any}, Bool, var"#simulationButton_clicked_callback#5", Ptr{Any}}, cb::Any)
    @ Gtk.GLib ~/.julia/packages/Gtk/oo3cW/src/GLib/signals.jl:216
  [8] GClosureMarshal(closuref::Ptr{Nothing}, return_value::Ptr{Gtk.GLib.GValue}, n_param_values::UInt32, param_values::Ptr{Gtk.GLib.GValue}, invocation_hint::Ptr{Nothing}, marshal_data::Ptr{Nothing})
    @ Gtk.GLib ~/.julia/packages/Gtk/oo3cW/src/GLib/signals.jl:58
  [9] (::Gtk.var"#253#254")()
    @ Gtk ~/.julia/packages/Gtk/oo3cW/src/events.jl:2
 [10] g_sigatom(f::Any)
    @ Gtk.GLib ~/.julia/packages/Gtk/oo3cW/src/GLib/signals.jl:176
 [11] gtk_main()
    @ Gtk ~/.julia/packages/Gtk/oo3cW/src/events.jl:1

What could be the issue?
Thank you in advance.

NM

@marcoxa
Copy link
Member

marcoxa commented Jun 28, 2023

Progress report?

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