Skip to content

koteth/python_mcl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCL algorithm

This module implements the Markov Cluster algorithm created by Stijn van Dongen and described in http://www.library.uu.nl/digiarchief/dip/diss/1895620/inhoud.htm.

This implementation is still in beta and is not yet optimized for large networks.

![example] (example.png)

##Installation

python setup.py install

##Usage

###Command line

Usage: mcl_clustering.py [options] <input_matrix>

Options
  -h, --help            show this help message and exit
  -e EXPAND_FACTOR, --expand_factor=EXPAND_FACTOR
                        expand factor (default: 2)
  -i INFLATE_FACTOR, --inflate_factor=INFLATE_FACTOR
                        inflate factor (default: 2)
  -m MULT_FACTOR, --mult_factor=MULT_FACTOR
                        multiply factor (default: 2)
  -l MAX_LOOP, --max_loops=MAX_LOOP
                        max loops (default: 60)
  -o FILE, --output=FILE
                        output (default: stdout)
  -v, --verbose         verbose (default: True)
  -d, --draw-graph      show graph with networkx (default: False)

The input matrix must be as comma-separated value file representing the adjacency matrix.

An example is the file example.csv in examples dir.

try: mcl_clustering.py -d -e 3 <example_path>/example.csv

###Code

####Using numpy adjacency matrix

from mcl_clustering import mcl

A = <your matrix>

M, clusters = mcl(A, expand_factor = <expand_factor>,
                   inflate_factor = <inflate_factor>,
                   max_loop = <max_loop>,
                   mult_factor = <mult_factor>)

####Using a networkx graph

from mcl_clustering import networkx_mcl

G = <your graph>

M, clusters = networkx_mcl(G, expand_factor = <expand_factor>,
                   inflate_factor = <inflate_factor>,
                   max_loop = <max_loop>,
                   mult_factor = <mult_factor>)


Output
    M = otuput matrix
    clusters = dict with keys = [<cluster id>] values = [<vertex id>]

##Requirements

numpy
networkx

##References

license

MIT

About

markov cluster algorithm - python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages