Repository navigation
Add a notebook on hierarchical (tuple-valued) states - #20
Merged
Merged
Conversation
The notebook models cells with a (cell_type, k) state: a differentiation hierarchy (progenitor -> intermediate -> terminal) combined with K cell-cycle stages. Cells divide only in the last stage, which gives gamma-distributed generation times with mean T_gen and standard deviation T_gen / sqrt(K). Intermediate cells have the highest death rate. The notebook renders trees colored by cell type for K = 1, 4, and 32, and shows that divisions stay synchronized for large K. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a fresh environment, the first matplotlib import prints "Matplotlib is building the font cache" to stderr, which nbval reports as an unexpected output of the first notebook cell that imports matplotlib. This failed CI once hierarchical_states.ipynb became the first notebook to run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the font cache The performance notebook already tags its first cell with nbval-ignore-output, so that the message matplotlib prints while building its font cache doesn't fail nbval. Tag the first cell of hierarchical_states.ipynb the same way, now that it runs first, and remove the extra step in the tests script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also includes two wording edits made in the notebook directly: the intro no longer mentions the required BDMS version, and the text before cell_cycle_model describes what the function builds and why it's a function. The sentence about dashed branches now cites the death rate, since intermediates aren't the majority of deaths in every tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs the single-tree simulations for 10 mean generation times instead of 8, with the tree renders re-executed, and removes the closing note about other combinations of attributes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Simulate only with K = 100, building the processes and mutator inline and passing them to evolve directly, without the cell_cycle_model and render helper functions. The generation-time densities for K = 1, 10, and 100 are now overlaid on one plot, labeled directly. The tree render and the synchronization histogram are for K = 100 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generation-time plot now shows K = 1, 10, 100, and 1000 with the default matplotlib colors and a legend, and the synchronization histogram uses bins of T_gen / 15. Reference lines are black. The notebook was re-run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a tutorial notebook,
docs/notebooks/hierarchical_states.ipynb, listed in the docs between the quickstart and performance notebooks. It shows how to use a tuple as a node state, which BDMS supports since 1.0.1 (#19).The model
Each cell's state is
(cell_type, k), combining a differentiation hierarchy (progenitor → intermediate → terminal) withKcell-cycle stages:k < K - 1moves to stagek + 1at rateK / T_gen, as BDMS mutation events.K / T_gen. A cycle is thenKexponential stages, so generation times are gamma (Erlang) distributed with meanT_genand standard deviationT_gen / sqrt(K), andK = 1is an ordinary birth process.birth_mutation_prob=1.0, each daughter gets a mutation event at birth. The mutator's transition matrix sends the last stage to stage 0 of the daughter's cell type, chosen with fixed probabilities.I used a finite birth rate in the last stage rather than an infinite one, so that all
Kstages have the same mean andK = 1reduces to the exponential case.What the notebook shows
K = 1, 10, and 100, overlaid on one plot in a light-to-dark gray ramp, with a legend and labels on the curves.K = 100for 10 mean generation times, rendered with branches colored by cell type and a color key. Divisions happen in nearly synchronized waves.T_genand spread out over time.The processes and mutator are built inline and passed to
Tree.evolvedirectly, with no helper functions. The cell-type colors are the first three slots of a palette that passes colorblind-separation checks for every pair of colors, and blue isn't reused elsewhere in the notebook, so it only ever means progenitor.nbval tag
In a fresh environment, the first matplotlib import prints "Matplotlib is building the font cache" to stderr, which nbval treats as an unexpected output. The performance notebook's first cell is tagged
nbval-ignore-outputfor this reason. Notebooks run alphabetically, so this notebook now runs first, and its first cell has the same tag.Testing
On Python 3.15, nbval passes on all three notebooks. On Python 3.13,
hatch run testspasses in a fresh clone with an empty matplotlib cache, as in CI. The new notebook takes about 40 seconds, most of it the 200 simulations for the synchronization histogram. Ruff passes on the notebook, and the docs build without new warnings.🤖 Generated with Claude Code