Skip to main content

docs

clone-competition-simulation

Python3 simulations of clone competition during ongoing mutagenesis.

Installation

First install GNU Scientific Library (homebrew) and FFMPEG (homebrew).

Then install from PyPi, e.g.

pip install clone-competition-simulation

Alternatively, install using the code from GitHub.

Install UV.

Clone the git repository
git clone https://github.com/michaelhall28/clone-competition-simulation.git

and install the code in this repository
uv pip install -e .

Running simulations

First, the parameters for the simulation are defined. The Parameters class checks that the parameters are appropriate for the chosen algorithm. e.g.

from clone_competition_simulation.parameters import Parameters, TimeParameters, PopulationParameters, FitnessParameters
from clone_competition_simulation.fitness import Gene, UniformDist, FitnessCalculator, multiply_fitness

# Define the effect of mutations that appear during the simulation
fitness_calculator = FitnessCalculator(genes=[Gene(name='example_gene', 
                                                   mutation_distribution=UniformDist(1, 2), synonymous_proportion=0.5)],
                                       combine_mutations=multiply_fitness)

p = Parameters(
        algorithm="WF2D",
        population=PopulationParameters(grid_shape=(100, 100), cell_in_own_neighbourhood=True),
        times=TimeParameters(max_time=20, division_rate=1),
        fitness=FitnessParameters(mutation_rates=0.01, fitness_calculator=fitness_calculator)
    )

Then the simulation can be initialised and run from the parameter object

s = p.get_simulator()
s.run_sim()
s.muller_plot()

Each parameter class has a docstring describing how to use the arguments (e.g.help(TimeParameters) or print(TimeParameters.__doc__)).
See the docs for more detailed guides.

Updates from version 0.0.1 (pre-2025)

  • The parameters are grouped by theme (timing, cell population, mutation fitness etc). Can be grouped using the parameter classes or using dictionaries.
  • Some parameters have to be explicitly given instead of using default values (max_time, division_rate, fitness_calculator, cell_in_own_neighbourhood)
####  Old 
p = Parameters(
    algorithm='WF2D', 
    grid_shape=(100, 100),
    mutation_rates=0.01,
)

####  New 
p = Parameters(
    algorithm='WF2D',
    population=PopulationParameters(grid_shape=(100, 100), cell_in_own_neighbourhood=False),
    times=TimeParameters(max_time=10, division_rate=1),
    fitness=FitnessParameters(mutation_rates=0.01, fitness_calculator=fitness_calculator)
)
# or
p = Parameters(
    algorithm='WF2D',
    population=dict(grid_shape=(100, 100), cell_in_own_neighbourhood=False),
    times=dict(max_time=10, division_rate=1),
    fitness=dict(mutation_rates=0.01, fitness_calculator=fitness_calculator)
)
  • A yml file can be used to supply parameters. These can be combined with __init__ parameters.
  • Biopsies are now Pydantic classes (from clone_competition import Biopsy) instead of dictionaries
  • Plot colours are specified in a new way
  • Custom functions can be used for combining fitness values from different mutations
  • Custom cell competition rules are now easier to implement

See the docs for more details.

Algorithms

There are 5 algorithms that can be run.

Non-spatial algorithms:

  • "Branching". A branching process based on the single progenitor model from Clayton, Elizabeth, et al. "A single type of progenitor cell maintains normal epidermis." Nature 446.7132 (2007): 185-189.
  • "Moran". A Moran-style model. At each simulation step, one cell dies and another cell divides, maintaining the overall population.
  • "WF". A Wright-Fisher style model. At each simulation step an entire generation of cells is produced from the previous generation.

2D algorithms:

  • "Moran2D". A Moran-style model constrained to a 2D hexagonal grid. At each simulation step, one cell dies and a cell from an adjacent location in the grid divides, maintaining the overall population.
  • "WF2D". A Wright-Fisher style model constrained to a 2D hexagonal grid. At each simulation step an entire generation of cells is produced from the previous generation, where cell parents must be from the local neighbourhood in the grid.

These algorithms can also be used as a framework for custom cell competition rules.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clone_competition_simulation-0.5.2.tar.gz (266.3 kB view details)

Uploaded Source

File details

Details for the file clone_competition_simulation-0.5.2.tar.gz.

File metadata

  • Download URL: clone_competition_simulation-0.5.2.tar.gz
  • Upload date:
  • Size: 266.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for clone_competition_simulation-0.5.2.tar.gz
Algorithm Hash digest
SHA256 943f990e9c2154ae4209ccd768af459bf83ead1a5bc143e63cbab6296e45d4af
MD5 abf6552fdaef3c609ea8bc671b0b96cd
BLAKE2b-256 0181f154f6befce4f7a8595c1ea6405dcf6f26556230575920649c44065f86d3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.7.1

1 file

0.7.0

1 file

0.6.0

1 file

This release

0.5.2 This release

1 file

0.5.1

1 file

0.5.0

1 file

0.4.0

1 file

0.3.1

1 file

0.2.0

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page