What you will do¶
Segment the same tissue with two methods, Cellpose and InstanSeg, each finding both cells and nuclei, and compare the two. Use this when you are unsure which method suits your tissue, or when you want nuclei and cytoplasm measured separately.
The data is exemplar-001, as in Tutorial 1. Do that one first: the download, samplesheet and marker sheet are the same.
Choose methods and targets¶
Pick one or both methods:
| You want | Set |
|---|---|
| Cells from one membrane marker and DNA | use_cellpose: true, cellpose_channels: "CD45 DNA_6", nuclear stain last |
| Cells from many markers, with Cellpose | use_cellpose: true, use_projection: true; see Many markers |
| Cells from every marker, no channel choice | use_instanseg: true, pixel_size in µm per pixel |
| A second opinion | Both. The QC then compares them |
Then the targets. 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 |
Every method × target is one more pass over every patch. Two methods with two targets are four
segmentations per patch. Nuclei come from a nuclear stain: for Cellpose the last of
cellpose_channels, or the projection’s nuclear channel; for InstanSeg the dna channels.
More: Methods and targets.
The parameters¶
Use the samplesheet and marker sheet from Tutorial 1. Save as params.yml:
input: /path/to/exemplars/samplesheet.csv
outdir: /path/to/results/exemplar-001-both
use_cellpose: true
use_projection: true
use_instanseg: true
pixel_size: 0.65
segment_nuclei: true
patch_width_pixel: 1500use_projectiongives Cellpose two channels built from the marker sheet (Channel projection):DNA_6as nuclear, and everymarkerwhosechannel_compartmentismembraneorcytoplasmas cell.FOXP3is nuclear, so it stays out.segment_nucleiadds nuclei to the cells. Each nucleus is then linked to its cell, and the cytoplasm is the cell minus its nuclei.With 1500-pixel patches, 3 × 2 patches, two methods and two targets: 24 segmentation tasks. Each InstanSeg cell task asks for about 16 GB of memory (12 channels).
Run¶
nextflow run CosciaLab/histo -r v3.2.0 \
-profile singularity,size_small,slurm \
-params-file params.ymlOn the MDC cluster add mdc. See
Running on the cluster.
What you get¶
/path/to/results/exemplar-001-both/
├── preprocessing/ as in Tutorial 1
├── exemplar-001.zarr/
│ ├── images/ exemplar-001
│ ├── shapes/ image_patches,
│ │ cellpose_cells, cellpose_nuclei, cellpose_cytoplasm,
│ │ instanseg_cells, instanseg_nuclei, instanseg_cytoplasm
│ └── tables/ cellpose_table, instanseg_table; layers nucleus and cytoplasm
├── qc/
│ ├── exemplar-001_cellpose_qc_report.html, exemplar-001_instanseg_qc_report.html
│ ├── exemplar-001_cellpose_qc.json, exemplar-001_instanseg_qc.json
│ ├── exemplar-001_cellpose_qc_images/, exemplar-001_instanseg_qc_images/
│ ├── exemplar-001_comparison.html, exemplar-001_comparison.json
│ └── exemplar-001_projection.png, exemplar-001_projection.json
└── pipeline_info/Each method has its own table, one row per cell, with marker intensities over the whole cell and, in the layers, over the nucleus and the cytoplasm. See The SpatialData store.
What to check¶
qc/exemplar-001_projection.png, what Cellpose saw: nuclear in magenta, cell in green. In the JSON, a marker underdominantswamps the others; leave it out with thesegmentationcolumn of the marker sheet. See Many markers.qc/exemplar-001_comparison.html: cell counts, median areas, and the share of cells both methods agree on, with both outlines on the same crops.“Linking” in each method’s report: cells by number of nuclei, nuclei linked to no cell, and cells their nucleus fills completely (no cytoplasm). See The QC report.
Both sets of outlines over the image; see Viewers.