Code Monkey home page Code Monkey logo

harmony-pytorch's Introduction

Harmony-Pytorch

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.

harmony-pytorch's People

Contributors

scottgigante-immunai avatar yihming avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.