torch-adata: bridging AnnData-based data models to torch.
Project description
Create PyTorch Datasets
from AnnData
Installation
Install from PYPI (current version: 0.0.24
):
pip install torch-adata
Install the developer version:
git clone https://github.com/mvinyard/torch-adata.git; cd torch-adata;
pip install -e .
The main API
The primary class is the AnnDataset
. This is a subclass of the widely-used torch.utils.data.Dataset
. The PyTorch Dataset
module enables us to take advantage of built-in multiprocessing and other organizational tricks that ultimately standardize workflows and enable reproducibility.
import anndata as a
import torch_adata
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = torch_adata.AnnDataset(adata, use_key="X_pca", groupby="time", obs_keys=["affinity"])
[ torch-adata ]: AnnDataset object with 7131 samples
----------------------------------------------------
Grouped by: 'time' with attributes:
- X (use_key = 'X_pca') torch.Size([3, 7131, 50])
- obs: affinity: torch.Size([3, 7131, 1])
There is an additional approach to this dubbed AnnLoader
, highlighted by Sergei Rybakov in Interfacing pytorch models with anndata
For more information, please visit the documentation!
Problem? Open an issue
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
File details
Details for the file torch_adata-0.1.0.tar.gz
.
File metadata
- Download URL: torch_adata-0.1.0.tar.gz
- Upload date:
- Size: 32.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e57375a65ac746fc3fe0637221c9db1e84248410f34edbfd8a09b299d0f2aba |
|
MD5 | 3fd872c06005c249d5c319c23b794e54 |
|
BLAKE2b-256 | 1c329618a7ff0d14b04346d3b0313354c974acad1ac912a1a1970c4bc3082727 |
File details
Details for the file torch_adata-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: torch_adata-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068a8b131e8988b7cd711cf242016e7f93e2a288f654c5064e6cc2b09319a7fa |
|
MD5 | 789252406e379aeae8cb9c654b315cb3 |
|
BLAKE2b-256 | d6ac333e0eac4cab29ca652da1538e80267d4101fa0ce810a750e92c8b0c3223 |