{"id":25527358,"url":"https://github.com/biocpy/spatialexperiment","last_synced_at":"2025-04-11T06:11:15.023Z","repository":{"id":273614135,"uuid":"917881384","full_name":"BiocPy/SpatialExperiment","owner":"BiocPy","description":"Container for Spatial Experiments","archived":false,"fork":false,"pushed_at":"2025-02-17T22:12:26.000Z","size":2802,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T22:32:44.156Z","etag":null,"topics":["spatial-data"],"latest_commit_sha":null,"homepage":"https://biocpy.github.io/SpatialExperiment/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BiocPy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-16T20:22:51.000Z","updated_at":"2025-02-10T16:43:54.000Z","dependencies_parsed_at":"2025-01-22T00:20:25.341Z","dependency_job_id":"0916ca68-d0d5-4e39-b615-b8369621e880","html_url":"https://github.com/BiocPy/SpatialExperiment","commit_stats":null,"previous_names":["biocpy/spatialexperiment"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiocPy%2FSpatialExperiment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiocPy%2FSpatialExperiment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiocPy%2FSpatialExperiment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BiocPy%2FSpatialExperiment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BiocPy","download_url":"https://codeload.github.com/BiocPy/SpatialExperiment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239742405,"owners_count":19689310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["spatial-data"],"created_at":"2025-02-19T22:18:18.655Z","updated_at":"2025-04-11T06:11:15.015Z","avatar_url":"https://github.com/BiocPy.png","language":"Python","readme":"[![PyPI-Server](https://img.shields.io/pypi/v/SpatialExperiment.svg)](https://pypi.org/project/SpatialExperiment/)\n![Unit tests](https://github.com/BiocPy/SpatialExperiment/actions/workflows/run-tests.yml/badge.svg)\n\n# SpatialExperiment\n\nA Python package for storing and analyzing spatial-omics experimental data. `SpatialExperiment` extends [SingleCellExperiment](https://github.com/biocpy/singlecellexperiment) with dedicated slots for image data and spatial coordinates, making it ideal for spatial transcriptomics and other spatially-resolved omics data.\n\n\u003e [!NOTE]\n\u003e\n\u003e This package is in **active development**.\n\n## Install\n\nTo get started, install the package from [PyPI](https://pypi.org/project/SpatialExperiment/)\n\n```bash\npip install spatialexperiment\n```\n\n## Usage\n\nThe `SpatialExperiment` class extends `SingleCellExperiment` with the following key attributes:\n\n- `spatial_coords`: A BioFrame containing spot/cell spatial coordinates relative to the image, typically including:\n  - x-coordinates\n  - y-coordinates\n  - Additional spatial metadata\n\n- `img_data`: A BiocFrame containing image-related information:\n  - sample_ids: Unique identifiers for each sample\n  - image_ids: Unique identifiers for each image\n  - data: The actual image data\n  - scale_factor: Scaling factors for proper image interpretation\n\n- `column_data`: Contains sample_id mappings that link spots to their corresponding images\n\n### Quick Start\n\nHere's how to create a SpatialExperiment object from scratch:\n\n```python\nfrom spatialexperiment import SpatialExperiment, construct_spatial_image_class\nimport numpy as np\nfrom biocframe import BiocFrame\n\n# Create example data\nnrows = 200  # Number of features (e.g., genes)\nncols = 500  # Number of spots/cells\n\n# Generate random count data\ncounts = np.random.rand(nrows, ncols)\n\n# Create feature annotations\nrow_data = BiocFrame({\n    \"gene_ids\": [f\"gene_{i}\" for i in range(nrows)],\n    \"gene_names\": [f\"Gene_{i}\" for i in range(nrows)]\n})\n\n# Create spot/cell annotations\ncol_data = BiocFrame({\n    \"n_genes\": [50, 200] * int(ncols / 2),\n    \"condition\": [\"healthy\", \"tumor\"] * int(ncols / 2),\n    \"cell_id\": [f\"spot_{i}\" for i in range(ncols)],\n    \"sample_id\": [\"sample_1\"] * int(ncols / 2) + [\"sample_2\"] * int(ncols / 2),\n})\n\n# Generate spatial coordinates\nspatial_coords = BiocFrame({\n    \"x\": np.random.uniform(low=0.0, high=100.0, size=ncols),\n    \"y\": np.random.uniform(low=0.0, high=100.0, size=ncols)\n})\n\n# Create image data\nimg_data = BiocFrame({\n    \"sample_id\": [\"sample_1\", \"sample_1\", \"sample_2\"],\n    \"image_id\": [\"aurora\", \"dice\", \"desert\"],\n    \"data\": [\n        construct_spatial_image_class(\"tests/images/sample_image1.jpg\"),\n        construct_spatial_image_class(\"tests/images/sample_image2.png\"),\n        construct_spatial_image_class(\"tests/images/sample_image3.jpg\"),\n    ],\n    \"scale_factor\": [1, 1, 1],\n})\n\n# Create SpatialExperiment object\nspe = SpatialExperiment(\n    assays={\"counts\": counts},\n    row_data=row_data,\n    column_data=col_data,\n    spatial_coords=spatial_coords,\n    img_data=img_data,\n)\n```\n\nFor more detailed information about available methods and functionality, please refer to the [SingleCellExperiment documentation](https://biocpy.github.io/SingleCellExperiment/).\n\n\n\u003c!-- biocsetup-notes --\u003e\n\n## Note\n\nThis project has been set up using [BiocSetup](https://github.com/biocpy/biocsetup)\nand [PyScaffold](https://pyscaffold.org/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiocpy%2Fspatialexperiment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiocpy%2Fspatialexperiment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiocpy%2Fspatialexperiment/lists"}