Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/aniclustermap/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import seaborn as sns
from matplotlib.colors import BoundaryNorm
from matplotlib.colors import LinearSegmentedColormap as LSC
from scipy.spatial.distance import squareform
from seaborn.matrix import ClusterGrid


Expand Down Expand Up @@ -59,7 +60,7 @@ def clustermap(
ani_matrix_df = pd.read_csv(ani_matrix_df, sep="\t", encoding="utf-8")

if linkage is None:
linkage = hc.linkage(ani_matrix_df, method="average")
linkage = hc.linkage(squareform(100 - ani_matrix_df), method="average")

if cmap_colors is None:
cmap_colors = ["lime", "yellow", "red"]
Expand Down
3 changes: 2 additions & 1 deletion src/aniclustermap/scripts/aniclustermap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pandas as pd
import scipy.cluster.hierarchy as hc
import typer
from scipy.spatial.distance import squareform
from typer import Option, Typer

from aniclustermap import __version__, const
Expand Down Expand Up @@ -172,7 +173,7 @@ def cli(

# Hierarchical clustering ANI matrix
logger.info(f"Clustering {mode.value} ANI matrix by scipy UPGMA method")
linkage = hc.linkage(ani_matrix_df, method="average")
linkage = hc.linkage(squareform(100 - ani_matrix_df), method="average")
dendrogram_newick_file = outdir / "ANIclustermap_dendrogram.nwk"
to_newick_tree(ani_matrix_df, linkage, dendrogram_newick_file)
logger.info("Write newick format cluster dendrogram")
Expand Down