Baysor icon indicating copy to clipboard operation
Baysor copied to clipboard

inconsistent number of cells between the output files

Open MobiTobi opened this issue 3 years ago • 3 comments

The number of cell boundaries in segmentation_polygons.json far exceeds the number of cells in segmentation.csv and segmentation_cell_stats.csv. For example one of my runs produced 4013 polygons but only 2430 cells.

I would like to filter the boundaries that I plot with the diagnostics information in segmentation_cell_stats.csv, but due to the different numbers of elements they contain I cannot match the diagnostics information with the cell boundaries :(

The expected behaviour would be one polygon for each cell that baysor finds.

MobiTobi avatar Jun 14 '21 13:06 MobiTobi

In the current version, polygons only roughly correspond to cells, unfortunately. The task of drawing polygons based on a set of points is ill-defined, and all solutions that I checked require some amount of parameter tuning. So in the current version, polygons may be drawn around empty holes in cells (showing their "inner boundaries"), or in rare cases one cell may have several polygons attached to it. There is a fix, which I'm going to implement in the next release, so each cell should only have the best-matching polygon, though I'm not sure if the solution would work as intended.

VPetukhov avatar Jun 24 '21 19:06 VPetukhov

@VPetukhov Hi, If the polygons do not correspond to cells, how did you draw boundaries in your publication?

jameswm2 avatar Nov 19 '21 01:11 jameswm2

Note for myself: after estimating KDE boundaries, need to replace my custom MST-based algorithm with Marching squares, maybe from Contour.jl

VPetukhov avatar Feb 04 '22 20:02 VPetukhov

Hi @VPetukhov, is this fixed in the current release? (Apologies for raising so many issues)

teng-gao avatar Mar 16 '23 00:03 teng-gao

Hi @teng-gao,

I made a stand-alone python module to generate "cell-borders" from the Baysor clusters. It reimplements the approach from Petukhov, but has a few quality of life improvements. I wanted to publish it on github anyway but never got around to it. Are you interested?

  • parallelized so much shorter wall time
  • direct control over parameters (grid size, threshold etc)
  • polygon estimation decoupled from baysor clustering

MobiTobi avatar Mar 28 '23 09:03 MobiTobi

Hi @MobiTobi , that would be very useful! I'm currently working on a tool set for spatial analysis in Python (baysorpy), which also will wrap julia calls to Baysor. If it's fine with you, it would be very cool to add your method to the package. Or it can be a stand-alone app, then I would reference it and use as a dependency for baysorpy.

VPetukhov avatar Apr 20 '23 12:04 VPetukhov

Regarding the main issue, I just released v0.6, which resolves it, and also has a much faster triangulation-based method for polygon estimation (similar to ideas from here).

VPetukhov avatar Apr 20 '23 12:04 VPetukhov