Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Use of distance metrics when clustering #111

Open
ltsypin opened this issue May 6, 2022 · 1 comment
Open

Bug: Use of distance metrics when clustering #111

ltsypin opened this issue May 6, 2022 · 1 comment

Comments

@ltsypin
Copy link

ltsypin commented May 6, 2022

I was digging a bit in the code to understand how the distance metric was implemented during clustering, and I think I found a bug:

In clustergrammer2/clustergrammer_fun/calc_clust.py, lines 80-93, it looks like neither the scipy nor fastclust libraries make use of the dist_type parameter. Right now, the code is:

def clust_and_group(net, inst_dm, axis, mat, dist_type='cosine', linkage_type='average',
                    clust_library='scipy', min_samples=1, min_cluster_size=2):

  # print(clust_library)

  import scipy.cluster.hierarchy as hier
  import pandas as pd

  if clust_library == 'scipy':
    Y = hier.linkage(inst_dm, method=linkage_type)

  elif clust_library == 'fastcluster':
    import fastcluster
    Y = fastcluster.linkage(inst_dm, method=linkage_type)

Shouldn't it be Y = hier.linkage(inst_dm, method=linkage_type, metric=dist_type) for the scipy case, for example?

Thanks!

@cornhundred
Copy link
Contributor

Hi @ltsypin, thanks for pointing this out. We are actually not using this dist_type variable in the her.linkage method since we are passing in a pre-calculated distance matrix, but we should not be passing in this variable. We can update this in the next release. Feel free to make a pull request or let me know if you have any other concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants