sdwfrost / Gillespie.jl

Stochastic Gillespie-type simulations using Julia
Other
61 stars 24 forks source link

function ssa_data failing #21

Open konkam opened 2 years ago

konkam commented 2 years ago

Hello,

the code in the instructions at https://sdwfrost.github.io/Gillespie.jl/latest/ seems to be failing.

The error message is:

ERROR: MethodError: Cannot `convert` an object of type Matrix{Int64} to an object of type DataFrames.DataFrame
Closest candidates are:
  convert(::Type{DataFrames.DataFrame}, ::DataFrames.SubDataFrame) at ~/.julia/packages/DataFrames/MA4YO/src/subdataframe/subdataframe.jl:304
  convert(::Type{T}, ::T) where T at ~/julia-1.7.2/share/julia/base/essentials.jl:218
  DataFrames.DataFrame(::Matrix) at ~/.julia/packages/DataFrames/MA4YO/src/dataframe/dataframe.jl:381
  ...
Stacktrace:
 [1] ssa_data(s::SSAResult)
   @ Gillespie ~/.julia/packages/Gillespie/FC1zW/src/SSA.jl:341
 [2] top-level scope
   @ REPL[9]:1

All lines up to this run fine. This behaviour is obtained on julia 1.7.2 (2022-02-06), the repo version of Gillespie.jl and DataFrames v1.3.2

A minor comment is that the installation command needs to be updated, with something along Pkg.add(url="https://github.com/sdwfrost/Gillespie")

martacunial commented 1 year ago

I have the same error with Julia 1.9.1. Have you solved this?

konkam commented 1 year ago

Hello Marta,

I ended up coding my own Gillespie algorithm and not using the package

martacunial commented 1 year ago

I solved this issue not using the function _ssadata (that still gives me error), but I extracted the data I needed from SSAResult returned from the function ssa. result=ssa(x0,F,nu,parms,tf) sim=result.data; time=result.time df= DataFrame(sim,:auto); #convert Matrix{Int64} into a Dataframe.

I converted the Matrix into a Dataframe so that I could use it to easily plot the data.