Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reader for Stereo-seq files. #70

Merged
merged 54 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
504bd9e
Add reader for Stereo-seq data
LLehner Jul 18, 2023
4595f5d
Fix init
LLehner Jul 19, 2023
21733f8
Fix duplicate Key values
LLehner Jul 19, 2023
8c4e9b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 19, 2023
093f8c9
Add Key value
LLehner Jul 19, 2023
442de55
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LLehner Jul 19, 2023
a007eb2
Add shapes
LLehner Aug 3, 2023
8a61442
Remove print
LLehner Aug 3, 2023
790ac13
Fix radius
LLehner Aug 7, 2023
5c24bb2
Fix constants
LLehner Aug 19, 2023
8f48b60
Update constants and reader
LLehner Aug 20, 2023
0f3f9d6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2023
8219aa7
Fix constants
LLehner Aug 20, 2023
ca22756
Add dataset identifier
LLehner Aug 20, 2023
b7b1866
Update reader
LLehner Aug 20, 2023
a6df587
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2023
3a78585
Fix parameters
LLehner Aug 20, 2023
e256b0b
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LLehner Aug 20, 2023
edca0d9
Fix parameters
LLehner Aug 20, 2023
fa1fe68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2023
14b3b2c
Fix input parameters
LLehner Aug 20, 2023
d46d4dd
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LLehner Aug 20, 2023
ef50c98
Fix input parameters
LLehner Aug 20, 2023
70a1ab4
Fix input parameters
LLehner Aug 20, 2023
1d54073
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 20, 2023
62ced28
Fix mypy
LLehner Aug 20, 2023
57fcada
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LLehner Aug 20, 2023
8907869
Fix input parameters
LLehner Aug 20, 2023
f1523ed
Fix mypy
LLehner Aug 21, 2023
6c6d609
Fix automatic dataset_id detection
LLehner Feb 21, 2024
08653ee
Update cellbin_gef location and allow multiple mask files
LLehner Feb 21, 2024
422cba9
Add optional read arguments
LLehner Feb 21, 2024
81b366c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 21, 2024
072559a
Fix pre-commit
LLehner Feb 21, 2024
abc458e
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LLehner Feb 21, 2024
6f6dcf7
Update cellbin_gef location
LLehner Feb 23, 2024
10c267a
Fix duplicate key names in images and labels
LLehner Feb 26, 2024
df00ec3
Merge branch 'main' into Stereo-seq_reader
LucaMarconato May 7, 2024
d68ae3b
fix spelling
LucaMarconato May 7, 2024
ac34e78
fixed cellID being nan due to incorrect assigned name
LucaMarconato May 7, 2024
1872f11
fix metadata
LucaMarconato May 15, 2024
2b8f70f
wip bin data parsing
LucaMarconato May 16, 2024
85fde20
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 16, 2024
23af1bd
renamed StereoseqKeys to SK
LucaMarconato May 16, 2024
8ee712d
Merge branch 'Stereo-seq_reader' of https://github.com/LLehner/spatia…
LucaMarconato May 16, 2024
295e1b4
comparing points vs shapes for bins
LucaMarconato May 21, 2024
abf1471
using points for bins
LucaMarconato May 21, 2024
65cddb7
experiment with relabeling; I will remove the code
LucaMarconato May 22, 2024
e9bfc75
cleanup
LucaMarconato May 22, 2024
3c40d08
fix spatialdata dependency
LucaMarconato May 22, 2024
579d972
stereoseq fixes
LucaMarconato May 24, 2024
94112e1
changelog
LucaMarconato May 24, 2024
e1ce1ac
add stereoseq to readme
LucaMarconato May 24, 2024
9cd012c
cleanup
LucaMarconato May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning][].

- (Xenium) support reading multi-polygon selection files from the Xenium Explorer
- (ISS) An experimental loader to load elemental ISS data objects, e.g. raw.tif, label.tif and anndata.h5ad
- (Stereo-seq) Added reader @LLehner @timtreis @florianingelfinger #70

### Fixed

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This package contains reader functions to load common spatial omics formats into
- MCMICRO (output data)
- NanoString CosMx
- Steinbock (output data)
- STOmics Stereo-seq
- Vizgen MERSCOPE (MERFISH)

## Getting started
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ I/O for the `spatialdata` project.
mcmicro
merscope
steinbock
stereoseq
visium
visium_hd
xenium
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies = [
"anndata",
"numpy",
"scanpy",
"spatialdata",
"spatialdata>=0.1.2",
"scikit-image",
"h5py",
"joblib",
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 @@ -7,6 +7,7 @@
from spatialdata_io.readers.mcmicro import mcmicro
from spatialdata_io.readers.merscope import merscope
from spatialdata_io.readers.steinbock import steinbock
from spatialdata_io.readers.stereoseq import stereoseq
from spatialdata_io.readers.visium import visium
from spatialdata_io.readers.visium_hd import visium_hd
from spatialdata_io.readers.xenium import (
Expand All @@ -23,6 +24,7 @@
"cosmx",
"mcmicro",
"steinbock",
"stereoseq",
"merscope",
"xenium_aligned_image",
"xenium_explorer_selection",
Expand Down
73 changes: 73 additions & 0 deletions src/spatialdata_io/_constants/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,79 @@ class SteinbockKeys(ModeEnum):
LABEL_SUFFIX = ".tiff"


@unique
class StereoseqKeys(ModeEnum):
"""Keys for *Stereo-seq* formatted dataset."""

# file extensions
GEF_FILE = ".gef"
TIF_FILE = ".tif"
# directories
MERGE = "01.merge"
COUNT_DIRECTORY = "02.count"
REGISTER = "03.register"
TISSUECUT = "04.tissuecut"
SPATIALCLUSTER = "05.spatialcluster"
SATURATION = "06.saturation"
CELLCUT = "041.cellcut"
CELLCLUSTER = "051.cellcluster"
# file identifiers
MASK_TIF = "_mask.tif"
REGIST_TIF = "_regist.tif"
TISSUE_TIF = "_tissue_cut.tif"
CELL_CLUSTER_H5AD = "cell.cluster.h5ad"
RAW_GEF = ".raw.gef"
CELLBIN_GEF = ".cellbin.gef"
TISSUECUT_GEF = ".tissuecut.gef"
TISSUE_GEM = ".tissue.gem.gz"
# transcripts
FEATURE_KEY = "gene"
GENE_NAME = "geneName"
CELL_COUNT = "cellCount"
MAX_MID_COUNT = "maxMIDcount"
GENE_EXP = "geneExp"
EXPRESSION = "expression"
EXON = "exon"
GENE_ID = "geneID"
GENE_EXP_EXON = "geneExpExon"
# cells
ID = "id"
CELL_ID = "cellID"
GENE_COUNT = "geneCount"
DNBCOUNT = "dnbCount"
CELL_AREA = "area"
CELL_TYPE_ID = "cellTypeID"
CLUSTER_ID = "clusterID"
CELL_BIN = "cellBin"
CELL_EXON = "cellExon"
CELL_DATASET = "cell"
GENE_EXON = "geneExon"
CELL_BORDER = "cellBorder"
CELL_EXP = "cellExp"
CELL_EXP_EXON = "cellExpExon"
PADDING_VALUE = 32767
# metadata
COUNT = "count"
EXP_COUNT = "expCount"
OFFSET = "offset"
COORD_X = "x"
COORD_Y = "y"
SPATIAL_KEY = "spatial"
REGION = "cells"
REGION_KEY = "region"
INSTANCE_KEY = "instance_id"
BLOCK_INDEX = "blockIndex"
BLOCK_SIZE = "blockSize"
CELL_TYPE_LIST = "cellTypeList"
# bin data and metadata
BIN1 = "bin1"
MIN_X = "minX"
MIN_Y = "minY"
MAX_X = "maxX"
MAX_Y = "maxY"
RESOLUTION = "resolution"


@unique
class McmicroKeys(ModeEnum):
"""Keys for *Mcmicro* formatted dataset."""
Expand Down
18 changes: 18 additions & 0 deletions src/spatialdata_io/readers/_utils/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
from collections.abc import Mapping
from pathlib import Path
from typing import Any, Optional, Union

Expand Down Expand Up @@ -66,3 +67,20 @@ def _read_counts(

adata.uns["spatial"] = {library_id: {"metadata": {}}} # can overwrite
return adata, library_id


def _initialize_raster_models_kwargs(
image_models_kwargs: Mapping[str, Any], labels_models_kwargs: Mapping[str, Any]
) -> tuple[dict[str, Any], dict[str, Any]]:
image_models_kwargs = dict(image_models_kwargs)
if "chunks" not in image_models_kwargs:
image_models_kwargs["chunks"] = (1, 4096, 4096)
if "scale_factors" not in image_models_kwargs:
image_models_kwargs["scale_factors"] = [2, 2, 2, 2]

labels_models_kwargs = dict(labels_models_kwargs)
if "chunks" not in labels_models_kwargs:
labels_models_kwargs["chunks"] = (4096, 4096)
if "scale_factors" not in labels_models_kwargs:
labels_models_kwargs["scale_factors"] = [2, 2, 2, 2]
return image_models_kwargs, labels_models_kwargs
Loading
Loading