Usage¶
Entry points¶
The repository currently exposes two practical usage modes:
- direct script execution via
python rlto_model.py, - importing objects and functions from
rlto_model.py.
There is no dedicated CLI parser in the current codebase.
Script mode¶
This triggers example_usage() and performs a full demonstration workflow on the built-in synthetic dataset.
What the script does¶
- constructs a moderately stressful
Microenvironment, - loads the synthetic demo dataframe,
- creates a
CancerRLTOModel, - runs gene-level optimization across all genes,
- performs tumor-level global optimization,
- optimizes inhibition for
TOXIC_DRIVER, - writes diagnostic plots into
diagnostic_plots/, - prints a JSON summary.
Import mode¶
Build from the demo dataset¶
from rlto_model import CancerRLTOModel, Microenvironment
env = Microenvironment(hypoxia=0.6, nutrient_limitation=0.4)
model = CancerRLTOModel.from_dataframe(
CancerRLTOModel.demo_dataset(),
microenvironment=env,
)
Build from your own dataframe¶
import pandas as pd
from rlto_model import CancerRLTOModel, Microenvironment
df = pd.read_csv("genes.csv")
env = Microenvironment(hypoxia=0.2, drug_pressure=0.5)
model = CancerRLTOModel.from_dataframe(df, microenvironment=env)
Common operations¶
Evaluate the current state¶
Summarize by pathway¶
Compute a scalar tumor score¶
Optimize one gene¶
Optimize all genes independently¶
Optimize the whole tumor state jointly¶
Simulate inhibition¶
Find the best inhibition level¶
Recommended analysis pattern¶
results = model.evaluate()
opt_gene = model.optimize_all()
pathways = model.pathway_summary()
score = model.tumor_fitness_score()
Then move to diagnostics only when you need to inspect model shape or optimization behavior.
Reproducibility notes¶
- The main analytical fitness calculation is deterministic.
- The model still initializes an RNG and exposes
sample_abundance(). - The diagnostics API contains labels such as “noise stability”, but the current analytical implementation does not rely on Monte Carlo sampling for
net_gene_fitness().
Note
The n_samples parameter is preserved in several method signatures for compatibility, but the analytical path means it is largely not used by the core fitness calculation.