Skip to main content

Atlas-level data integration in multi-condition single-cell genomics

Project description

iPerturb

iPerturb utilizes variational autoencoders for multi-condition integration of single-cell data at the population level. For more information, refer to the PyPI page. Sample information can be found in the vignettes.

Installation

Install using pip:

pip install iPerturb

Usage

After installation, you can use functions and classes from the iPerturb package in your Python code.

For example:

import iperturb as iPerturb
import torch
import scanpy as sc

cuda = torch.cuda.is_available()
if cuda:
    print('cuda is available')
else:
    print('cuda is not available')

# Load necessary datasets and parameters such as batch_key, condition_key, and groundtruth_key (optional)
dataset = 'Pbmc'
batch_key = 'batch'
condition_key = 'condition'
groundtruth_key = 'groundtruth'  # Used for calculating ARI

print(dataset + ' done!')

# Load real data
anndata = sc.read_h5ad('/data/chenyz/iPerturb_project/data/' + dataset + '.h5ad')
savepath = '/data/chenyz/iPerturb_project/Score/result/Result/' + dataset

datasets, raw, var_names, index_names = iPerturb.preprocess.data_load(anndata, batch_key=batch_key, condition_key=condition_key, groundtruth_key=groundtruth_key, n_top_genes=4000)
hyper = iPerturb.utils.create_hyper(datasets, var_names, index_names)

# Train the model
epochs = 30
optimizer = torch.optim.Adam

svi, scheduler, iPerturb_model = iPerturb.model.model_init_(hyper, latent_dim1=100, latent_dim2=30, latent_dim3=30, 
                                                            optimizer=optimizer, lr=0.006, gamma=0.2, milestones=[20], 
                                                            set_seed=123, cuda=cuda, alpha=1e-4)

x_pred, reconstruct_data = iPerturb.model.RUN(datasets, iPerturb_model, svi, scheduler, epochs, hyper, raw, cuda, batch_size=100, if_likelihood=True)

reconstruct_data.write(os.path.join(savepath, 'iPerturb.h5ad'))

`

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iperturb-0.2.6.tar.gz (11.2 kB view hashes)

Uploaded Source

Built Distribution

iperturb-0.2.6-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page