Skip to content

Add finite state projection example #1269

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

Merged
merged 19 commits into from
May 26, 2025
Merged

Add finite state projection example #1269

merged 19 commits into from
May 26, 2025

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented May 16, 2025

An example of how to simulate the CME using FiniteStateProjection.jl.

I trialled having a collapsed "quick-start" example at the beginning (in the same way we had the environment set up in the CRN example library doc page).

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a collapsible "installation instructions" too?

Have you double checked you have the axes correct on the heatmaps? (Sometimes some libraries flip the x and y axes I recall.)

It might be nice to also make the SS heatmap by running SSAs? That would be a nice comparison to show one gets the same result.

Finally, you probably want to pass vectors that label the X and Y ticks in the heatmaps, as otherwise I think they might start plotting at 1 and not zero. (Maybe plot the initial condition to confirm it looks ok and is labeled right?)

TorkelE and others added 4 commits May 20, 2025 21:54
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
@TorkelE
Copy link
Member Author

TorkelE commented May 20, 2025

Should we add a collapsible "installation instructions" too?

Sounds good, will add it.

Have you double checked you have the axes correct on the heatmaps? (Sometimes some libraries flip the x and y axes I recall.)

Yes (I made a really skewed case and checked that the distribution ended up at the right side). It does flip from what one would expect. However, we probably should add an !!! warning statement explicitly pointing this out (as it is not obvious for someone just skimming the tutorial).

It might be nice to also make the SS heatmap by running SSAs? That would be a nice comparison to show one gets the same result.

Basically just running a long SSA, and plotting the distribution of all values (after some initial time interval where it approaches the steady state? That would make sense.

Finally, you probably want to pass vectors that label the X and Y ticks in the heatmaps, as otherwise I think they might start plotting at 1 and not zero. (Maybe plot the initial condition to confirm it looks ok and is labeled right?)

Definitely, I will update to do this.

@isaacsas
Copy link
Member

I was thinking to just run many simulations to a fixed (large enough) time and then calculating the distribution at that time, but you can use the time series too (but that is usually more work to properly construct the distribution from).

@TorkelE
Copy link
Member Author

TorkelE commented May 20, 2025

Sounds good. I will check the simulation time of a few 100 Gillespie simulations, and if that is not noteworthy (should be very quick) I will use that.

@isaacsas
Copy link
Member

Don't forget to only save the final value once you've determined what time things look stationary at.

@TorkelE
Copy link
Member Author

TorkelE commented May 20, 2025

will do, sounds like a good oppertunity to make this point generally (and show of a nice feature of the ensemble simulation interface).

@TorkelE
Copy link
Member Author

TorkelE commented May 21, 2025

The main example is updated and should be ready, however, an unrelated doc page has started failing. Will have to figure out why.

@TorkelE
Copy link
Member Author

TorkelE commented May 22, 2025

The error has been reported in SciML/SciMLSensitivity.jl#1212

@isaacsas
Copy link
Member

Should we comment out that doc for now to get the build here working and merged? We can open a tracking issue on it to add that tutorial back later once it is fixed.

Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments. Feel free to address as you see fit and you are welcome to merge after you are happy with things. Thanks, very nice tutorial!

Comment on lines 2 to 18
```@raw html
<details><summary><strong>Environment setup and package installation</strong></summary>
```
The following code sets up an environment for running the code on this page.
```julia
using Pkg
Pkg.activate(".")
Pkg.add("Catalyst")
Pkg.add("FiniteStateProjection")
Pkg.add("JumpProcesses")
Pkg.add("OrdinaryDiffEqDefault")
Pkg.add("OrdinaryDiffEqRosenbrock")
Pkg.add("Plots")
Pkg.add("SteadyStateDiffEq")
```
```@raw html
</details>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! We should work to add this to each tutorial. The only change I might suggest is using a temp environment in activate i.e. Pkg.activate(; temp = true), along with a comment that that is what the command does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy to start adding these in across the docs. Good idea about the temporary environment (one of those thing I have never really used but probably should), what about

Pkg.activate(; temp = true) # Creates a temporary environment, which is deleted when the Julia session ends.
Pkg.add("Catalyst")
...

TorkelE and others added 4 commits May 25, 2025 16:10
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
Co-authored-by: Sam Isaacson <isaacsas@users.noreply.github.com>
@TorkelE TorkelE merged commit afd5d59 into master May 26, 2025
1 check passed
@TorkelE TorkelE deleted the add_fsp_docs branch May 26, 2025 08:35
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

Successfully merging this pull request may close these issues.

2 participants