From ff9ff666ec7f19049937ce1ab81000b29996110d Mon Sep 17 00:00:00 2001 From: Blampey Quentin Date: Wed, 25 Sep 2024 15:04:16 +0200 Subject: [PATCH] Support `baysor>=0.7.0` (#125) --- CHANGELOG.md | 6 ++++++ docs/tutorials/cli_usage.md | 2 -- workflow/Snakefile | 9 +++++++-- workflow/config/cosmx/baysor.yaml | 2 -- workflow/config/cosmx/cellpose_baysor.yaml | 2 -- workflow/config/example_commented.yaml | 2 -- workflow/config/merscope/baysor_cellpose.yaml | 2 -- workflow/config/merscope/baysor_vizgen.yaml | 2 -- workflow/config/toy/uniform_baysor.yaml | 2 -- workflow/config/toy/uniform_baysor_overlaps.yaml | 2 -- workflow/config/toy/uniform_baysor_vizgen.yaml | 2 -- workflow/config/toy/uniform_cellpose_baysor.yaml | 2 -- workflow/config/xenium/baysor.yaml | 2 -- workflow/config/xenium/baysor_multimodal.yaml | 2 -- workflow/config/xenium/cellpose_baysor.yaml | 2 -- workflow/utils.py | 2 +- 16 files changed, 14 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 763a41d7..d9dc17d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [1.x.x] - 2024-xx-xx + +### Fix +- Support `baysor>=0.7.0` (#125, @lguerard). + - NB: For Snakemake, please remove the `new_component_*` arguments from the Baysor config. + ## [1.1.5] - 2024-09-17 ### Fix diff --git a/docs/tutorials/cli_usage.md b/docs/tutorials/cli_usage.md index 6ff9b80c..a80b0df1 100644 --- a/docs/tutorials/cli_usage.md +++ b/docs/tutorials/cli_usage.md @@ -165,8 +165,6 @@ iters = 500 n_cells_init = 0 nuclei_genes = "" cyto_genes = "" -new_component_weight = 0.2 -new_component_fraction = 0.3 ``` Then, we generate the bounding boxes of the patches on which Baysor will be run. Here, the patches have a width and height of 1200 microns and an overlap of 50 microns. We advise bigger sizes for real datasets (see our default parameters in one of our [config files](https://github.com/gustaveroussy/sopa/tree/master/workflow/config)). On the toy dataset, this will generate **4** patches. diff --git a/workflow/Snakefile b/workflow/Snakefile index f087bf22..74e2a5d7 100644 --- a/workflow/Snakefile +++ b/workflow/Snakefile @@ -113,7 +113,6 @@ rule patch_segmentation_baysor: patches_file = paths.smk_patches_file_baysor, baysor_patch = paths.smk_baysor_temp_dir / "{index}", output: - paths.smk_baysor_temp_dir / "{index}" / "segmentation_polygons.json", paths.smk_baysor_temp_dir / "{index}" / "segmentation_counts.loom", params: args_baysor_prior_seg = args.baysor_prior_seg, @@ -126,7 +125,13 @@ rule patch_segmentation_baysor: fi cd {input.baysor_patch} - {config[executables][baysor]} run --save-polygons GeoJSON -c config.toml transcripts.csv {params.args_baysor_prior_seg} + + help_output=$({config[executables][baysor]} run --help 2>&1) # check if the polygon-format option is available + if [[ $help_output == *"polygon-format"* ]]; then + {config[executables][baysor]} run --polygon-format GeometryCollection -c config.toml transcripts.csv {params.args_baysor_prior_seg} + else + {config[executables][baysor]} run --save-polygons GeoJSON -c config.toml transcripts.csv {params.args_baysor_prior_seg} + fi """ rule patch_segmentation_comseg: diff --git a/workflow/config/cosmx/baysor.yaml b/workflow/config/cosmx/baysor.yaml index a3d0fbc0..16731c09 100644 --- a/workflow/config/cosmx/baysor.yaml +++ b/workflow/config/cosmx/baysor.yaml @@ -34,8 +34,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/cosmx/cellpose_baysor.yaml b/workflow/config/cosmx/cellpose_baysor.yaml index 7705d439..e0accae4 100644 --- a/workflow/config/cosmx/cellpose_baysor.yaml +++ b/workflow/config/cosmx/cellpose_baysor.yaml @@ -41,8 +41,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/example_commented.yaml b/workflow/config/example_commented.yaml index f33a1206..fcc2199b 100644 --- a/workflow/config/example_commented.yaml +++ b/workflow/config/example_commented.yaml @@ -63,8 +63,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: diff --git a/workflow/config/merscope/baysor_cellpose.yaml b/workflow/config/merscope/baysor_cellpose.yaml index adbf7137..c987ff24 100644 --- a/workflow/config/merscope/baysor_cellpose.yaml +++ b/workflow/config/merscope/baysor_cellpose.yaml @@ -42,8 +42,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/merscope/baysor_vizgen.yaml b/workflow/config/merscope/baysor_vizgen.yaml index 10920027..53bc15b2 100644 --- a/workflow/config/merscope/baysor_vizgen.yaml +++ b/workflow/config/merscope/baysor_vizgen.yaml @@ -37,8 +37,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/toy/uniform_baysor.yaml b/workflow/config/toy/uniform_baysor.yaml index b628470d..ef656ab6 100644 --- a/workflow/config/toy/uniform_baysor.yaml +++ b/workflow/config/toy/uniform_baysor.yaml @@ -34,8 +34,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/toy/uniform_baysor_overlaps.yaml b/workflow/config/toy/uniform_baysor_overlaps.yaml index 3b08951f..f3097950 100644 --- a/workflow/config/toy/uniform_baysor_overlaps.yaml +++ b/workflow/config/toy/uniform_baysor_overlaps.yaml @@ -34,8 +34,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/toy/uniform_baysor_vizgen.yaml b/workflow/config/toy/uniform_baysor_vizgen.yaml index a6b9db07..7aac2fbc 100644 --- a/workflow/config/toy/uniform_baysor_vizgen.yaml +++ b/workflow/config/toy/uniform_baysor_vizgen.yaml @@ -38,8 +38,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/toy/uniform_cellpose_baysor.yaml b/workflow/config/toy/uniform_cellpose_baysor.yaml index bd3479c5..588496ad 100644 --- a/workflow/config/toy/uniform_cellpose_baysor.yaml +++ b/workflow/config/toy/uniform_cellpose_baysor.yaml @@ -41,8 +41,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/xenium/baysor.yaml b/workflow/config/xenium/baysor.yaml index e12b466e..1401b62f 100644 --- a/workflow/config/xenium/baysor.yaml +++ b/workflow/config/xenium/baysor.yaml @@ -32,8 +32,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/xenium/baysor_multimodal.yaml b/workflow/config/xenium/baysor_multimodal.yaml index 1e5eb53b..af4306f7 100644 --- a/workflow/config/xenium/baysor_multimodal.yaml +++ b/workflow/config/xenium/baysor_multimodal.yaml @@ -36,8 +36,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/config/xenium/cellpose_baysor.yaml b/workflow/config/xenium/cellpose_baysor.yaml index 0b5a8590..79df1286 100644 --- a/workflow/config/xenium/cellpose_baysor.yaml +++ b/workflow/config/xenium/cellpose_baysor.yaml @@ -41,8 +41,6 @@ segmentation: n_cells_init: 0 nuclei_genes: "" cyto_genes: "" - new_component_weight: 0.2 - new_component_fraction: 0.3 aggregate: average_intensities: true diff --git a/workflow/utils.py b/workflow/utils.py index dee924e4..0d81eea6 100644 --- a/workflow/utils.py +++ b/workflow/utils.py @@ -98,7 +98,7 @@ def cells_paths(self, file_content: str, name, dirs: bool = False): return [str(self.smk_cellpose_temp_dir / f"{i}.parquet") for i in range(int(file_content))] if name == "baysor": indices = map(int, file_content.split()) - BAYSOR_FILES = ["segmentation_polygons.json", "segmentation_counts.loom"] + BAYSOR_FILES = ["segmentation_counts.loom"] if dirs: return [str(self.smk_baysor_temp_dir / str(i)) for i in indices]