• Stars
    star
    338
  • Rank 124,931 (Top 3 %)
  • Language
    Jupyter Notebook
  • License
    GNU General Publi...
  • Created over 8 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MAGIC (Markov Affinity-based Graph Imputation of Cells), is a method for imputing missing values restoring structure of large biological datasets.

Markov Affinity-based Graph Imputation of Cells (MAGIC)

Latest PyPI version Latest CRAN version GitHub Actions Build Read the Docs Cell Publication DOI Twitter Github Stars

Markov Affinity-based Graph Imputation of Cells (MAGIC) is an algorithm for denoising high-dimensional data most commonly applied to single-cell RNA sequencing data. MAGIC learns the manifold data, using the resultant graph to smooth the features and restore the structure of the data.

To see how MAGIC can be applied to single-cell RNA-seq, elucidating the epithelial-to-mesenchymal transition, read our publication in Cell.

David van Dijk, et al. Recovering Gene Interactions from Single-Cell Data Using Data Diffusion. 2018. Cell.

MAGIC has been implemented in Python, Matlab, and R.

To get started immediately, check out our tutorials:

Python
R


Magic reveals the interaction between Vimentin (VIM), Cadherin-1 (CDH1), and Zinc finger E-box-binding homeobox 1 (ZEB1, encoded by colors).

Table of Contents

Python

Installation

Installation with pip

To install with pip, run the following from a terminal:

pip install --user magic-impute

Installation from GitHub

To clone the repository and install manually, run the following from a terminal:

git clone git://github.com/KrishnaswamyLab/MAGIC.git
cd MAGIC/python
python setup.py install --user

Usage

Quick Start

The following code runs MAGIC on test data located in the MAGIC repository.

import magic
import pandas as pd
import matplotlib.pyplot as plt
X = pd.read_csv("MAGIC/data/test_data.csv")
magic_operator = magic.MAGIC()
X_magic = magic_operator.fit_transform(X, genes=['VIM', 'CDH1', 'ZEB1'])
plt.scatter(X_magic['VIM'], X_magic['CDH1'], c=X_magic['ZEB1'], s=1, cmap='inferno')
plt.show()
magic.plot.animate_magic(X, gene_x='VIM', gene_y='CDH1', gene_color='ZEB1', operator=magic_operator)

Tutorials

You can read the MAGIC documentation at https://magic.readthedocs.io/. We have included two tutorial notebooks on MAGIC usage and results visualization for single cell RNA-seq data.

EMT data notebook: http://nbviewer.jupyter.org/github/KrishnaswamyLab/MAGIC/blob/master/python/tutorial_notebooks/emt_tutorial.ipynb

Bone Marrow data notebook: http://nbviewer.jupyter.org/github/KrishnaswamyLab/MAGIC/blob/master/python/tutorial_notebooks/bonemarrow_tutorial.ipynb

Matlab

Instructions for the Matlab version

  1. run_magic.m -- MAGIC imputation function
  2. test_magic.m -- Shows how to run MAGIC. Also included is a function for loading 10x format data (load_10x.m)

R

Installation

To use MAGIC, you will need to install both the R and Python packages.

If python or pip are not installed, you will need to install them. We recommend Miniconda3 to install Python and pip together, or otherwise you can install pip from https://pip.pypa.io/en/stable/installing/.

Installation from CRAN

In R, run this command to install MAGIC and all dependencies:

install.packages("Rmagic")

In a terminal, run the following command to install the Python repository.

pip install --user magic-impute

Installation from GitHub

To clone the repository and install manually, run the following from a terminal:

git clone git://github.com/KrishnaswamyLab/MAGIC.git
cd MAGIC/python
python setup.py install --user
cd ../Rmagic
R CMD INSTALL .

Usage

Quick Start

After installing the package, MAGIC can be run by loading the library and calling magic():

library(Rmagic)
library(ggplot2)
data(magic_testdata)
MAGIC_data <- magic(magic_testdata, genes=c("VIM", "CDH1", "ZEB1"))
ggplot(MAGIC_data) +
  geom_point(aes(x=VIM, y=CDH1, color=ZEB1))

Tutorials

You can read the MAGIC tutorial by running help(Rmagic::magic). For a working example, see the Rmarkdown tutorials at http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/bonemarrow_tutorial.html and http://htmlpreview.github.io/?https://github.com/KrishnaswamyLab/MAGIC/blob/master/Rmagic/inst/examples/emt_tutorial.html or in Rmagic/inst/examples.

Help

If you have any questions or require assistance using MAGIC, please contact us at https://krishnaswamylab.org/get-help.

More Repositories

1

PHATE

PHATE (Potential of Heat-diffusion for Affinity-based Transition Embedding) is a tool for visualizing high dimensional data.
Python
436
star
2

SAUCIE

Python
98
star
3

TrajectoryNet

TrajectoryNet: A Dynamic Optimal Transport Network for Modeling Cellular Dynamics
Jupyter Notebook
98
star
4

SingleCellWorkshop

Jupyter Notebook
87
star
5

scprep

A collection of scripts and tools for loading, processing, and handling single cell data.
Python
73
star
6

phateR

PHATE dimensionality reduction method implemented in R
HTML
73
star
7

ReLSO-Guided-Generative-Protein-Design-using-Regularized-Transformers

a Transformer-based neural network for generating highly optimized protein sequences called Regularized Latent Space Optimization (RELSO)
Jupyter Notebook
71
star
8

Multiscale_PHATE

Creating multi-resolution embeddings and clusters from high dimensional data
Jupyter Notebook
48
star
9

travelgan

Python
46
star
10

graphtools

Tools for building and manipulating graphs in Python
Python
41
star
11

DiffusionEMD

Code corresponding to the paper Diffusion Earth Mover's Distance and Distribution Embeddings
Jupyter Notebook
27
star
12

AAnet

Archetypal Analysis network (AAnet)
Jupyter Notebook
23
star
13

TPHATE

Python
22
star
14

MAGAN

Python
17
star
15

MIOFlow

Jupyter Notebook
17
star
16

phemd

Identifying cell subpopulational differences among single-cell biospecimens
R
12
star
17

PECAN

PECAN: Persistent Condensation
Jupyter Notebook
9
star
18

SUGAR

Synthesis using Geometrically Aligned Random-walks
MATLAB
7
star
19

CATCH

Learning cellular hierarchy from scRNAseq data
Jupyter Notebook
7
star
20

GSAE

Code from 'Uncovering the Folding Landscape of RNA Secondary Structure with Deep Graph Embeddings"
Jupyter Notebook
7
star
21

HeatGeo

Embedding with the Heat-geodesic dissimilarity
Jupyter Notebook
6
star
22

visualization_selection

Selecting the right tool for the job: understanding drawbacks and biases in visualization methods
Jupyter Notebook
6
star
23

LearnableScattering

Learnable Geometric Scattering Network
Python
6
star
24

CUTS

[MICCAI 2024] CUTS: A Deep Learning and Topological Framework for Multigranular Unsupervised Medical Image Segmentation
Python
5
star
25

LAD

Lipschitz Anomaly Discriminator
Python
5
star
26

logicml

C
5
star
27

CurveNet

Diffusion curvature and Hessian prediction using point samples from quadratic hypersurfaces
MATLAB
5
star
28

Cell-Dynamics-Pipeline

Python
5
star
29

scgraph

Graph-based methods for the analysis of single-cell data
Python
5
star
30

ImageFlowNet

Python
5
star
31

GeoSinkhorn

Code for the paper Geodesic Sinkhorn for Fast and Accurate Optimal Transport on Manifolds.
Python
4
star
32

GSPA-manuscript-analyses

Learning meaningful representations of genes
Jupyter Notebook
4
star
33

Gene-Signal-Pattern-Analysis

Learning meaningful representations of genes
Jupyter Notebook
3
star
34

graph_fit

New ways of fitting a graph to vector data.
Jupyter Notebook
3
star
35

pointcloud_scattering

Python
3
star
36

scnn

Deep learning methods for the analysis of single-cell data
Python
2
star
37

Trellis

2
star
38

NN-LossLandscape-PHATE

Exploring the Geometry and Topology of Neural Network Loss Landscapes
Python
2
star
39

CSHL_ComputationalGenomics2022

2
star
40

Directed-Hierarchical-Gene-Networks

Python
2
star
41

scMMGAN

Python
2
star
42

RiTINI

Regulatory Temporal Interaction Network Inference
2
star
43

spARC

Denoising spatial transcriptomics data
Jupyter Notebook
2
star
44

GEFMAP

Jupyter Notebook
2
star
45

CSHL_ComputationalGenomics2023

2
star
46

krishnaswamy-lab-site

Svelte
1
star
47

phate-docker

Interactive command line docker script for running PHATE
Python
1
star
48

NSCLC_pembro_sbrt

Jupyter Notebook
1
star
49

GRASSY-Net

Python
1
star
50

NeuronTransform

Python
1
star
51

FMGAN

Python
1
star
52

Condensation

Diffusion Condensation is a topologically-inspired machine learning algorithm that is used to identify populations of cells across granularities.
Jupyter Notebook
1
star