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

WIP: beginning to refactor network analysis docs #1142

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

Conversation

vyudu
Copy link
Member

@vyudu vyudu commented Dec 2, 2024

Probably worth discussing more but my thought here is to make Network Analysis its own section of the Catalyst docs, with subsections for the ODE decompositions, structural properties and chemical reaction network theory, and a third section for advanced stuff that links to CatalystNetworkAnalysis.

Added sections for the new API functions in #1134 and building symbolic functions from the ODEs to the ODE docs. Added a section on complex/detailed balance to the CRNT docs.

Need to: add a section on the deficiency one theorem, bring in the CatalystNetworkAnalysis docs, add code examples to the complex/detailed balance section (including stuff about the precision limitations of isdetailedbalanced)

@isaacsas
Copy link
Member

Having network analysis be its own section is fine. LMK when you feel this is ready to review.

@vyudu vyudu marked this pull request as ready for review February 5, 2025 02:43
@vyudu vyudu mentioned this pull request Mar 27, 2025
7 tasks
of all options currently available.
- [`parameters`](@ref dsl_advanced_options_declaring_species_and_parameters): Allows the designation of a set of symbols as system parameters.
- [`parameters`]:(@ref dsl_advanced_options_declaring_species_and_parameters) Allows the designation of a set of symbols as system parameter.
Copy link
Member

Choose a reason for hiding this comment

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

these two changes seems wrong?

```

Note, currently API functions for network analysis and conservation law analysis
do not work with constant species (currently only generated by SBMLToolkit).
Copy link
Member

Choose a reason for hiding this comment

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

We allow the definition of constant species in Catalyst (https://docs.sciml.ai/Catalyst/stable/model_creation/dsl_advanced/#dsl_advanced_options_constant_species)?

Also, maybe say SBML generally (I think currently SBMLImporters is the more reliable SBML importer. I think i both covers more cases and also handles jump systems a lot better)

isdetailedbalanced
robustspecies
reset_networkproperties!
```
Copy link
Member

Choose a reason for hiding this comment

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

Might be useful (for some, although personally I do not use API that way really) to split into sections? Only if there actually is an easy split that makes sense.

in `rn` a variety of information. For example the first call to
```julia
rcs,B = reactioncomplexes(rn)
```
Copy link
Member

Choose a reason for hiding this comment

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

Could this be made dynamic by creating a simple rn model and then applying these on it? The output doesn't;t really matter, so can add nothing # hide at the end of each block.

Network Theory*[^1] for more discussion about the concepts on this page.

Note, currently API functions for network analysis and conservation law analysis
do not work with constant species (currently only generated by SBMLToolkit).
Copy link
Member

Choose a reason for hiding this comment

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

same as previous comment

μ, P₃ --> ∅
end
```
In the [Introduction to Catalyst](@ref introduction_to_catalyst)
Copy link
Member

Choose a reason for hiding this comment

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

Since when we initially wrote this, we have a dedicated tutorial and section for this kind of visualisation: https://docs.sciml.ai/Catalyst/stable/model_creation/model_visualisation/#visualisation_graphs. Might make sense to link that directly instead?

Copy link
Member

Choose a reason for hiding this comment

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

(admitedly that repressilator is implemented using a slightly simplified network)

![Repressilator solution](../assets/repressilator.svg)

We also showed in the [Introduction to Catalyst](@ref introduction_to_catalyst) tutorial that
the reaction rate equation ODE model for the repressilator is
Copy link
Member

Choose a reason for hiding this comment

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

first mention of the RRE, maybe change this to "reaction rate equation (RRE)" and use rre later on?

```@example s1
rn = @reaction_network begin
k, 2*A + 3*B --> A + 2*C + D
b, C + D --> 2*A + 3*B
Copy link
Member

Choose a reason for hiding this comment

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

Think, generally, we have used k, 2A + 3B --> A + 2C + D (no *) across the docs. But feel free to use your preferred notation.

```

Note that we have used `isequal` instead of `==` here because `laplacianmat`
returns a `Matrix{Num}`, since some of its entries are symbolic rate constants.
Copy link
Member

Choose a reason for hiding this comment

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

I might add a parenthesis or something here explaining that == does not work for symbolic variables (i.e. Nums). Don't think this is common knowledge to many new-to intermediate users.

laplacianmat(rn, parammap)
```

# Symbolic ODE functions
Copy link
Member

Choose a reason for hiding this comment

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

I think so far (not sure by chance or planning, but I stick to it these days) we only use # Title for the first header of each doc page. Then subsequent ones uses ## Sub heading and ### Subsub heading and such.

@@ -681,10 +681,12 @@ end
# Reads the variables options. Outputs a list of the variables inferred from the equations,
# as well as the equation vector. If the default differential was used, update the `diffsexpr`
# expression so that this declares this as well.
function read_equations_option!(diffsexpr, options, syms_unavailable, tiv; requiredec = false)
function read_equations_option!(
diffsexpr, options, syms_unavailable, tiv; requiredec = false)
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably make the line break after tiv;, if possible.

@@ -739,7 +741,8 @@ end
# Reads the observables options. Outputs an expression for creating the observable variables,
# a vector containing the observable equations, and a list of all observable symbols (this
# list contains both those declared separately or inferred from the `@observables` option` input`).
function read_observables_option(options, all_ivs, us_declared, all_syms; requiredec = false)
function read_observables_option(
options, all_ivs, us_declared, all_syms; requiredec = false)
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably make the line break after all_syms;, if possible.

@@ -1461,7 +1472,8 @@ Notes:
- Returns a new `ReactionSystem` and does not modify `rs`.
- By default, the new `ReactionSystem` will have the same name as `sys`.
"""
function ModelingToolkit.compose(sys::ReactionSystem, systems::AbstractArray; name = nameof(sys))
function ModelingToolkit.compose(
sys::ReactionSystem, systems::AbstractArray; name = nameof(sys))
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably put the line break after systems::AbstractArray;, if possible.

@@ -0,0 +1,332 @@
> Note, currently API functions for network analysis and conservation law analysis
> do not work with constant species (currently only generated by SBMLToolkit).
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably remove this one, doesn't feel like something we need everywhere, given the niche ness of the situation.

If it is something that can yield a silent error, it might make sense to add it as a warning later on. Howeverstarting the tutorial with a note about something that most users won't know about or encounter seems irrelevant. And if it is restricted to SBMLToolkit the warning might be better there.


Broadly, results from chemical reaction network theory relate a purely
graph-structural property (e.g. deficiency) to dynamical properties of the reaction system
(e.g. complex balance). The relevant graph here is the one corresponding to the [reaction complex representation](@ref network_analysis_reaction_complexes)
Copy link
Member

Choose a reason for hiding this comment

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

Here I'd make the deficiency and complex balance links to corresponding sections (if nothing else to mark that these are terms we do not necessarily expect the reader to know at this stage).


## [Deficiency of the network](@id network_analysis_structural_aspects_deficiency)
A famous theorem in Chemical Reaction Network Theory, the Deficiency Zero
Theorem [^1], allows us to use knowledge of the net stoichiometry matrix and the
Copy link
Member

Choose a reason for hiding this comment

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

No space in Theorem [^1]

Copy link
Member

Choose a reason for hiding this comment

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

I.e. Theorem[^1]

Copy link
Member

Choose a reason for hiding this comment

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

(I think)

calculate a network's deficiency.

The rank, ``r``, of a reaction network is defined as the dimension of the
subspace spanned by the net stoichiometry vectors of the reaction-network [^1],
Copy link
Member

Choose a reason for hiding this comment

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

No space in Theorem [^1]


For the set of reactions $A \to B, B \to A, B \to C$, $\{A, B, C\}$ is a linkage class, and $\{A, B\}$ is a strong linkage class (since A is reachable from B and vice versa). However, $\{A, B\}$ is not a terminal linkage class, because the reaction $B \to C$ goes to a complex outside the linkage class.

If these conditions are met, then the network will have at most one steady state in each stoichiometric compatibility class for any choice of rate constants and parameters.
Copy link
Member

Choose a reason for hiding this comment

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

no line break

"network_analysis/odes.md",
"network_analysis/crn_theory.md",
"network_analysis/network_properties.md",
"network_analysis/advanced_analysis.md"
Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this order, having the ODE section first makes sense as it nicely feeds into the next one. On the other hand, most users will likely have more use of the subsequent sections, which makes it make sense to have that earlier.

Maybe keep it for now, and then as this gets more fleshed out we can make a "Introduction to Network" analysis section, which basically explains what this is all about, when it can be useful, and where to find the useful bits.
(i.e. a new user that know very little should likely first know about the network analysis summary function, and maybe be directed to know about conservation laws).

@isaacsas
Copy link
Member

isaacsas commented Apr 2, 2025

Can you remove the full repo format? We haven’t been using formatter due to the bugs it introduced in one release last year. While I’m fine with re-enabling it that should really be in a separate PR so we can check nothing is getting broken. (Feel free to run it on the files you are actually editing here though.)

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.

3 participants