[main] Add spatialdata element to segger export - #80
Conversation
… for legacy segmentation outputs
Runs cell_boundary for each cell in a ProcessPoolExecutor sized to the SLURM-allocated CPU count instead of a single-threaded loop.
spatialdata's xarray_schema dependency imports pkg_resources, which comes from setuptools; not otherwise pulled in by the resolved env.
zip(*results) produced tuples, which geopandas' set_geometry mistakes for a column-name lookup instead of geometry values, dumping every polygon into the error message. Convert to lists. Also leave one CPU free instead of using every allocated core.
- Disable dask's query-planning backend at the top of segger/__init__.py: cudf is imported unconditionally by every CLI subcommand and pulls in dask.dataframe before export code ever runs, so setting the config lazily inside the export path was too late. - _write_to_sdata now adds elements directly to the given --sdata store instead of copytree-ing it into the output directory first; avoids the 'cannot overwrite' error from the raw Xenium sdata's transcripts/ cell_boundaries/table already occupying those element names. - Fail fast: check the target element names don't already exist before doing any of the (expensive) segmentation/boundary work. - Add --spatialdata-element-prefix (default '_segger') to name segger's elements distinctly from the source sdata's own. - -o/--output-directory is now optional, only required for the anndata/transcripts/boundaries elements.
|
Example user workflow: |
|
Asking for your feedback on this workflow @MeyerBender, @quentinblampey. This adds segger elements to an existing spatialdata object. Would this be useful for you? |
|
Tagging @alihamraoui since he started working on integrating segger to sopa |
|
Thanks a lot, looks really cool and will be super useful! One thing I don't fully understand is why the Also tagging @LazDaria. |
|
Agree with @MeyerBender I belive keeping all transcripts is essential for downstream QC, so default should contain all, while user can select only to keep assigned transcripts. |
|
Appreciate your inputs. How about negative controls and antisense probes? And low quality probes ( If we keep all the same transcripts, it doesn't necessarily make sense to store a new element. Perhaps just add a column with seggers segmentation to the existing transcripts element? @EliHei2 with the new |
|
I think that would be a good idea, having just one points element should also make things less ambiguous. I would even keep quality probes in there, and just have them as "Unassigned". I can ofc only speak for SegTraQ, but we usually filter out quality probes beforehand, and then only look at the "regular" gene probes to compute the number of unassigned transcripts. What would be important is that the number of transcripts assigned in the points element matches the number in the table exactly (in the old ProSeg version, this wasn't enforced, which led to quite some inconsistencies, see here). |
|
I see, this is useful. We could join the following info with configurable prefix to the existing transcripts then:
How about the cell_boundaries and table? Should we override, or add new elements? -- we don't use spatialdata, so really reffering to your inputs here. thanks @MeyerBender |
|
Are there naming conventions or other aspects to look out for for SOPA integration? @alihamraoui |
|
Sounds like a resonable plan, from my POV the most important ones would be |
1 similar comment
|
Sounds like a resonable plan, from my POV the most important ones would be |
Points and table centroids include z when present; no-op until a reader emits it. Spatialdata writes now fail on a name collision instead of overwriting. Co-authored-by: Elyas Heidari <55977725+EliHei2@users.noreply.github.com> Co-authored-by: enric-bazz <enrico.bazzacco02@outlook.it>
Added better support for spatialdata in response to #25 #48 #67 #73.
Add
spatialdataelement tosegger export. Requires thatsdata.zarrexists somehwere, created for example usingspatialdata_io.<technology>. Run like this:Output:
transcripts_seggercell_boundaries_seggertable_seggerNotes:
FileExistsErrortranscripts_seggeronly contain assigned transcripts. In contrast,transcriptsin sdata.zarr often contain unassigned and negative control transcripts too--spatialdata-element-prefixinsegger exportfor a different prefix. Per default it's_segger.Other changes:
filteredcolumn introduced in [main] Add x/y coordinates and filtered flag to transcripts output #79Example result:
