Skip to content

Commit a0380db

Browse files
committed
refactored landmark and alignment processing
1 parent 4fa4b1a commit a0380db

7 files changed

Lines changed: 1994 additions & 1284 deletions

File tree

src/xenium_analysis_tools/alignment/align_sections.py

Lines changed: 471 additions & 1011 deletions
Large diffs are not rendered by default.

src/xenium_analysis_tools/alignment/format_for_napari.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ def get_fov_sdata(
9292
else:
9393
filtered_points[el] = pts
9494

95-
# spatialdata's bounding_box_query does not support "case 2":
96-
# a 2D element (data_dim=2) with a 3D lifting transformation (rank-2 map to 3D
97-
# czstack space, transform_coordinate_length=3). Such elements come from 2D
98-
# Xenium section images/labels that align_section_to_zstack registered in the
99-
# czstack_microns coordinate system. They don't need spatial filtering here
100-
# (they are already precisely placed in czstack space), so we remove them
101-
# before the bounding-box query and re-attach them afterwards.
10295
def _is_2d_element(el):
10396
"""Return True if the element has no 'z' spatial dimension."""
10497
if hasattr(el, 'dims'):
@@ -907,25 +900,25 @@ def add_napari_colormaps(
907900
-----------------------------
908901
Writes a ``'{column}{suffix}'`` column (default ``'{column}_color'``) into
909902
the Dask DataFrame with a hex string per row. In napari you can then choose
910-
this color column to directly colour individual transcripts by gene/feature.
903+
this color column to directly color individual transcripts by gene/feature.
911904
912905
Parameters
913906
----------
914907
sdata : SpatialData
915908
column_colors : dict
916909
``{column_name: color_spec}`` where *color_spec* is one of:
917910
918-
* **dict** ``{category_value: color}`` — explicit per-value colours
919-
(hex strings, RGB tuples, or matplotlib named colours).
920-
* **str** — a matplotlib colormap name; colours are auto-assigned to
911+
* **dict** ``{category_value: color}`` — explicit per-value colors
912+
(hex strings, RGB tuples, or matplotlib named colors).
913+
* **str** — a matplotlib colormap name; colors are auto-assigned to
921914
sorted unique category values.
922-
* **list** — colours in the same order as the sorted unique categories
915+
* **list** — colors in the same order as the sorted unique categories
923916
(or ``table.obs[col].cat.categories`` for table columns).
924917
925918
table_key : str
926919
Key of the AnnData table to update. Default ``'table'``.
927920
points_elements : list[str] | None
928-
Points element names to add colour columns to.
921+
Points element names to add color columns to.
929922
``None`` → every element whose name starts with ``'transcripts'``.
930923
points_color_col_suffix : str
931924
Suffix appended to the column name when writing into points DataFrames.
@@ -941,7 +934,7 @@ def add_napari_colormaps(
941934
>>> add_napari_colormaps(
942935
... sdata,
943936
... column_colors={
944-
... # Cell-type column in table — explicit colours
937+
... # Cell-type column in table — explicit colors
945938
... 'subclass_name': {'L2/3 IT': '#e41a1c', 'Pvalb': '#377eb8', 'L5 IT': '#4daf4a'},
946939
... # Another column — auto-assign from a matplotlib cmap
947940
... 'broad_class': 'tab10',
@@ -1041,7 +1034,7 @@ def _resolve_color_map(color_spec, categories):
10411034
sdata.points[pt_key] = pts
10421035
print(
10431036
f" [colormaps] points['{pt_key}']['{color_col}'] → "
1044-
f"{len(color_map)} gene colours"
1037+
f"{len(color_map)} gene colors"
10451038
)
10461039

10471040
return sdata

src/xenium_analysis_tools/alignment/process_landmarks.py

Lines changed: 270 additions & 85 deletions
Large diffs are not rendered by default.

src/xenium_analysis_tools/alignment/process_transforms.py

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)