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

Create SPR_fitting.md #704

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Create SPR_fitting.md #704

wants to merge 8 commits into from

Conversation

tstrey
Copy link
Contributor

@tstrey tstrey commented Oct 25, 2023

No description provided.

@ChrisRackauckas
Copy link
Member

This needs to be added to the make.jl of the docs in order to show up.

@TorkelE
Copy link
Member

TorkelE commented Oct 29, 2023

Will continue going through it tomorrow, but so far it looks good :)

@TorkelE
Copy link
Member

TorkelE commented Oct 30, 2023

I have gone through the first half. Unfortunately I get an error after that due to not being sure which combination of optimization packages to use. Once that is figured out, I will go through the last bit :)

@isaacsas
Copy link
Member

isaacsas commented Nov 5, 2024

@tstrey this needs to have master merged into it as it is out of date. (The pages.jl needs updating.)

@isaacsas
Copy link
Member

isaacsas commented Nov 7, 2024

@tstrey this should probably be moved to be an inverse problem example now instead of a model creation example given the new doc structure. Can you update that?

@@ -0,0 +1,110 @@
# [Surface Plasmon Resonance Model Example](@id surface_plasmon_resonance_model_Example)
This tutorial shows how to programmatically construct a ['ReactionSystem'](@ref) corresponding to the chemistry underlying the [Surface Plasmon Resonance Model](https://en.wikipedia.org/wiki/Surface_plasmon_resonance) using [ModelingToolkit](http://docs.sciml.ai/ModelingToolkit/stable/)/[Catalyst](http://docs.sciml.ai/Catalyst/stable/). You can find a simpler constructruction of this model [here](https://docs.sciml.ai/Catalyst/stable/catalyst_applications/parameter_estimation/) in the example of parameter estimation.
Copy link
Member

Choose a reason for hiding this comment

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

https://docs.sciml.ai/Catalyst/stable/catalyst_applications/parameter_estimation/

This seems to be a link from an older version of the docs that no longer works / exists.

Using the symbolic interface, we will create our states/species, define our reactions, and add a discrete event. This model is simulated and used to generate sample data points with added noise and then used to fit parameters in iterations. This event will correspond to the time at which the antibody stop binding to antigen and switch to dissociating.

We begin by importing some necessary packages.
```julia
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
```julia
```@example spr_ex

All of these should be @example blocks so that they run dynamically.

Copy link
Member

Choose a reason for hiding this comment

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

Check out the Documenter.jl documentation for information on how to use such blocks, or look at the other Catalyst tutorials.

using Optimization, OptimizatizationOptimJL
using Plots
```
In this example, the concentration of antigen,`\beta` is varied to determine the constant of proportionality, `\alpha`, `k_{on}`(association rate constant), and `k_{off}` (dissociation rate constant) which characterized the binding interaction between the antigen and the immobilized receptor molecules on the sensor slide. We start by defining our reaction equations, parameters, variables, event, and states.
Copy link
Member

Choose a reason for hiding this comment

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

Note that single quotes are for code rendering not math. They won't render \beta as $\beta$. If you build the documentation locally on your computer and check it looks ok you can see issues such as this.

# [Surface Plasmon Resonance Model Example](@id surface_plasmon_resonance_model_Example)
This tutorial shows how to programmatically construct a ['ReactionSystem'](@ref) corresponding to the chemistry underlying the [Surface Plasmon Resonance Model](https://en.wikipedia.org/wiki/Surface_plasmon_resonance) using [ModelingToolkit](http://docs.sciml.ai/ModelingToolkit/stable/)/[Catalyst](http://docs.sciml.ai/Catalyst/stable/). You can find a simpler constructruction of this model [here](https://docs.sciml.ai/Catalyst/stable/catalyst_applications/parameter_estimation/) in the example of parameter estimation.

Using the symbolic interface, we will create our states/species, define our reactions, and add a discrete event. This model is simulated and used to generate sample data points with added noise and then used to fit parameters in iterations. This event will correspond to the time at which the antibody stop binding to antigen and switch to dissociating.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Using the symbolic interface, we will create our states/species, define our reactions, and add a discrete event. This model is simulated and used to generate sample data points with added noise and then used to fit parameters in iterations. This event will correspond to the time at which the antibody stop binding to antigen and switch to dissociating.
Using the DSL interface, we will create our states/species, define our reactions, and add a discrete event. This model is simulated and used to generate sample data points with added noise and then used to fit parameters in iterations. This event will correspond to the time at which the antibody stop binding to antigen and switch to dissociating.

Comment on lines +52 to +55
plot(p, sample_times, results_list[1][2,:])
plot!(p, sample_times, results_list[2][2,:])
plot!(p, sample_times, results_list[3][2,:])
plot!(p, sample_times, results_list[4][2,:])
Copy link
Member

Choose a reason for hiding this comment

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

Just use a loop.

return sol.u
end

p_estimate = optimise_p([100.0, 10.0, 1.0], 1.5)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
p_estimate = optimise_p([100.0, 10.0, 1.0], 1.5)
p_estimate = optimise_p([100.0, 10.0, 1.0], 1.5)

Shouldn't tend here by switch_time? Why are you setting it to be smaller?


p_estimate = optimise_p([100.0, 10.0, 1.0], 1.5)
```
Finally, we remake the solution using the estimate, fit the entire time span for some `alpha`, and plot the solution.
Copy link
Member

Choose a reason for hiding this comment

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

But you don't seem to be fitting a second time using the parameters from the first fit?

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.

4 participants