Code Monkey home page Code Monkey logo

harmony's Introduction

Harmony

Scalable integration of single cell RNAseq data for batch correction and meta analysis

Check out the latest preprint of Harmony on bioRxiv

Installation

To run Harmony, open R and install directly from github using the following commands:

library(devtools)
install_github("immunogenomics/harmony")

Usage

We made it easy to run Harmony in most common R analysis pipelines.

Normalized gene matrix

The simplest way to run Harmony is on a sparse matrix of library size normalized expression counts. Harmony will scale these counts, run PCA, and finally perform integration.

library(harmony)
my_harmony_embeddings <- HarmonyMatrix(normalized_counts, meta_data, "dataset")

PCA matrix

The Harmony algorithm iteratively corrects PCA embeddings. To input your own low dimensional embeddings directly, set do_pca=FALSE.

library(harmony)
my_harmony_embeddings <- HarmonyMatrix(my_pca_embeddings, meta_data, "dataset", do_pca=FALSE)

Seurat

You can run Harmony within your Seurat workflow. You'll only need to make two changes to your code.

  1. Run Harmony with the RunHarmony() function
  2. In downstream analyses, use the Harmony embeddings instead of PCA.

For example, run Harmony and then UMAP in two lines.

seuratObj <- RunHarmony(seuratObj, "dataset")
seuratObj <- RunUMAP(seuratObj, reduction = "harmony")

For details, check out these vignettes:

MUDAN

You can run Harmony with functions from the MUDAN package. For more, details, check out this vignette.

Harmony with two or more covariates

Harmony can integrate over multiple covariates. To do this, specify a vector covariates to integrate.

my_harmony_embeddings <- HarmonyMatrix(my_pca_embeddings, meta_data, c("dataset", "donor", "batch_id"), do_pca=FALSE)

Do the same with your Seurat object:

seuratObject <- RunHarmony(seuratObject, c("dataset", "donor", "batch_id"))

Advanced

The examples above all return integrated PCA embeddings. We created a more advanced tutorial that explores the internal data structures used in the Harmony algorithm.

harmony's People

Contributors

ilyakorsunsky avatar jefworks avatar

Watchers

James Cloos 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.