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.
Metadata
Release files for harmony-pytorch 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| harmony-pytorch-0.1.8.tar.gz | 8.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harmony_pytorch-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.8 kB
Release files / harmony-pytorch-0.1.8.tar.gz
| Download URL | harmony-pytorch-0.1.8.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b097906d49c6ed9dde6cf234f7d987fb49a3b649b8a1323d99e6ea71b5b7df2
|
|
BLAKE2b-256 checksum How to use checksums |
8ddf71fe694d70ff148db2364c4118a6bbd37e598be269be471ed3d2f6bfee1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / harmony_pytorch-0.1.8-py3-none-any.whl
| Download URL | harmony_pytorch-0.1.8-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f92f6145ea93225b0226fda9da5bdd442e411d14ff402052afae0fde7fd1452
|
|
BLAKE2b-256 checksum How to use checksums |
75da42486f1c79b6f2db9140ee23161791e5b25d9369f30c1d9f67b67f3eb4bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|