tanglegram


Nametanglegram JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/schlegelp/tanglegram
SummaryPlot simple tanglegrams from two dendrograms
upload_time2021-11-06 18:00:07
maintainer
docs_urlNone
authorPhilipp Schlegel
requires_python>=3
licenseGNU GPL V3
keywords python tanglegram dendrogram
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            tanglegram
==========
Uses scipy and matplotlib to plot simple tanglegrams. Inspired by the amazing [dendextend](https://github.com/talgalili/dendextend) by Tal Galili.

## Installation
First, get [PIP](https://pip.pypa.io/en/stable/installing/) 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](https://www.continuum.io/downloads)).


#### Dependencies
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)

## 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

```Python
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()
```

<img src="https://user-images.githubusercontent.com/7161148/105351954-2ae19f80-5be5-11eb-9dad-2dd0fe83d44d.png" width="650">

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

<img src="https://user-images.githubusercontent.com/7161148/105351772-e8b85e00-5be4-11eb-9343-db42f143ec68.png" width="650">


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

## License:
This code is under GNU GPL V3



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/schlegelp/tanglegram",
    "name": "tanglegram",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "python tanglegram dendrogram",
    "author": "Philipp Schlegel",
    "author_email": "pms70@cam.ac.uk",
    "download_url": "https://files.pythonhosted.org/packages/5d/5f/767c486efd8e4f933149327545d9d7ade6c3a918a133292d860d232f896a/tanglegram-0.2.0.tar.gz",
    "platform": "",
    "description": "tanglegram\n==========\nUses scipy and matplotlib to plot simple tanglegrams. Inspired by the amazing [dendextend](https://github.com/talgalili/dendextend) by Tal Galili.\n\n## Installation\nFirst, get [PIP](https://pip.pypa.io/en/stable/installing/) and then run in terminal:\n\n```\npip3 install tanglegram -U\n```\n\nTo install the bleeding-edge version from Github you can run:\n\n```\npip3 install git+git://github.com/schlegelp/tanglegram@master\n```\n\n**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)).\n\n\n#### Dependencies\nInstalling 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):\n\n- [Pandas](http://pandas.pydata.org/)\n- [SciPy](http://www.scipy.org)\n- [Numpy](http://www.scipy.org)\n- [Matplotlib](http://www.matplotlib.org)\n\n## How it works\n\n`tanglegram` exposes three functions:\n\n1. `tanglegram.plot` plots a tanglegram (optionally untangling)\n2. `tanglegram.entanglement` measures the entanglement between two linkages\n3. `tanglegram.untangle` rotates dendrograms to minimize entanglement\n\n```Python\nimport tanglegram as tg\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\n# Generate two distance matrices and just switch labels in one\nlabelsA= ['A', 'B', 'C', 'D']\nlabelsB= ['B', 'A', 'C', 'D']\ndata = [[ 0,  .1,  .4, .3],\n        [.1,   0,  .5, .6],\n        [ .4, .5,   0, .2],\n        [ .3, .6,  .2,  0]]\n\nmat1 = pd.DataFrame(data,\n                    columns=labelsA,\n                    index=labelsA)\n\nmat2 = pd.DataFrame(data,\n                    columns=labelsB,\n                    index=labelsB)\n\n# Plot tanglegram\nfig = tg.plot(mat1, mat2, sort=False)\nplt.show()\n```\n\n<img src=\"https://user-images.githubusercontent.com/7161148/105351954-2ae19f80-5be5-11eb-9dad-2dd0fe83d44d.png\" width=\"650\">\n\n```Python\n# Plot again but this time try minimizing cross-over\nfig = tg.plot(mat1, mat2, sort=True)\nplt.show()\n```\n\n<img src=\"https://user-images.githubusercontent.com/7161148/105351772-e8b85e00-5be4-11eb-9343-db42f143ec68.png\" width=\"650\">\n\n\n## Known Issues:\n* layout does not scale well, i.e. small dendrograms look weird\n\n## License:\nThis code is under GNU GPL V3\n\n\n",
    "bugtrack_url": null,
    "license": "GNU GPL V3",
    "summary": "Plot simple tanglegrams from two dendrograms",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/schlegelp/tanglegram"
    },
    "split_keywords": [
        "python",
        "tanglegram",
        "dendrogram"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "76cfbe88160f0dd4f452ca68045ac08f8c2c5135c4a03fb2870a8a776971e9ac",
                "md5": "c330cf0b4ee8fb3f1d801a62ce025c8d",
                "sha256": "b94fd9a23028e671dc5c1f9d98ef534c6301e5f52ac52584efeb197f0ea80c24"
            },
            "downloads": -1,
            "filename": "tanglegram-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c330cf0b4ee8fb3f1d801a62ce025c8d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 22702,
            "upload_time": "2021-11-06T18:00:06",
            "upload_time_iso_8601": "2021-11-06T18:00:06.112769Z",
            "url": "https://files.pythonhosted.org/packages/76/cf/be88160f0dd4f452ca68045ac08f8c2c5135c4a03fb2870a8a776971e9ac/tanglegram-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5d5f767c486efd8e4f933149327545d9d7ade6c3a918a133292d860d232f896a",
                "md5": "48b8582ec559cac78d8ef6085fe42e95",
                "sha256": "8e170cd0c4150208019dced4130ed4f9a7481174d3ed0b7f0cb48fcb14ff2e90"
            },
            "downloads": -1,
            "filename": "tanglegram-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "48b8582ec559cac78d8ef6085fe42e95",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 22892,
            "upload_time": "2021-11-06T18:00:07",
            "upload_time_iso_8601": "2021-11-06T18:00:07.039512Z",
            "url": "https://files.pythonhosted.org/packages/5d/5f/767c486efd8e4f933149327545d9d7ade6c3a918a133292d860d232f896a/tanglegram-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-11-06 18:00:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "schlegelp",
    "github_project": "tanglegram",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "tanglegram"
}
        
Elapsed time: 0.33556s