For this tutorial, we assume the user is using the following path and has Docker properly set up: /home/user/card_demo
. It is also assumed that the user has access to a machine with a GPU and the right memory set up.
Donwload the code from the github repository
git clone https://github.com/Sanofi-Public/spatialone-pipeline.git
cd spatialone-pipeline
Download the two cancer samples, the reference data for deconvolution, and the default configuration files.
./download_experiment_data.sh
Hovernet can work with different weights, as described in their official repository. To use the CONSEP weights and labels described in the SpatialOne paper you should download them on the reference folder.
You can manually download them from the author's site, from Zenodo (weights, labels) or you can execute the following two instructions:
curl -L -o reference/hovernet_original_consep_type_tf2pytorch.tar "https://zenodo.org/records/12801948/files/hovernet_original_consep_type_tf2pytorch.tar?download=1"
curl -L -o reference/type_info.json "https://zenodo.org/records/12801948/files/type_info.json?download=1"
Prepare your environment to build the container images if necessary. To that end, edit the .env
file:
HOST_DATA_PATH = /home/user/card_demo/spatialone-pipeline
GPU_DEVICE_ID = 0
Export proxies only if necessary:
export HTTP_PROXY=http://your.proxy.url:port
export HTTPS_PROXY=http://your.proxy.url:port
Build the docker containers:
make docker-build
Note that this operation may take up to 20 minutes
Edit the config file located at $HOST_DATA_PATH/conf/visium_config_flow.yaml
(in our case ./conf/visium_config_flow.yaml
) to reflect an appropriate configuration. You'll need to define the pipelines to run, and set up Hovernet & CARD.
Ensure that all the pipelines are enabled:
pipelines.enabled:
imgseg: True # cell segmentation
cell2spot: True # matching cells to visium spots
celldeconv: True # cell deconvoluiton
cluster: True # morphological clustering
assign: True # cell assignment integrates celldeconvolution with cell segmentation
qc: True # QC metrics generation
datamerge: True # To visualize in Tissuumaps enable "datamerge: true"
spatialanalysis: True # Spatial analysis reporting
Remove the cellpose
configuration section and uncomment the hovernet
section:
imgseg:
image.resolution: "400dpi"
image.magnification: "20x"
model:
name: "hovernet"
version: "0.0.1"
params:
gpu: '0'
nr_types: 5
batch_size: 16
model_mode: "original"
nr_inference_workers: 1
nr_post_proc_workers: 1
wsi: True
tile: False
help: False
model_name: "hovernet_original_consep_type_tf2pytorch.tar"
type_filename: "type_info.json"
Please note that if you plan to use a different set of weights than hovernet_original_consep_type_tf2pytorch you should update the model_name
and the type_filename
parameters.
Remove the cell2location
section and uncomment the CARD
block:
celldeconv:
model:
name: "card"
version: "X.X.X"
params:
min_count_gene: 100
min_count_spot: 5
ct_varname: 'cellType'
ct_select: 'NULL'
atlas_type: 'luca'
sc_label_key: 'luca'
sc_sample_key: 'batch'
Ensure to update the atlas_type
parameter to luca
to match the reference dataset with the type of tissue analyzed in the example. If you plan to use a different reference dataset, make sure to set up the appropriate refernce dataset name.
Run the analysis:
make docker-start
By following these steps, you will set up and run a SpatialOne analysis using CARD and Hovernet.
The analysis results can be loaded in TissUUmaps by loading the experiment_tmap.tmap
file in the TissUUmaps application (File --> Open --> select the appropriate file):
Or by checking the html reports stored at results/experiment_name/reports