{"id":18932034,"url":"https://github.com/koonimaru/radialtree","last_synced_at":"2025-04-15T16:33:34.921Z","repository":{"id":36988460,"uuid":"505240420","full_name":"koonimaru/radialtree","owner":"koonimaru","description":"A python module to draw a circular dendrogram","archived":false,"fork":false,"pushed_at":"2024-11-10T01:08:23.000Z","size":1414,"stargazers_count":18,"open_issues_count":5,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T23:43:28.341Z","etag":null,"topics":["circular","clustering","dendrogram","hierarchical-clustering","python3","radial"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koonimaru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-19T23:25:29.000Z","updated_at":"2024-12-17T05:29:44.000Z","dependencies_parsed_at":"2024-11-08T11:48:42.131Z","dependency_job_id":"dfadd969-ccb6-4362-9869-f8b6af6a0a00","html_url":"https://github.com/koonimaru/radialtree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koonimaru%2Fradialtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koonimaru%2Fradialtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koonimaru%2Fradialtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koonimaru%2Fradialtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koonimaru","download_url":"https://codeload.github.com/koonimaru/radialtree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249108488,"owners_count":21214002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circular","clustering","dendrogram","hierarchical-clustering","python3","radial"],"created_at":"2024-11-08T11:47:55.945Z","updated_at":"2025-04-15T16:33:34.629Z","avatar_url":"https://github.com/koonimaru.png","language":"Python","readme":"# radialtree\n\n## What is radialtree\n\nradialtree is a python module to draw a circular dendrogram using a output from scipy dendrogram.\n![example](example.png \"example\")\n\n## Install\n\n```bash\ngit clone https://github.com/koonimaru/radialtree.git\ncd radialtree\npip install .\n```\nPlease note that radialtree is now integreated into [omniplot](https://github.com/koonimaru/omniplot) module with an improvement. \n\n\n## Example usage\n\n```python\nimport scipy.cluster.hierarchy as sch\nimport numpy as np\nimport radialtree as rt\n\nnp.random.seed(1)\nlabels=[chr(i)*10 for i in range(97, 97+numleaf)]\nx = np.random.rand(numleaf)\nD = np.zeros([numleaf,numleaf])\nfor i in range(numleaf):\n    for j in range(numleaf):\n        D[i,j] = abs(x[i] - x[j])\n\n# Compute and plot the dendrogram.\nY = sch.linkage(D, method='single')\nZ2 = sch.dendrogram(Y,labels=labels,no_plot=True)\n\n# plot a circular dendrogram\nrt.plot(Z2)\n```\n\n## Example usage 2 (adding color labels to the tree.)\n\n```python\nimport scipy.cluster.hierarchy as sch\nimport numpy as np\nimport radialtree as rt\nnp.random.seed(1)\nnumleaf=200\n_alphabets=[chr(i) for i in range(97, 97+24)]\nlabels=sorted([\"\".join(list(np.random.choice(_alphabets, 10))) for i in range(numleaf)])\nx = np.random.rand(numleaf)\nD = np.zeros([numleaf,numleaf])\nfor i in range(numleaf):\n    for j in range(numleaf):\n        D[i,j] = abs(x[i] - x[j])\n    \n#optionally leaves can be labeled by colors\ntype_num=12 # Assuming there are 12 known types in the sample set\n_cmp=cm.get_cmap(\"bwr\", type_num) # Setting 12 different colors \n_cmp2=cm.get_cmap(\"hot\", type_num) # Setting another 12 different colors\ncolors_dict={\"example_color\":_cmp(np.random.rand(numleaf)),  # RGB color list. the order of colors must be same as the original sample order.\n             \"example_color2\":_cmp2(np.random.rand(numleaf))} # Another RGB color list.\n\n#optionally, specify the legend of the color labels.     \ncolors_legends={\"example_color\":{\"colors\":_cmp(np.linspace(0, 1, type_num)), \n                                 \"labels\": [\"ex1_\"+str(i+1) for i in range(type_num)]},\n                \"example_color2\":{\"colors\":_cmp2(np.linspace(0, 1, type_num)),\n                                  \"labels\": [\"ex2_\"+str(i+1) for i in range(type_num)]}}\n    \n# Compute and plot the dendrogram.\n\nY = sch.linkage(D, method='single')\nZ2 = sch.dendrogram(Y,labels=labels,no_plot=True)\nrt.plot(Z2, colorlabels=colors_dict,colorlabels_legend=colors_legends)\n```\n\n![example2](example2.png \"example2\")\n\n## Example usage 3 (adding color labels to the tree automatically (rather simpler than Example 2).)\n\n```python\nimport scipy.cluster.hierarchy as sch\nimport numpy as np\nimport radialtree as rt\nnp.random.seed(1)\n\nnumleaf=200\n_alphabets=[chr(i) for i in range(97, 97+24)]\nlabels=sorted([\"\".join(list(np.random.choice(_alphabets, 10))) for i in range(numleaf)])\nx = np.random.rand(numleaf)\nD = np.zeros([numleaf,numleaf])\nfor i in range(numleaf):\n    for j in range(numleaf):\n        D[i,j] = abs(x[i] - x[j])\n        \nY = sch.linkage(D, method='single')\nZ2 = sch.dendrogram(Y,labels=labels,no_plot=True)\ntype_num=6\ntype_list=[\"ex\"+str(i) for i in range(type_num)]\nsample_classes={\"example_color\": [np.random.choice(type_list) for i in range(numleaf)]}\nrt.plot(Z2, sample_classes=sample_classes)\n```\n\n## Example usage 4 (Emebedding the radial tree in a figure)\n\n```python\nimport scipy.cluster.hierarchy as sch\nimport numpy as np\nimport radialtree as rt\nfrom seaborn import load_dataset\nimport matplotlib.pyplot as plt\n\n#get a simple dataset\niris = load_dataset(\"iris\")\nspecies = iris.pop(\"species\")\n\nfig, axes = plt.subplots(2, 1, figsize=(10, 10))\n# Compute and plot the dendrogram.\nY = sch.linkage(np.asarray(iris), method=\"average\")\nZ2 = sch.dendrogram(\n    Y,\n    # no_plot=True,\n    ax=axes[0],\n    color_threshold=1.0,\n)\n\naxes[1].set_aspect(1)\n# plot a circular dendrogram\nrt.radialTreee(Z2, ax=axes[1], sample_classes={\"species\": species})\n```\n\n![example4](example4.png \"example4\")\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoonimaru%2Fradialtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoonimaru%2Fradialtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoonimaru%2Fradialtree/lists"}