Spatially distinct chromatin compaction states predict neoadjuvant chemotherapy resistance in Triple Negative Breast Cancer
This repository implements an analysis pipeline for TNBC FLIM data, including preprocessing and nuclei segmentation, feature extraction, classification models for predicting neoadjuvant chemotherapy resistance and spatial analysis (see Repository overview). It also provides scripts (see Direct Script Run) and usage examples (see Notebook Examples) that enable running individual stages of the pipeline, alongside reproducible notebooks to recreate the paper’s results.
Reut Mealem1*, Thomas. A. Phillips2*, Leor Ariel Rose1*, Stefania Marcotti2, Maddy Parsons2&, Assaf Zaritsky1&
- Institute for Interdisciplinary Computational Science, Faculty of Computer and Information Science, Ben-Gurion University of the Negev, Beer-Sheva 84105, Israel
- Randall Centre for Cell and Molecular Biophysics, King’s College London, Guy’s Campus London, SE1 1UL, UK
- * Equal contribution
- & Co-corresponding authorship
Organisation and dynamics of chromatin play a key role in regulation of cell state and function. In cancer, chromatin plasticity is known to be important in control of drug resistance, but the relationship between chromatin compaction and chemotherapy response within complex tissue settings remains unclear. Here, we measured single nuclei chromatin compaction using fluorescence lifetime imaging microscopy (FLIM) in situ in whole biopsies from 53 pre-treatment and 14 post-surgery tissue samples of human triple-negative breast cancer (TNBC) patients to determine whether single nuclei spatial chromatin compaction state can predict resistance to neoadjuvant chemotherapy (NACT). Bulk chromatin compaction across 53 pre-treatment core biopsies did not predict patient outcome. However, machine learning analysis revealed that a subset of patients exhibited distinct distributions of single nuclei with more open chromatin states, which was predictive of NACT-resistance.
Graph neural network analysis established that the spatial arrangement of chromatin compaction contributed to prediction of NACT resistance and that chromatin compaction signatures were preserved in tissue state transitions from pre- to 14 post-NACT samples. Our findings shed new light on spatial control of chromatin structure and relationship to therapeutic resistance and establish a foundation for further molecular analysis of chromatin states in complex biological tissues.
To read the full research paper, go to the following link - Spatially distinct chromatin compaction states predict neoadjuvant chemotherapy resistance in Triple Negative Breast Cancer
This repo is based on a retrospective cohort obtained from triple-negative breast cancer (TNBC) patients prior to neoadjuvant chemotherapy (NACT). You must download it and set the paths in the code before running anything.
FLIM/
├── cohort_metadata.csv # Clinical metadata
├── raw/ # Raw FLIM images
│ ├── LEAP015_slide7_extreme-non-responder_0countthreshold.tif
│ └── ... Other .tif files corresponding to each LEAP ID
├── segmentations/ # Single nuclei segmentation maps (can also be created by the repo using the raw data)
│ ├── LEAP015_segmentation_labels.tif
│ └── ... Other .tif files corresponding to each LEAP ID
├── segmentations_after_qc/ # Single nuclei segmentation maps after quality control (can also be created by the repo using the raw data and segmentation maps)
│ ├── LEAP015_segmentation_labels_qc.tif
│ └── ... Other .tif files corresponding to each LEAP ID
└── metadata/ # Image acquisition metadata
├── LEAP015_slide7_extreme-non-responder_0countthreshold_properties.xml
└── ... Other .xml files corresponding to each LEAP IDDownload the dataset from BioImage Archive to your local machine (339 files). The folder structure should match the one shown in the Data overview section (you can refer to the BioImage Archive's download help guide, which includes options for bulk download). After downloading, make sure you set the required input data directory specified in config/const.py by the DATA_DIR variable to where the data is stored on your local machine. Any data related computational outputs (segmentations, segmentations_after_qc) will also be saved in this directory if you decide to run the code.
DATA_DIR = "PATH-TO-THE-DATA"By default, in our code this path is defined relative to the BASE_DIR directory like so:
DATA_DIR = os.path.join(BASE_DIR, 'data')You must clone the repository and change directory into the cloned repository. Run the following commands:
git clone https://github.com/zaritskylab/TNBC-SPATIAL-CHROMATIN-COMPACTION
cd TNBC-SPATIAL-CHROMATIN-COMPACTIONMake sure the pyproject.toml file lives at the root of the repo as it is required for correct installation of the Python environment and packages. Run the following commands:
conda env create -f environment.yml
conda activate tnbc_flim
pip install -e .Before running any part of this code, make sure you set the base directory for the analysis specified in config/const.py by the BASE_DIR variable. This is where all the data and computational outputs will be saved.
# config/const.py
BASE_DIR = "/your/full/path/to/analysis"TNBC-SPATIAL-CHROMATIN-COMPACTION/
├── config/ # Folder for code configurations such as paths and experiment-level configuration settings
│ ├── const.py # Paths configuration
│ └── params.py # Experiments configuration
│
├── flim_analysis/ # Main source code organized by functional domain
│ ├── distribution_classification/ # Distribution-based classification using cross-validation and robust model evaluation techniques
│ ├── feature_extraction/ # Scripts for extracting FLIM and morphological features at both the patch and full-tissue level
│ ├── gnn_classification/ # End-to-end GNN pipeline
│ ├── preprocessing/ # Tissue segmentation and preprocessing workflows to prepare input for feature extraction
│ ├── resection_analysis/ # Contains Jupyter notebooks related to resection-based spatial analysis
│ └── spatial_analysis/ # Contains spatial metrics and related analysis. Some data preparation is also done in the notebook `spatial_analysis/spatial_information.ipynb`
│
├── notebooks/ # Top-level directory for exploratory and paper-figure creation notebooks
│ ├── analysis_paper_result_reproduce/ # Contains both main and supplementary figure notebooks
│ └── usage_example/ # Contains runnable examples demonstrating how to use the main components of the pipeline
│
├── sbatch/ # SLURM job submission scripts for running tasks on HPC clusters
├── utils/ # Helper functions used across the pipeline
├── pyproject.toml
└── environment.ymlYou should run the scripts in the order given here as some depend on others (unless explicitly stated as not required).
# Processing of the raw images (not contained in the data directory and should be run)
python flim_analysis/preprocessing/processing.py# IMPORTANT NOTE: This step is not required as data folder already contains segmentations.
# Running this script will overwrite the existing data segmentation outputs in SEG_DIR and SEG_AFTER_QC_DIR.
python flim_analysis/preprocessing/segmentation.py# Full tissue feature extraction
python flim_analysis/feature_extraction/extract_features.py core# Lifetime distribution creation with default 18 bins and median features lifetime extraction
python flim_analysis/feature_extraction/create_distribution_and_median.py core --max-val 13 --bin-range 0.73 # Tissue-wise lifetime distribution treatment classification
python flim_analysis/distribution_classification/treatment_classification_tissue_wise --dist_csv_name features_lifetime_distribution_data_max_val_13_bins_amount_18_bin_range_0.73.csv --n_seeds 100 --n_permutations 1000# Patch feature extraction
python flim_analysis/feature_extraction/extract_features.py patch --patch-size 1500 --overlap 0.75# Patch lifetime distribution creation with default 18 bins
python flim_analysis/feature_extraction/create_distribution_and_median.py patch --patch-size 1500 --overlap 0.75 --max-val 13 --bin-range 0.73 # Patch-wise lifetime distribution treatment classification
python flim_analysis/distribution_classification/treatment_classification_patch_wise --dist_csv_name features_lifetime_distribution_data_patches_size_1500_overlap_0.75_max_val_13_bins_amount_18_bin_range_0.73.csv --patch_size 1500 --n_seeds 100 --n_permutations 1000# Graphs building for GNN training - construct graphs from extracted features
python flim_analysis/gnn_classification/build_graphs/build_graph_main.py gnn --patch-size 1500 --overlap 0.75 --feature_type 'lifetime' --max_dist 30# Conversion of graphs to PyTorch Geometric data objects for GNN training
python flim_analysis/gnn_classification/create_pytorch_geo_data/process_data_pytorch_geo_main.py gnn --patch-size 1500 --overlap 0.75 --feature_type 'lifetime' --max_dist 30# Training and evaluation of GNNs
python flim_analysis/gnn_classification/train_model/train_gnn_model_main.py gnn --patch-size 1500 --overlap 0.75 --feature_type 'lifetime' --max_dist 30 --k-fold 5 --model-id 1 --n_seeds 20# Resection feature extraction
python flim_analysis/feature_extraction/extract_features.py resection# Create median features data frame
python flim_analysis/feature_extraction/create_distribution_and_median.py resectionThe notebooks/usage_example folder contains three Jupyter notebooks that illustrate three main parts of the analysis workflow:
-
run_example_preprocess_segmentation.ipynb
Demonstrates data preprocessing, segmentation and segmentation quality control. -
run_example_feature_extraction.ipynb
Shows how to run feature extraction on preprocessed and segmented data. -
run_example_gnn_build_train.ipynb
Builds graphs and trains the GNN model using extracted features.
Each notebook may depend on earlier processing, and any such dependencies are noted at the beginning.
The notebooks under notebooks/analysis_paper_result_reproduc/ are used to recreate the figures presented in the paper.
They are organized by figure number and contain both main-figure and supplementary-figure notebooks:
_preparation.ipynbvs_visualize.ipynbconvention used for clean separation between data generation and plottingFigure_1.ipynb–Figure_4.ipynb: Main paper figuresSupplementary/: Supplementary figure generation and visualization notebooks
This repository is released under the Creative Commons Attribution–NonCommercial 4.0 International License. See LICENSE for details. Commercial use is not permitted, and any reuse or modification requires proper attribution to the original authors.
If you use this code or implementation in your research, please cite:
@article{mealem2025spatial,
title={Spatially distinct chromatin compaction states predict neoadjuvant chemotherapy resistance in Triple Negative Breast Cancer},
author={Mealem, Reut and Phillips, Thomas A. and Rose, Leor Ariel and Marcotti, Stefania and Parsons, Maddy and Zaritsky, Assaf},
journal={bioRxiv},
pages={2025.12.04.692131},
year={2025},
publisher={Cold Spring Harbor Laboratory},
doi={10.64898/2025.12.04.692131}
}Please contact [email protected] or [email protected] for comments or questions regarding this repo.