spacetx / starfish

starfish: unified pipelines for image-based transcriptomics
https://spacetx-starfish.readthedocs.io/en/latest/
MIT License
226 stars 68 forks source link

Improve 3D support #53

Open dganguli opened 6 years ago

dganguli commented 6 years ago

We want Starfish to natively and seamlessly support 3D images. There are several TODOs in the code where this transition has not been made yet.

dganguli commented 6 years ago

One particular place in the code that needs 3D support is here: https://github.com/chanzuckerberg/starfish/blob/master/starfish/assign.py

The goal of this function is to assign 'spots' to 'cells'. The algorithm is a 2D point in polygon method based on ray tracing. This algorithm does not generalize readily to 3D data. What should the proper 3D implementation be?

tractatus commented 6 years ago

Do you actually need point in polygon for assignment in 3D? It assumes that your polygon perfectly represents the cell which it hardly will so lots of transcripts that strictly do not meet the point-in-polygon requirements will be left out.

I have several examples of FISSEQ (2000-4000 amplicons per cell) with z-stack 30 steps (can share one FOV to the example data for this package if desirable). My current reasoning is however that affinity propagation clustering solves this better than point-in-polygon in 3D as well as 2D since for cases where the provided polygon is not a perfect description of the cell transcripts will be correctly assigned and also given a probability of membership to that cell.

The reason for why the probability of membership is important is because cross-linking of amplicons to tissue is not always perfect resulting in transcripts "floating around" in the tissue. If using strict point-in-polygon algorithm you will get high Poisson shot noise in your counts per cell making the analysis of low-expressing genes difficult. Being able to give different weight to transcripts based on the probability of membership is desirable.

Affinity propagation clustering: http://www.psi.toronto.edu/affinitypropagation/FreyDueckScience07.pdf http://scikit-learn.org/stable/modules/generated/sklearn.cluster.AffinityPropagation.html

Now a point in polygon for 3D could be nice for other reasons and probably easiest to start with one for convex polyhedrons only.

ambrosejcarr commented 6 years ago

261 touches on some ideas that we could incorporate here.

ttung commented 6 years ago

@dganguli can you break this up into issues for specific algorithms?

neuromusic commented 4 years ago

After consultation with @shanaxel42 and @ttung, proposing the following...

Let's make sure that we support 3D where underlying algorithms support 3D, but we shouldn't develop new 3D algorithms.

Practically, as of 0.1.9, that means the following...

Target assignment and segmentation need 3D support, but we should NOT try to upgrade the 2D spot finders.

Then we close this issue :D

ttung commented 4 years ago

Which spotfinders are 2D and are the underlying algorithms also 2D-only?

neuromusic commented 4 years ago

LocalMaxPeakFinder, which wraps the 2D skimage.feature.peak_local_max

https://spacetx-starfish.readthedocs.io/en/latest/api/spots/index.html#starfish.spots.FindSpots.LocalMaxPeakFinder

neuromusic commented 4 years ago

Thanks to @ttung for diving in and noting that I was wrong about LocalMaxPeakFinder (silly me for relying on our docs).

Details here: https://github.com/spacetx/starfish/issues/1679

neuromusic commented 4 years ago

note from @ttung : waiting for skimage release