Giter Site home page Giter Site logo

mix-mmm's Introduction

MIX-MMM

Installation

conda env create -f environment.yml
source activate Mix-env

Training the model

python main.py train_model --dataset _ --num_clusters _ --use_cosmic _ --num_signatures _ --random_seed _ --max_iterations _

Available datasets are: ICGC-BRCA, TCGA-OV, MSK-ALL, BRCA-panel, OV-panel and more. The code can easily be changed to support more datasets as well as getting a file instead of a name of the dataset.

Use for developers

Developers can load data and precomputed signatures in anyway they want and use as follow

Denovo training:

from src.models.Mix import Mix

data # Loaded data in ndarray samplesXmutations
mix = MIX(num_clusters, num_topics)
mix.fit(data) 

Refit training:

from src.models.Mix import Mix

data # Loaded data in ndarray (samples, mutations)
signatures # Loaded signatures in ndarray (signatures, mutations) 
mix = MIX(num_clusters, num_topics, init_params={e: signatures})
mix.refit(data) 

Loading model from experiment file:

from src.utils import get_model, load_json

# Example for a path - 'experiments/{dataset}/{mode}/{settings}/{seed}.json'
mix = get_model(load_json(path_to_experiment_file)['parameters'])

Loading best seed under some settings:

from src.utils import get_model, load_json
from src.analyze_results import get_best_run

# Example for a path - 'experiments/{dataset}/{mode}/{settings}'
mix = get_model(load_json(get_best_run(path_to_settings))['parameters'])

Loading best model using BIC:

from src.analyze_results import get_best_model

# Example for a path - 'experiments/{dataset}/{mode}'
mix = get_best_model(path, return_model=True)

Reproducing paper results

First to prepare the synthetic data run

snakemake data_prep -j{num_cores}

This will train the Mix used for synthesizing data and synthesize the data. Then use the snakefile to reproduce all models used in the paper:

snakemake all -j{num_cores}

This will take a long time because each model is trained 10 times, so to save time and train only the best seed for each model, first change the False in line 6 in Snakefile to True (default is True). This will reduce running time by 10x, but still might take a long time, so if you are willing to drop the synthetic data results you can run:

snakemake all_no_synthetic -j{num_cores}

To get all results it is actually recommended to run in the following order:

snakemake all_no_synthetic -j{num_cores}
snakemake data_prep -j{num_cores}
snakemake all -j{num_cores}

Here the first command will create most results and in the process will creat the Mix model used to synthesize data, thus better for parallelization. Another way to produce (most likely) similar results but faster is to change the default 1000 iterations in line 7 in Snakefile. This will reduce running time but will change the results (for better or worse). Also note that the best seeds were chosen using 1000 iterations and there is no guarantee they are the best seeds for other max_iterations.

mix-mmm's People

Contributors

itaysason avatar tracyyxchen avatar

Watchers

 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.