Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Tutorial 3: Whole slide with background subtraction

When to use

A whole slide imaged with autofluorescence channels: a cycle, or channels, that record only the tissue’s own glow. backsub subtracts them from the markers before segmentation. The example below is made up; adapt the names and paths to your slide.

The samplesheet

One row per cycle:

samplecycle_numberimage_tilesmarker_sheet
wsi011/data/myproject/raw/wsi01/cycle01.ome.tiff/data/myproject/sheets/markers_wsi01.csv
wsi012/data/myproject/raw/wsi01/cycle02.ome.tiff/data/myproject/sheets/markers_wsi01.csv
Copy as CSV: samplesheet.csv
sample,cycle_number,image_tiles,marker_sheet
wsi01,1,/data/myproject/raw/wsi01/cycle01.ome.tiff,/data/myproject/sheets/markers_wsi01.csv
wsi01,2,/data/myproject/raw/wsi01/cycle02.ome.tiff,/data/myproject/sheets/markers_wsi01.csv

Columns: The samplesheet.

The marker sheet

Cycle 1 records the background, cycle 2 the markers:

channel_numbercycle_numbermarker_namechannel_rolechannel_compartmentfilterexposurebackgroundremove
11DNA_1dnanuclearDAPI20
21AF_FITCautofluorescenceFITC100true
31AF_Cy5autofluorescenceCy5150true
42DNA_2dnanuclearDAPI20
52CD45markermembraneFITC100AF_FITC
62PanCKmarkercytoplasmCy5150AF_Cy5
Copy as CSV: markers_wsi01.csv
channel_number,cycle_number,marker_name,channel_role,channel_compartment,filter,exposure,background,remove
1,1,DNA_1,dna,nuclear,DAPI,20,,
2,1,AF_FITC,autofluorescence,,FITC,100,,true
3,1,AF_Cy5,autofluorescence,,Cy5,150,,true
4,2,DNA_2,dna,nuclear,DAPI,20,,
5,2,CD45,marker,membrane,FITC,100,AF_FITC,
6,2,PanCK,marker,cytoplasm,Cy5,150,AF_Cy5,

Columns: The marker sheet.

The parameters

Save as params.yml:

input: /data/myproject/sheets/samplesheet.csv
outdir: /data/myproject/results

use_backsub: true

use_cellpose: true
cellpose_channels: "CD45 DNA_1"

patch_width_pixel: 8000

Run

nextflow run CosciaLab/histo -r v3.2.0 \
    -profile singularity,size_medium,slurm \
    -params-file params.yml

size_medium covers stitched images of about 50 to 200 GB; this one is about 72 GB at 16 bit. See Profiles.

What runs: BaSiCPy per cycle, Ashlar, backsub, then the SpatialData store, tiled segmentation with Cellpose, quantification and the QC report.

What you get

results/
├── preprocessing/
│   ├── illumination/            wsi01_cycle1-dfp.ome.tif, -ffp.ome.tif; per cycle
│   ├── registration/            wsi01.ome.tif, wsi01_ashlar_qc/
│   └── background_subtraction/  wsi01_backsub.ome.tif, wsi01_backsub.csv
├── wsi01.zarr/
│   ├── images/                  wsi01_backsub, the subtracted image
│   ├── shapes/                  image_patches, cellpose_cells
│   └── tables/                  cellpose_table
├── qc/                          wsi01_cellpose_qc_report.html, wsi01_cellpose_qc.json,
│                                wsi01_cellpose_qc_images/
└── pipeline_info/

Every file: Outputs.

What to check

  1. preprocessing/background_subtraction/wsi01_backsub.csv: the marker sheet everything after subtraction reads. The background channels are gone and channel_number is renumbered.

  2. “Zero pixels per channel” in the QC report, before and after subtraction. Many zero pixels after means real signal was subtracted away.

  3. wsi01.ome.tif beside wsi01_backsub.ome.tif in a viewer; see Viewers.

  4. “Segmentation overlay” and “Cells per patch”; see Common failures.