Parameters say what to run. Put them in a params.yml file and pass it with -params-file:
input: /data/myproject/sheets/samplesheet.csv
outdir: /data/myproject/results
use_instanseg: true
pixel_size: 0.65Every run needs input (the samplesheet) and outdir (where results go), and
a segmentation method. Everything else has a default. This page covers the parameters most runs
change, by topic; All parameters lists every one.
Write true and false in the params file. On the command line, --use_backsub false does not
switch it off, so the run refuses it; use the params file for anything that is off.
The run checks combinations when it starts and stops with a message when they do not fit. The rules are given under each topic below.
Which steps run¶
By default the pipeline corrects illumination, stitches, segments, quantifies and writes a QC report. Two switches change the route:
| You want | Set | Tutorial |
|---|---|---|
| Start from images stitched elsewhere | use_preprocessing: false | Pre-stitched image |
| Stitched images only, nothing after | preprocessing_only: true | Stitching only |
Two optional steps add to the route; both need the raw-cycle route: background subtraction and TMA dearray.
Segmentation¶
Methods and targets¶
Pick one method or both. Unless preprocessing_only, at least one is needed.
| Method | Set | Channels it reads |
|---|---|---|
| Cellpose | use_cellpose: true and cellpose_channels, e.g. "CD45 DNA_1", nuclear last | the two you name, or two projected ones |
| InstanSeg | use_instanseg: true and pixel_size, your pixel size in µm | every dna and marker channel of the marker sheet |
Then pick what to find. Cells are on by default.
| You want | Set |
|---|---|
| Cells | nothing |
| Cells, nuclei and cytoplasm, linked | segment_nuclei: true |
| Nuclei only | segment_cells: false, segment_nuclei: true |
Each method × target is one more pass over the image: two methods and two targets are four. With both methods finding cells, the QC compares them. How to choose: Multiple segmentations.
Cellpose finds nuclei on the last of
cellpose_channels; InstanSeg on thednachannels.Pre-stitched images have no marker sheet, so InstanSeg there needs
instanseg_channels.Cellpose needs
cellpose_channelsoruse_projection, not both.
Many markers with Cellpose¶
Cellpose looks at two channels, nuclear and cell, but an mIF panel spreads cell outlines across many markers. Channel projection combines them into those two channels:
use_cellpose: true
use_projection: trueuse_projectionbuilds the nuclear channel from the firstdnachannel and the cell channel from everymarkerwhose compartment ismembraneorcytoplasm. To choose by hand, use the marker sheet’ssegmentationcolumn.The default grouping leaves autofluorescence and nuclear markers out of the cell channel, as the segmentation benchmark favours. Keep them out when choosing by hand.
After the run, open
qc/{sample}_projection.png, what Cellpose saw. If one marker is listed underdominantinqc/{sample}_projection.json, it drowns the others: set itssegmentationtononeand run again.keep_projection: truekeeps the projected image in the store, to view under the outlines.Needs the raw-cycle route, because it reads the marker sheet.
Patch size¶
The image is cut into square patches that are segmented in parallel; see
Tiled segmentation. patch_width_pixel
sets their width. The default, 2000 px, suits TMA cores and small slides. Set it for anything
larger: aim for 16 to 200 patches.
| Stitched image (px) | 2000 | 5000 | 8000 | 10000 |
|---|---|---|---|---|
| 3 000 × 3 000 | 4 | 1 | 1 | 1 |
| 25 000 × 25 000 | 169 | 25 | 16 | 9 |
| 50 000 × 50 000 | 625 | 100 | 49 | 25 |
| 115 000 × 115 000 | 3364 | 529 | 225 | 144 |
The rule: patch_width_pixel = √(width × height / patches). A 30 000 × 20 000 px image at 70
patches gives 2928; round to 3000. The image size is in the stitched OME-TIFF’s metadata, which
QuPath or Fiji show when you open it.
One patch means no parallelism; thousands cost more in scheduling than in work.
InstanSeg’s memory grows with patch area × channels: at 3000 px, 0.65 µm/px and 8 channels, a patch asks for 39 GB. Above 64 GB the run warns and suggests a width that fits.
patch_overlap_pixel(default 100): about twice a cell diameter.Keep the width the same when you compare runs; it changes results at patch edges.
GPU¶
On the cluster, use_gpu: true gives each Cellpose and InstanSeg
patch one GPU. Run with the slurm profile; with mdc as well, it asks for an A40. See
GPU for other clusters.
InstanSeg on a GPU takes at most 10 channels for now. With more in the marker sheet, name 10 or fewer in
instanseg_channels, e.g."DNA_1 CD45 PanCK CD3 CD8"; the run checks at startup.A patch without a usable GPU fails; it does not quietly fall back to the CPU.
Not on a Mac.
Skip empty glass¶
use_tissue_segmentation: true finds the tissue
first and segments only patches that touch it. For fluorescence, also set mode: staining:
use_tissue_segmentation: true
mode: stainingIt takes the brightest channel at each pixel at low resolution, separates tissue from glass automatically (Otsu’s method), and drops specks smaller than 1 % of the tissue.
tissue_segmentation_kwargssteers it, written with double quotes:'{"channel": "DNA_1", "drop_threshold": 0.001}'uses one channel and keeps smaller pieces.levelpicks the resolution it reads.Without
mode, an image with exactly three channels is treated as H&E (saturationmode), which expects an 8-bit colour image.If no tissue is found, nothing is segmented and the run stops, naming the sample.
Check the outline,
region_of_interest, over the image in a viewer.
Preprocessing¶
Stitching¶
Ashlar stitches and aligns the cycles. Its settings go in
ashlar_args, default --maximum-shift 30. Setting it replaces
the default, so repeat what you want to keep:
ashlar_args: "--maximum-shift 50 --filter-sigma 1"What to change when: When stitching looks wrong. A poor alignment does not stop the run; check the QC report every time.
Background subtraction¶
use_backsub: true subtracts autofluorescence channels from
the markers before segmentation; see backsub. The marker sheet needs
exposure and background columns. Tutorial:
WSI with background subtraction.
TMA dearray¶
use_tma_dearray: true cuts a tissue microarray into
cores, processes each core alone and merges them per slide; see
Coreograph. It needs:
tma_expected_cores: how many cores the slide has (a count, not rows × columns), andtma_core_diameter_mm: their diameter in mm.
From these the pipeline tries several detection settings and keeps the one that finds the cores
you expect. Both apply to every slide in the run, so run arrays with different layouts
separately. To set Coreograph yourself instead, use
coreograph_args. Tutorial: TMA.
Quality control¶
On by default. use_qc writes the QC report and Ashlar’s stitching
QC; use_qc_images adds outline crops and a clustering of
cells to the report, which takes minutes rather than seconds. To switch either off, write
false in the params file. What the report shows: Reports.