Read and write Spatial Experiments to takane representations
Project description
Save and write SpatialExperiment's in Python
Introduction
The dolomite-spatial package is the Python counterpart to the alabaster.spatial R package,
providing methods for saving/reading SpatialExperiment objects within the dolomite framework.
Quick start
Let's mock up a SpatialExperiment that contains reduced dimensions and alternative experiments,
from spatialexperiment import SpatialExperiment, construct_spatial_image_class
import biocframe
import numpy as np
spe = SpatialExperiment(
assays={"counts": np.random.rand(1000, 200)},
row_data=biocframe.BiocFrame(
{"foo": np.random.rand(1000), "bar": np.random.rand(1000)}
),
column_data=biocframe.BiocFrame(
{"whee": np.random.rand(200), "stuff": np.random.rand(200), "sample_id": ["sample_1", "sample_2"] * 100}
),
reduced_dims={"tsnooch": np.random.rand(200, 4)},
spatial_coords = np.array(
[
np.random.uniform(low=0.0, high=100.0, size=200),
np.random.uniform(low=0.0, high=100.0, size=200)
]
).transpose(),
img_data = biocframe.BiocFrame({
"sample_id": ["sample_1", "sample_1", "sample_2"],
"image_id": ["aurora", "dice", "desert"],
"data": [
construct_spatial_image_class("biocpy/spatialexperiment/tests/images/sample_image1.jpg"),
construct_spatial_image_class("biocpy/spatialexperiment/tests/images/sample_image2.png"),
construct_spatial_image_class("biocpy/spatialexperiment/tests/images/sample_image3.jpg"),
],
"scale_factor": [1, 1, 1],
})
)
print(spe)
Now we can save it:
from dolomite_base import save_object
import dolomite_spatial
import os
from tempfile import mkdtemp
path = os.path.join(mkdtemp(), "test")
save_object(spe, path)
And load it again, e,g., in a new session:
from dolomite_base import read_object
roundtrip = read_object(path)
print(roundtrip)
## output
class: SpatialExperiment
dimensions: (1000, 200)
assays(1): ['counts']
row_data columns(2): ['foo', 'bar']
row_names(0):
column_data columns(3): ['whee', 'stuff', 'sample_id']
column_names(0):
main_experiment_name:
reduced_dims(1): ['tsnooch']
alternative_experiments(0): []
row_pairs(0): []
column_pairs(0): []
metadata(0):
spatial_coords columns(0): []
img_data columns(4): ['sample_id', 'image_id', 'data', 'scale_factor']
Note
This project has been set up using BiocSetup and PyScaffold.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dolomite_spatial-0.1.1.tar.gz.
File metadata
- Download URL: dolomite_spatial-0.1.1.tar.gz
- Upload date:
- Size: 964.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04648f40244645d15dc5f5005931183aaa63df2da39809f8147603f7242a334b
|
|
| MD5 |
16ffebf7e56569fe81c0b821e517150b
|
|
| BLAKE2b-256 |
87e4a975ade9e65d4356d88109c3cad8fe4b59d79826c85de380bcf97b06f21c
|
Provenance
The following attestation bundles were made for dolomite_spatial-0.1.1.tar.gz:
Publisher:
publish-pypi.yml on ArtifactDB/dolomite-spatial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dolomite_spatial-0.1.1.tar.gz -
Subject digest:
04648f40244645d15dc5f5005931183aaa63df2da39809f8147603f7242a334b - Sigstore transparency entry: 213036931
- Sigstore integration time:
-
Permalink:
ArtifactDB/dolomite-spatial@337040e691bb99043b455809eeee7defe8821edc -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ArtifactDB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@337040e691bb99043b455809eeee7defe8821edc -
Trigger Event:
push
-
Statement type:
File details
Details for the file dolomite_spatial-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dolomite_spatial-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a242eb7969c04d4b1be98bf953c9604e455b57dc8453d922c17852c5db319e1
|
|
| MD5 |
fa19ad5c6aff07c07cfc043cfde8154e
|
|
| BLAKE2b-256 |
fd18c9678d74f6fccb6549bd6de83c9359c021b3c6711b39b6f767db2f5eb273
|
Provenance
The following attestation bundles were made for dolomite_spatial-0.1.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on ArtifactDB/dolomite-spatial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dolomite_spatial-0.1.1-py3-none-any.whl -
Subject digest:
6a242eb7969c04d4b1be98bf953c9604e455b57dc8453d922c17852c5db319e1 - Sigstore transparency entry: 213036935
- Sigstore integration time:
-
Permalink:
ArtifactDB/dolomite-spatial@337040e691bb99043b455809eeee7defe8821edc -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/ArtifactDB
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@337040e691bb99043b455809eeee7defe8821edc -
Trigger Event:
push
-
Statement type: