alanderos91 / BioSimulator.jl

A stochastic simulation framework in Julia.
https://alanderos91.github.io/BioSimulator.jl/stable/
Other
47 stars 7 forks source link

Change parameters of the model #19

Closed skycolt closed 4 years ago

skycolt commented 4 years ago

Hello,

I am trying to change parameters in the model but can't even find the place they are stored, neither can I find a function for that. Could you help me with this?

Thanks Wenzhe

alanderos91 commented 4 years ago

Currently it is not possible to change parameters during a simulation. You can change parameters by "redefining" a reaction:

model <= Reaction("name_of_reaction", new_parameter, "formula")
skycolt commented 4 years ago

Thank you for this! And is there a way to check the value of the parameters in the model?

Wenzhe

skycolt commented 4 years ago

BTW. Is there a function that I can read the simulation result into variables for future analysis?

Thanks

alanderos91 commented 4 years ago
  1. The Network type has this information. For example,

    model.reaction_list[:birth].rate

    This retrieves the parameter for a reaction channel called "birth".

  2. You can extract the results in two ways:

    
    result = simulate(...)

directly

id2index = result.id2index simulation_data = result.simulation_data ntrials = length(simulation_data)

protein = [simulation_data[n][k][id2index[:protein]] for n in 1:ntrials, k in 1:length(simulation_data[n])]

with DataFrames

using DataFrames

DataFrame(result)



Here `simulation_data` stores the trajectory for each realization of the process, so that `simulation_data[n]` is the `n`-th sample path. The index `k` steps through each *recorded* event. The [DataFrames](https://juliadata.github.io/DataFrames.jl/stable/) approach is more straightforward, and will let you save results if you read their documentation.
skycolt commented 4 years ago

Thank you very much!