Giter Site home page Giter Site logo

crystal's Introduction

crystal

python modules to evaluate methylation modeling strategies and find differentially methylated regions.

See additional documentation here

Here is an example of a region discovered by crystal where males have lower methylation than females dmr

quick-start

All functions to model clusters take:

  1. formula: a string model formula in R (or patsy syntax).
  2. a methylation cluster from aclust
  3. a pandas datafame containing the covariates of interest. The samples in this dataframe should be in the same order as they are in the methylation cluster.
  4. a coefficient of interest from the model.

So a single call would look like:

import pandas as pd
import aclust
import crystal

covs_df = pd.read_csv('covariates.csv')
cluster_iter = aclust.mclust(feature_gen(), max_dist=100)
crystal.zscore_cluster("methylation ~ disease + age + gender",
                        next(cluster_iter),
                        covs_df,
                        "disease")

Which will return a dictionary containing the p value, the coef and the t statistic for 'disease' status. However it is more likely that users will want a simple way to model every cluster:

for cluster in crystal.model_clusters(cluster_iter, covs_df,
                                      formula, "disease",
                                      crystal.zscore_cluster, n_cpu=10):
    print cluster

See the introduction notebook for more detail

Installation

users unaccustomed to installing their own python packages should download anaconda and then install additional modules with pip.

Running python setup.py install should work on systems with the scientific python stack.

How

Crystal works by generating clusters using aclust and then testing them against a chosen method. New methods can be implemented easily, but currently, there is:

  1. GEE: generalized estimating equation using sample as the grouping variable
  2. Mixed Effect Model: with a random intercept by sample
  3. Combining P-values: test each site in a region and combine the resulting p-values using the Stouffer-Liptak or Z-score method
  4. Bump(hunt)ing: A modification of bumphunting that works on local clusters and allows arbitrary metrics (not just the sum of the smoothed coefficients).

Methods using Robust regression are also available for the above.

Note that these are cleanly implemented in python thanks to the excellent statsmodels package

Evaluation

I have evaluated a number of methods for modeling correlated data (clusters). See the evaluation notebook for more detail. Here is the summary image--higher is better for the top plot and lower is better for the bottom plot:

evaluation

crystal's People

Contributors

brentp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

crystal's Issues

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.