This repository contains the code that underlies analyses and figures shown in the paper "ImmuNet: A Segmentation-Free Machine Learning Pipeline for Immune Landscape Phenotyping in Tumors by Muliplex Imaging" by Sultan et al (https://doi.org/10.1093/biomethods/bpae094).
For all figures except Figure 5, the following software is sufficient:
Conda, minimum version 24.9.2Latex, including XeLaTeX engine
Then, a figure can be built by running bash run.sh from its root folder. This script automatically creates a virtual environment with all dependencies installed, runs data analysis scripts in the correct order, and eventually builds a figure with Latex.
By default, the code that evaluates the model performance shown in Figures 3 and 4 uses the cached prediction for time efficiency. We also provide an option to directly detect immune cells in in mIHC images with the final model used in the paper. This requires hardware supporting TensorFlow 1.14.0 and R (minimum version 4.3.0).
Figure 5:
R, minimum version 4.3.0
The data needed to reproduce the analysis performed in the paper and to build the figures are located on Zenodo archive; the folder hierarchy in the data archive matches the folder hierarchy in this repository. Before building a figure, you need to make sure that its folder contains all the necessary assets: code, data, external images, a Makefile, and a Latex file that defines the figure layout. The typical file hierarchy inside a figure folder is:
- code
- data
- images
- plots
Makefile
figure.tex
requirements.txt
run.sh
The code folder contains the source code that reproduces the analysis and generates auxiliary data files and plots. The data folder contains the data required for the analysis. External assets that are needed to complete the figure should be located in the images folder. The plots that visualise the results of the data analysis are saved in the plots folder, which is created automatically. The Makefile specifies the order in which the analysis scripts must be run, with the figure.pdf file as the final target, built with the figure.tex file. The run.sh script creates a conda environment based on the dependencies (R and Python) listed in the requirements.txt and then executes make.
Steps to reproduce a figure:
- Place the data needed for a figure in the
datafolder. This includes everything exceptimages.tar.gz, - In the
datafolder, uncompress all the.tar.gzarchives (but do not uncompress the.gzfiles), - Extract
images.tar.gzinto theimagesfolder, - Run
bash run.sh.
Note, that creation of a conda environment and execution of the code might take a while for some figures.
Figure specific instructions are given below.
By default, the cached prediction (prediction.tar.gz) from ImmuNet and the baseline algorithm InForm will be used to reproduce the analysis. However, an option to run inference on mIHC images with ImmuNet is provided. To do this, you need to extract the corresponding image archive into the data folder:
tilecache.tar.gz- for Figure 3rois_tilecache.tar.gz- for Figure 4
Then, use the run_tf.sh script which creates a conda environment with TensorFlow 1.14. Note: due to of the conflict between the Python version that supports TensorFlow 1 and the required R version, R packages will be installed in your default R!
This figure uses Bioconductor software that is difficult to install with conda, therefore the required R packages have to be installed manually. Steps to build a figure:
- Fill in the
dataandimagesfolders as described above, - Install R packages:
irr=0.84.1,BiocManager=1.30.25,polyclip=1.10-7,remotes=2.5.0, - Run
BiocManager::install("flowCore"), - Run
remotes::install_github("jtextor/tiltools"), - Run
makein the root folder of the figure.
- We use the
Helvetica Neuefont family for text on figures. If it is not installed on your system, you can change the fonts in thesettings.Rfile located in the root folder of the repository and in the\setmainfontcommand of eachfigure.texfile. - On some systems
condamay fail to resolve the dependencies. Switching to mamba should fix the issue.