Code accompanying: Pan-cancer spatial characterization of key immune biomarkers in the tumor microenvironment. Cell Reports Medicine (2025).
Code summary:
- compute_cell_densities.py: Compute cell densities for immune biomarkers.
- calc_gross.R; compute_prox_scores.py: Compute proximity scores for immune biomarkers. The R script is run first.
- compute_pca.py: Perform PCA to calculate TiME spatial factors.
- genomics_analysis.ipynb: Notebook for calculating genomics associations.
- plotting.py: Performs analysis and creates plots of the results.
Tested with Python 3.9.12 and R 4.4.0
Python packages used: lifelines (0.27.4), matplotlib (3.6.2), numpy (1.23.4), pandas (1.5.0), scipy (1.13.1), seaborn (0.12.1), scikit-learn (1.1.3), scikit-survival (0.19.0), statsmodels (0.14.0), tqdm (4.63.0)
R packages used: arrow (18.1.0), dplyr (1.1.4), spatstat (3.3.0)
Installation of all packages and running the code of the sample data should each take less than 30 minutes.