sergiyayf / PhysiLearning

Reinforcement Learning repo for PhysiCell adaptive therapy
0 stars 0 forks source link

PhysiLearning

CI coverage version

PhysiLearning is a project in applying Reinforcement Learning to improve evolution based therapies considering physical cell-cell interactions. This repository is mainly build on two great open source platforms: PhysiCell - for simulating tumor growth, and Stable Baselines 3 - for reinforcement learning.

Installation

Clone the repository and install the main package with pip

git clone
cd PhysiLearning
pip install -e .

You will also need to install ZMQ cpp library. On Ubuntu:

sudo apt-get install libzmq-dev

After you installed zmq update ZMQLIB flag in src/PhysiCell_src/Makefile with the path to the library.

Usage

Usage of the package is aimed to be user-friendly and require minimal coding. Most of the configuration is done through the config.yaml file that controls both the environment(simulation) and the agent.

See the config.yaml file for more details on the configuration, it should be self-explanatory.

First steps

To make sure that PhysiCell works on your machine, run the following command:

make raven

or

make mela

depending on where you want to run the simulation. This will recompile PhysiCell with the options that are machine specific.

Training

To train the agent on ubuntu with installed slurm queuing system, run the following command:

python run.py train

List of example policies

This is for now only an example, these values will not work

Usage policy_kwargs Description
Number obs dict('net_arch': dict('pi': [32, 32], 'vf': [32, 32)) Control the size of actor and critic networks
Image/Multi obs dict('cnn_output_dim': 16) Control number of extracted features from images

Evaluation

To evaluate the agent, run the following command:

python run.py evaluate

Simulating virtual patients with barcode tracking

To simulate virtual patients with barcode tracking PhysiCell config via ./config.yaml is not supported. You need to first configure your simulation in the ./src/PhysiCell_src/config/PhysiCell_settings.xml file. Then you need to copy the PhysiCell source directory to the ./simulations folder. You can do it with a script:

bash create_dirs.sh number_of_copies

Then you might need to reconfigure the ./scripts/simulate_patients_job.sh script to load correct modules and use correct resources. In config.yaml parameter envs::PcEnv::cpus_per_sim and envs::PcEnv::transport_address also need to be adjusted.

Then you can submit the jobs with:

python run.py simulate-patients --n_sims=number_of_simulations

On raven about 10 simulations will run in one job on one node in parallel. In the script ./scripts/simulate_patients.py parameter num_episodes will define how many times simulations from one directory will run. If you don't care about the PhysiCell original data, you can make this number larger than 1. Data will be stored by the PCDL class into hdf5 file, 1 file per simulation folder, and will contain cell IDs, positions, barcodes, types and time in the current phase.

Run tests

To run all tests, run the following command:

make pytest

or run single tests with:

pytest tests/test_evaluate.py

Changelog

0.3.5 Major Changes

0.3.4 Major Changes

0.3.3 Major Changes

0.3.1 Major Changes

0.3.0 Major Changes

0.3.0 Minor Changes

0.2.4 Changes

0.2.2 Major changes

0.2.2 Minor changes

0.2.0 Major changes

0.2.0 Minor changes

0.1.6 Major changes