Skip to main content

Plots simple tanglegrams from two dendrograms

Project description

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

## Installation
I recommend using [Python Packaging Index (PIP)]( to install the package.
First, get [PIP]( and then run in terminal:

`pip install git+git://`

This command should also work to update the package.

**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](

If your default distribution is Python 2, you have to explicitly tell [PIP]( to install for Python 3:

`pip3 install git+git://`

#### External libraries used:
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 []( for version info):

- [Pandas](
- [SciPy](
- [Numpy](
- [Matplotlib](
- [Tqdm](

## Quickstart:

import tanglegram as tg
import numpy as np
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,

mat2 = pd.DataFrame(data,

# Plot tanglegram
fig = tg.gen_tangle(mat1, mat2, optimize_order=False)

# Plot again but this time try minimizing cross-over
fig = tg.gen_tangle(mat1, mat2, optimize_order=1000)

<img src="" width="650">

## Known Issues:
* layout does not scale well, i.e. small dendrograms look weird

## License:
This code is under GNU GPL V3

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tanglegram, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size tanglegram-0.1.0-py3-none-any.whl (18.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size tanglegram-0.1.0.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page