Python translation of the hybrid dynamicTreeCut method created by Peter Langfelder and Bin Zhang.
- dynamicTreeCut was originally published by in Bioinformatics:
Langfelder P, Zhang B, Horvath S (2007) Defining clusters from a hierarchical cluster tree: the Dynamic Tree Cut package for R. Bioinformatics 2008 24(5):719-720
dynamicTreeCut R code is distributed under the GPL-3 License and original sources should be cited.
dynamicTreeCut contains methods for detection of clusters in hierarchical clustering dendrograms. NOTE: though the clusters match the R output, the cluster names are shuffled
Installing
To install, it’s best to create an environment after installing and downloading the Anaconda Python Distribution
conda env create –file environment.yml
PyPI install, presuming you have all its requirements (numpy and scipy) installed:
pip install dynamicTreeCut
Importation
>>> from dynamicTreeCut import cutreeHybrid >>> from scipy.spatial.distance import pdist >>> import numpy as np >>> from scipy.cluster.hierarchy import linkage >>> d = np.transpose(np.arange(1,10001).reshape(100,100)) >>> distances = pdist(d, "euclidean") >>> link = linkage(distances, "average") >>> clusters = cutreeHybrid(link, distances) ..cutHeight not given, setting it to 495.1 ===> 99% of the (truncated) height range in dendro. ..done. >>> clusters["labels"] [2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
Compared to R:
> library(dynamicTreeCut) > d = matrix(1:10000, 100) > distances <- dist(d, method="euclidean") > dendro <- hclust(distances, method="average") > clusters <- cutreeDynamic(dendro, distM=as.matrix(distances)) ..cutHeight not given, setting it to 495 ===> 99% of the (truncated) height range in dendro. ..done. > clusters [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 [38] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 1 1 [75] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Installation
If you dont already have numpy and scipy installed, it is best to download Anaconda, a python distribution that has them included.
Dependencies can be installed by:
pip install -r requirements.txt
License
dynamicTreeCut is available under the GPL-3 License
Metadata
Release files for dynamicTreeCut 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dynamicTreeCut-0.1.1.tar.gz | 13.2 kB | Without provenance | Details for dynamicTreeCut-0.1.1.tar.gz |
Release files / dynamicTreeCut-0.1.1.tar.gz
| Download URL | dynamicTreeCut-0.1.1.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ad78e78867a17c9c5fb448e8481adf99db403d0a879a36d7d288fd4953e602b
|
|
BLAKE2b-256 checksum How to use checksums |
e2f907241f0d25fe0e00a2e545142241a9cf81482b4054789e0cd590b0016623
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
|
Security for dynamicTreeCut 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.