Zero-inflated dimensionality reduction algorithm for single-cell data
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
LICENSE.txt added license Oct 8, 2015


Zero-inflated dimensionality reduction algorithm for single-cell data. Created by Emma Pierson and Christopher Yau.


@article{pierson2015zifa, title={ZIFA: Dimensionality reduction for zero-inflated single-cell gene expression analysis}, author={Pierson, Emma and Yau, Christopher}, journal={Genome biology}, volume={16}, number={1}, pages={1}, year={2015}, publisher={BioMed Central} }


If you are using count data, we recommend taking the log (ie, Y = log2(1 + count_data)) prior to using ZIFA.

Algorithm code is contained in and For datasets with more than a few thousand genes, we recommend using block_ZIFA, which subsamples genes in blocks to increase efficiency; it should yield similar results to ZIFA. Runtime for block ZIFA on the full single-cell dataset from Pollen et al, 2014 (~250 samples, ~20,000 genes) is approximately 15 minutes on a quadcore Mac Pro.

Runtime for block ZIFA is roughly linear in the number of samples and the number of genes, and quadratic in the block size. Decreasing the block size may decrease runtime but will also produce less reliable results.

See for a full example demonstrating superior performance over factor analysis.

See for a example demonstrating how to read in real data using pandas and run ZIFA on it.

ZIFA requires pylab, scipy, numpy, and scikit.learn for full functionality.

Prior to issuing pull requests, please confirm that your code passes the tests by running (If you are using a different version of scipy, numpy, or sklearn, the results may be slightly different -- in that case, please report how much you have to increase the absolute_tolerance parameter to get them to pass.) The tests take about 30 seconds to run.

Please contact with any questions or comments.


Download the code: git clone

Install the package: cd ZIFA then python install

##Sample usage

from ZIFA import ZIFA
from ZIFA import block_ZIFA

To fit ZIFA:

Z, model_params = ZIFA.fitModel(Y, k)

To fit with the block algorithm:

Z, model_params = block_ZIFA.fitModel(Y, k)


Z, model_params = block_ZIFA.fitModel(Y, k, n_blocks = desired_n_blocks)

where Y is the observed zero-inflated data, k is the desired number of latent dimensions, and Z is the low-dimensional projection and desired_n_blocks is the number of blocks to divide genes into. By default, the number of blocks is set to n_genes / 500 (yielding a block size of approximately 500).