Add segger export for scverse-compatible output#70
Open
EliHei2 wants to merge 1 commit into
Open
Conversation
Collaborator
|
Looks good, thanks for putting this together so quickly.
|
`segger export` writes a segger segmentation to plain files from which a `SpatialData` object can be assembled. Name which elements to write: `anndata` (the cell-by-gene table), `transcripts` (the assigned transcripts), or `boundaries` (one polygon per cell). With no element named it writes `anndata` and `boundaries`; pass `transcripts` to also write the per-transcript assignment. The column names follow SOPA's conventions. `anndata.h5ad` and `cell_boundaries.parquet` share `cell_id`, the instance key SOPA uses to join a table to its shapes. `transcripts.parquet` keeps the segger assignment as `segger_cell_id` alongside `row_index`, a sibling column in the spirit of SOPA's `sopa_prior`, so it merges onto an existing transcripts dataframe by `row_index` without overwriting the vendor `cell_id`; its values match the `cell_id` in the other two files. Boundaries are traced with `--method` (`delaunay`, a pruned Delaunay outline, or `convex_hull`) and Chaikin-smoothed unless `--no-smooth-masks`. The exported transcripts are selected with `--include-all-transcripts`, `--min-similarity`, and `--min-transcripts`, which default to the per-gene similarity threshold. No new dependencies. Closes #67.
5d42532 to
e3075b3
Compare
Collaborator
Author
|
Thanks! Both done in the latest push. Good call on the area too. I dropped the convex-hull area and now write obs["area"] only when boundaries is exported, taking it straight from the polygon areas so it stays consistent with the shapes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
segger exportwrites a segger segmentation to plain files from which aSpatialDataobject can be assembled. Name which elements to write:anndata(the cell-by-gene table),transcripts(the assigned transcripts), orboundaries(one polygon per cell). With no element named it writesanndataandboundaries; passtranscriptsto also write the per-transcript assignment.The column names follow SOPA's conventions.
anndata.h5adandcell_boundaries.parquetsharecell_id, the instance key SOPA uses to join a table to its shapes.transcripts.parquetkeeps the segger assignment assegger_cell_idalongsiderow_index, a sibling column in the spirit of SOPA'ssopa_prior, so it merges onto an existing transcripts dataframe byrow_indexwithout overwriting the vendorcell_id; its values match thecell_idin the other two files.Boundaries are traced with
--method(delaunay, a pruned Delaunay outline, orconvex_hull) and Chaikin-smoothed unless--no-smooth-masks. The exported transcripts are selected with--include-all-transcripts,--min-similarity, and--min-transcripts, which default to the per-gene similarity threshold.No new dependencies. Closes #67.