torch-adata
Project description
Create pytorch Datasets from AnnData
Installation
Install from PYPI:
pip install torch-adata
Install the developer version:
git clone https://github.com/mvinyard/torch-adata.git; cd torch-adata;
pip install -e .
Example use of the base class
The base class, AnnDataset
is a subclass of the widely-used torch.utils.data.Dataset
.
import anndata as a
import torch_adata
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = torch_adata.AnnDataset(adata)
Returns sampled data X_batch
as a torch.Tensor
.
# create a dummy index
idx = np.random.choice(range(dataset.__len__()), 5)
X_batch = dataset.__getitem__(idx)
TimeResolvedAnnDataset
Specialized class for time-resolved datasets. A subclass of the class, AnnDataset
.
import anndata as a
import torch_adata as ta
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = torch_adata.TimeResolvedAnnDataset(adata, time_key="Time point")
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
torch-adata-0.0.12.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for torch_adata-0.0.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff76d3933cde6e0657665bee526f503f69b53909a07d276907352adc8e6f9487 |
|
MD5 | 18cbe1f81c1fc7aa42b19de827fbbfc1 |
|
BLAKE2b-256 | 9a8b81387bae58a38b1ca56a906958673bcdef3cd881f4406667dbd30843d549 |