gustaveroussy / sopa

Technology-invariant pipeline for spatial omics analysis that scales to millions of cells (Xenium / Visium HD / MERSCOPE / CosMx / PhenoCycler / MACSima / etc)
https://gustaveroussy.github.io/sopa/
BSD 3-Clause "New" or "Revised" License
138 stars 15 forks source link

Passing kwargs to cellpose from yaml #99

Closed pakiessling closed 3 months ago

pakiessling commented 3 months ago

Hello again,

I am now very satisified with the performance of Sopa on my data.

One thing I noticed is that setting resample=False in CellposeModel.eval() massively speeds up segmentation without noticable effect on segmentation accuracy or cluster purity. For 4096 pixel tiles it decreased runtime from 30 minutes to 30 seconds which is quite nice with my massive datasets.

Is there a way to pass this argument from the Snakemake yaml? I was a little bit confused with utils.py

quentinblampey commented 3 months ago

Hi @pakiessling,

Good to hear, and thanks again for your PR!

Yeah utils.py may be confusing. In brief, it handles the paths to the different files that will be created by the pipeline, and also ensures that the config parameters are properly transferred to the CLI (which is used by Snakemake).

To pass an extra keyword argument, you can use method_kwargs as in the example below:

segmentation:
  cellpose:
    diameter: 60
    channels: ["DAPI"]
    flow_threshold: 2
    cellprob_threshold: -6
    min_area: 2000
    method_kwargs:
      resample: False

I'll add this example in the FAQ, since it is indeed not detailed :)

pakiessling commented 3 months ago

Perfect , ty!