Skip to main content

Pytorch implementation of Harmony algorithm on single-cell sequencing data integration

Project description

PyPI Conda Python License

This is a Pytorch implementation of Harmony algorithm on single-cell sequencing data integration. Please see Ilya Korsunsky et al., 2019 for details.

Installation

This package is published on PyPI:

pip install harmony-pytorch

Usage

General Case

Given an embedding X as a N-by-d matrix in numpy array structure (N for number of cells, d for embedding components) and cell attributes as a Data Frame df_metadata, use Harmony for data integration as the following:

from harmony import harmonize
Z = harmonize(X, df_metadata, batch_key = 'Channel')

where Channel is the attribute in df_metadata for batches.

Alternatively, if there are multiple attributes for batches, write:

Z = harmonize(X, df_metadata, batch_key = ['Lab', 'Date'])

Input as MultimodalData Object

It’s easy for Harmony-pytorch to work with count matrix data structure from PegasusIO package. Let data be a MultimodalData object in Python:

from harmony import harmonize
Z = harmonize(data.obsm['X_pca'], data.obs, batch_key = 'Channel')
data.obsm['X_pca_harmony'] = Z

This will calculate the harmonized PCA matrix for the default UnimodalData of data.

Given a UnimodalData object unidata, you can also use the code above to perform Harmony algorithm: simply substitute unidata for data there.

Input as AnnData Object

It’s easy for Harmony-pytorch to work with annotated count matrix data structure from anndata package. Let adata be an AnnData object in Python:

from harmony import harmonize
Z = harmonize(adata.obsm['X_pca'], adata.obs, batch_key = '<your-batch-key>')
adata.obsm['X_harmony'] = Z

where <your-batch-key> should be replaced by the actual batch key attribute name in your data.

For details about AnnData data structure, please refer to its documentation.

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

harmony-pytorch-0.1.6.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

harmony_pytorch-0.1.6-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file harmony-pytorch-0.1.6.tar.gz.

File metadata

  • Download URL: harmony-pytorch-0.1.6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for harmony-pytorch-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c72cdf43882794ca7d247fa5585d44d9a62dd800a247f2ba463209d373c448c1
MD5 969515be561126cb70abf6928b3c36b2
BLAKE2b-256 7f5dd36f77ccbda8dc1990adc737c1c9a98b4afe9b7707aa8bc74e3b36a8b268

See more details on using hashes here.

File details

Details for the file harmony_pytorch-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: harmony_pytorch-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

File hashes

Hashes for harmony_pytorch-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 daf19453b4d5f0ac72c64379bd07660022fa1c14856814c64914d373f92cc8b6
MD5 0b9510610a7fae0ff1355aba4003f2fa
BLAKE2b-256 fc8dc03eee0c02dbe25f1ef17547923f4090a6479c3dbec50826e23227dc5500

See more details on using hashes here.

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