torch-adata
Reason this release was yanked:
misordered
Project description
torch-adata
Create pytorch Datasets from AnnData
Example use of the base class
The base class, AnnDataset
is a subclass of the widely-used torch.utils.data.Dataset
. The outputs of all AnnDataset
classes and subclasses are designed to be directly compatible with the torch.utils.data.DataLoader
module.
import anndata as a
import torch_adata as ta
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = ta.AnnDataset(adata)
Returns data (X
as a torch.Tensor
) and the pandas.DataFrame
; adata.obs
.
# create a dummy index
idx = np.random.choice(range(dataset.__len__()), 5)
X, obs = dataset.__getitem__(idx)
Specialized classes
GroupedAnnDataset
A subclass of the base class, AnnDataset
.
import anndata as a
import torch_adata as ta
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = ta.GroupedAnnDataset(adata, groupby="batch")
Returns data as a dictionary of data with values as torch.Tensor
and keys as each groupby
category and the sampled adata.obs
is again returned as a pandas.DataFrame
.
# create a dummy index
idx = np.random.choice(range(dataset.__len__()), 5)
X_dict, obs = dataset.__getitem__(idx)
TimeResolvedAnnDataset
A subclass of the class, GroupedAnnDataset
.
import anndata as a
import torch_adata as ta
adata = a.read_h5ad("/path/to/data.h5ad")
dataset = ta.TimeResolvedAnnDataset(adata, time_key="Time point")
Returns the initial datapoint, X0
as a torch.Tensor
, the entire sample of the dataset as a dictionary of data with values as torch.Tensor
and keys as each timepoint indicated by the time_key
. Sampled adata.obs
is again returned as a pandas.DataFrame
.
# create a dummy index
idx = np.random.choice(range(dataset.__len__()), 5)
X0, X_dict, t, obs = dataset.__getitem__(idx)
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 .
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
Hashes for torch_adata-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fce1f6c6c238a4e9511f44cd7f44e11d081da9a9a4104ca50c5b7a2a29a8b80 |
|
MD5 | fe9d792a57c99719fb75fdd88cd51cae |
|
BLAKE2b-256 | 1ca53fb5b7887d5e46f0ca682e9acf343cd36174029cc582825ae59281eab3c7 |