Skip to content

Core model API

Data containers

Microenvironment

Microenvironment dataclass

GeneConfig

GeneConfig dataclass

Per-gene parameters for the cancer RLTO-inspired model.

ModelResult

ModelResult dataclass

Main model

CancerRLTOModel

CancerRLTOModel

Cancer-adapted threshold/noise/burden model.

robustness_probability

robustness_probability(
    gene: GeneConfig, mean_abundance: Optional[float] = None
) -> float

Calculates the exact analytical probability that abundance >= threshold.

net_gene_fitness

net_gene_fitness(
    gene: GeneConfig,
    mean_abundance: Optional[float] = None,
    n_samples: int = 0,
) -> ModelResult

Calculates fitness analytically, entirely eliminating Monte Carlo noise. (n_samples is kept in the signature for backwards compatibility but is no longer used).

optimize_global

optimize_global(
    n_samples: int = 0, global_resource_weight: float = 0.5
) -> Tuple[np.ndarray, float]

Finds the optimal abundance vector across all genes simultaneously, enforcing carrying capacity.

optimize_inhibition

optimize_inhibition(
    target_gene: str, n_samples: int = 10000
) -> Tuple[float, float]

Finds the precise inhibition level (0 to 1) that minimizes tumor fitness.

demo_dataset staticmethod

demo_dataset() -> pd.DataFrame

A comprehensive synthetic dataset designed to stress-test the bounds, edge cases, and trade-offs of the Cancer RLTO model.

Practical usage notes

For most workflows, prefer dataframe ingestion:

from rlto_model import CancerRLTOModel, Microenvironment

env = Microenvironment(hypoxia=0.3, drug_pressure=0.2)
df = CancerRLTOModel.demo_dataset()
model = CancerRLTOModel.from_dataframe(df, microenvironment=env)

Methods you will use most often

Method Purpose
evaluate() rank the current gene set
optimize_gene_abundance() optimize one gene
optimize_all() optimize all genes independently
optimize_global() jointly optimize the tumor state
simulate_intervention() apply an inhibition fraction to one target
optimize_inhibition() search for the best inhibition level
pathway_summary() group outputs by pathway
tumor_fitness_score() derive a scalar summary score

Behavior caveat

Several methods retain n_samples arguments for compatibility, but the main fitness calculation is analytical.