Giter Site home page Giter Site logo

luxiancao / tanglegram Goto Github PK

View Code? Open in Web Editor NEW

This project forked from schlegelp/tanglegram

0.0 0.0 0.0 66 KB

Python wrapper for scipy and matplotlib to plot tanglegrams from two dendrograms

License: GNU General Public License v3.0

Python 100.00%

tanglegram's Introduction

tanglegram

Uses scipy and matplotlib to plot simple tanglegrams. Inspired by the amazing dendextend by Tal Galili.

Installation

First, get PIP and then run in terminal:

pip3 install tanglegram -U

To install the bleeding-edge version from Github you can run:

pip3 install git+git://github.com/schlegelp/tanglegram@master

Attention: on Windows, the dependencies (i.e. Numpy, Pandas and SciPy) will likely fail to install automatically. Your best bet is to get a Python distribution that already includes them (e.g. Anaconda).

Dependencies

Installing via PIP should install all external dependencies. You may run into problems on Windows though. In that case, you need to install dependencies manually, here is a list of dependencies (check out install_requires in setup.py for version info):

How it works

tanglegram exposes three functions:

  1. tanglegram.plot plots a tanglegram (optionally untangling)
  2. tanglegram.entanglement measures the entanglement between two linkages
  3. tanglegram.untangle rotates dendrograms to minimize entanglement
import tanglegram as tg
import matplotlib.pyplot as plt
import pandas as pd

# Generate two distance matrices and just switch labels in one
labelsA= ['A', 'B', 'C', 'D']
labelsB= ['B', 'A', 'C', 'D']
data = [[ 0,  .1,  .4, .3],
        [.1,   0,  .5, .6],
        [ .4, .5,   0, .2],
        [ .3, .6,  .2,  0]]

mat1 = pd.DataFrame(data,
                    columns=labelsA,
                    index=labelsA)

mat2 = pd.DataFrame(data,
                    columns=labelsB,
                    index=labelsB)

# Plot tanglegram
fig = tg.plot(mat1, mat2, sort=False)
plt.show()

# Plot again but this time try minimizing cross-over
fig = tg.plot(mat1, mat2, sort=True)
plt.show()

Known Issues:

  • layout does not scale well, i.e. small dendrograms look weird

License:

This code is under GNU GPL V3

tanglegram's People

Contributors

schlegelp avatar vannghia69 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.