Skip to content

Commit

Permalink
Merge pull request #130 from scverse/visium_hd
Browse files Browse the repository at this point in the history
Visium HD support
  • Loading branch information
LucaMarconato authored Mar 29, 2024
2 parents 77bd666 + b5b5742 commit f33092b
Show file tree
Hide file tree
Showing 7 changed files with 449 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning][].

## [0.1.2] - xxxx-xx-xx

### Added

- (Visium HD) added reader, coauthored by @LLehner

### Fixed

- (Xenium) reader for 1.0.1 (paper data) and unknown versions
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@

This package contains reader functions to load common spatial omics formats into SpatialData. Currently, we provide support for:

- NanoString CosMx
- MCMICRO (output data)
- Steinbock (output data)
- 10x Genomics Visium
- 10x Genomics Visium HD
- 10x Genomics Xenium
- Curio Seeker
- Akoya PhenoCycler (formerly CODEX)
- Vizgen MERSCOPE (MERFISH)
- Curio Seeker
- DBiT-seq
- MCMICRO (output data)
- NanoString CosMx
- Steinbock (output data)
- Vizgen MERSCOPE (MERFISH)

## Getting started

Expand Down
11 changes: 6 additions & 5 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ I/O for the `spatialdata` project.
:toctree: generated
codex
curio
cosmx
curio
dbit
mcmicro
merscope
steinbock
visium
visium_hd
xenium
steinbock
merscope
mcmicro
dbit
```

### Conversion functions
Expand Down
2 changes: 2 additions & 0 deletions src/spatialdata_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from spatialdata_io.readers.merscope import merscope
from spatialdata_io.readers.steinbock import steinbock
from spatialdata_io.readers.visium import visium
from spatialdata_io.readers.visium_hd import visium_hd
from spatialdata_io.readers.xenium import (
xenium,
xenium_aligned_image,
Expand All @@ -26,6 +27,7 @@
"xenium_aligned_image",
"xenium_explorer_selection",
"dbit",
"visium_hd",
]

__version__ = version("spatialdata-io")
57 changes: 57 additions & 0 deletions src/spatialdata_io/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,60 @@ class DbitKeys(ModeEnum):
BARCODE_POSITION = "barcode_list"
# image
IMAGE_LOWRES_FILE = "tissue_lowres_image.png"


@unique
class VisiumHDKeys(ModeEnum):
"""Keys for *10X Genomics Visium hd* formatted dataset."""

# directories
SPATIAL = "spatial"
DEFAULT_BIN = "square_008um"
BIN_PREFIX = "square_"
MICROSCOPE_IMAGE = "microscope_image"

# counts and locations files
FILTERED_COUNTS_FILE = "filtered_feature_bc_matrix.h5"
RAW_COUNTS_FILE = "raw_feature_bc_matrix.h5"
TISSUE_POSITIONS_FILE = "tissue_positions.parquet"

# images
IMAGE_HIRES_FILE = "spatial/tissue_hires_image.png"
IMAGE_LOWRES_FILE = "spatial/tissue_lowres_image.png"
IMAGE_CYTASSIST = "spatial/cytassist_image.tiff"

# scalefactors
SCALEFACTORS_FILE = "scalefactors_json.json"

# scalefactors keys
SCALEFACTORS_HIRES = "tissue_hires_scalef"
SCALEFACTORS_LOWRES = "tissue_lowres_scalef"
SCALEFACTORS_SPOT_DIAMETER_FULLRES = "spot_diameter_fullres"
SCALEFACTORS_BIN_SIZE_UM = "bin_size_um"
SCALEFACTORS_MICRONS_PER_PIXEL = "microns_per_pixel"

# locations keys
LOCATIONS_X = "pxl_col_in_fullres"
LOCATIONS_Y = "pxl_row_in_fullres"
BARCODE = "barcode"
IN_TISSUE = "in_tissue"
ARRAY_ROW = "array_row"
ARRAY_COL = "array_col"

# table keys
REGION_KEY = "region"
INSTANCE_KEY = "location_id"

# feature slice file (it contains transformation matrices in the metadata)
FEATURE_SLICE_FILE = "feature_slice.h5"

# METADATA_KEYS
METADATA_JSON = "metadata_json"
HD_LAYOUT_JSON = "hd_layout_json"
TRANSFORM = "transform"
TRANSFORM_MATRICES = "transform_matrices"
CYTASSIST_COLROW_TO_SPOT_COLROW = ("cytassist_colrow_to_spot_colrow",)
SPOT_COLROW_TO_CYTASSIST_COLROW = ("spot_colrow_to_cytassist_colrow",)
MICROSCOPE_COLROW_TO_SPOT_COLROW = ("microscope_colrow_to_spot_colrow",)
SPOT_COLROW_TO_MICROSCOPE_COLROW = ("spot_colrow_to_microscope_colrow",)
FILE_FORMAT = "file_format"
6 changes: 3 additions & 3 deletions src/spatialdata_io/converters/legacy_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SpatialData,
get_centroids,
get_extent,
join_sdata_spatialelement_table,
join_spatialelement_table,
to_circles,
)
from spatialdata._core.operations._utils import transform_to_data_extent
Expand Down Expand Up @@ -149,8 +149,8 @@ def to_legacy_anndata(
shapes = to_circles(element)
circles_sdata = SpatialData(tables={table_name: table}, shapes={region_name: shapes})

joined_elements, new_table = join_sdata_spatialelement_table(
sdata=circles_sdata, spatial_element_name=region_name, table_name=table_name, how="inner", match_rows="left"
joined_elements, new_table = join_spatialelement_table(
sdata=circles_sdata, spatial_element_names=region_name, table_name=table_name, how="inner", match_rows="left"
)

# the table after the filtering must not be empty
Expand Down
Loading

0 comments on commit f33092b

Please sign in to comment.