Skip to main content
tanglegram
==========
Uses scipy and matplotlib to plot simple tanglegrams. Inspired by the amazing [dendextend](https://github.com/talgalili/dendextend) by Tal Galili.

## Installation
I recommend using [Python Packaging Index (PIP)](https://pypi.python.org/pypi) to install the package.
First, get [PIP](https://pip.pypa.io/en/stable/installing/) and then run in terminal:

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

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](https://www.continuum.io/downloads)).

If your default distribution is Python 2, you have to explicitly tell [PIP](https://pip.pypa.io/en/stable/installing/) to install for Python 3:

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

#### External libraries used:
Installing via [PIP](https://pip.pypa.io/en/stable/installing/) 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](https://raw.githubusercontent.com/schlegelp/PyMaid/master/setup.py) for version info):

- [Pandas](http://pandas.pydata.org/)
- [SciPy](http://www.scipy.org)
- [Numpy](http://www.scipy.org)
- [Matplotlib](http://www.matplotlib.org)
- [Tqdm](https://pypi.python.org/pypi/tqdm)

## Quickstart:

```python
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,
columns=labelsA,
index=labelsA)

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

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

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

<img src="https://user-images.githubusercontent.com/7161148/42809649-fde86b00-89ad-11e8-9ecd-051f40731bc1.png" width="650">

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

## License:
This code is under GNU GPL V3


Download files

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

Source Distribution

tanglegram-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tanglegram-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file tanglegram-0.1.0.tar.gz.

File metadata

  • Download URL: tanglegram-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.0 CPython/3.5.3

File hashes

Hashes for tanglegram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be9174aa98047b7571de26e358a5ac50f0e71d16acd777cf48b8f9401363b626
MD5 847701586774745c9e2f4e50343b7db2
BLAKE2b-256 5e03e87a01f82f850f61cb78dfa85affdc4c97586c7cfe4c72671f9ac8e0fe35

See more details on using hashes here.

File details

Details for the file tanglegram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tanglegram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.0 CPython/3.5.3

File hashes

Hashes for tanglegram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 191c04556fa1241861c69464cb4291d9b3b42795272835af4ec30dbe5de36ef6
MD5 4ddb34216d0f088a8b965904a1549a67
BLAKE2b-256 7aa3fee4f8a510e654d0fc24c3a73488c937e3dd91cea2b7c65dd4cb8453880a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

2 files

0.0.2

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page