Skip to main content

Ash dendrogram utilities

Project description

ash-dendro package

This package contains two dendrogram utilities

  • utility to split dendrogram by selecting a nodes
  • utility to parse R hclust format to linkage matrix used by Scipy

Example Usage

import pandas as pd
from scipy.cluster.hierarchy import dendrogram
import matplotlib.pyplot as plt
import numpy as np

from ash_dendro.utils import parse_order_df, parse_heights_df, parse_r_hclust, split_dendrogram

# Input data are expected to be in pandas dataframes
# Iris sample data can be used for this purpose

BASE_PATH = "<INSERT YOUR LOCAL PATH>"
heights = pd.read_csv(f"{BASE_PATH}/iris/heights.csv")
order = pd.read_csv(f"{BASE_PATH}/iris/order.csv")
merge = pd.read_csv(f"{BASE_PATH}/iris/merge.csv")

parsed_order = parse_order_df(order)
parsed_heights = parse_heights_df(heights)

# convert from R hclust format to linkage matrix used in Scipy
parsed_merge = parse_r_hclust(
    merge,
    parsed_heights,
    parsed_order
)

plt.figure()
dendrogram(parsed_merge)
plt.show()

nodes_to_split = [3, 8]
clusters_ids_to_assign = [1, 2]

r = split_dendrogram(
    np.array(parsed_merge),
    nodes_to_split,
    clusters_ids_to_assign,
)
print(r)

Project details


Download files

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

Source Distribution

ash_dendro-0.0.7.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

ash_dendro-0.0.7-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file ash_dendro-0.0.7.tar.gz.

File metadata

  • Download URL: ash_dendro-0.0.7.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for ash_dendro-0.0.7.tar.gz
Algorithm Hash digest
SHA256 6c9fe69d941a1e618132eb07c5bb616ecb39a2ad96cd4d8e00b988ad6885f6c5
MD5 78180b8aa7a9b5a151d7ef97d19e6d15
BLAKE2b-256 45152ac24880582e3d2984ad9864ed402a255f3c143e118708b8d66b50c8a0a4

See more details on using hashes here.

File details

Details for the file ash_dendro-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: ash_dendro-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for ash_dendro-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e71180f85d615eb084390f844ca9ac37e1fed9c085896b4450359b9368a5f9a2
MD5 b13209de4e8c50100ba3123d24fd196f
BLAKE2b-256 4e8d91cabcb646c6f73806d50d9477ee7a86bb2a15b1deec8ffe6115dd9f0e19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page