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

"Internal error, label numbers "+str(len(Z2['ivl'])) +" and "+str(len(label_coords))+" must be equal!" #15

Open
elipu opened this issue Mar 15, 2023 · 3 comments

Comments

@elipu
Copy link

elipu commented Mar 15, 2023

Hello,

First of all, thank you for your work! It has saved me a lot of time.

I have the error in the title at line 149 in radialtree.py and I cannot figure out what might cause it.

The specific difference between labels in my case is "Internal error, label numbers 211 and 255 must be equal!"

Thank you in advance!

@koonimaru
Copy link
Owner

Hello, thank you for your contact.
Can you give me your data or code to reproduce the error. I was expecting that some one might get this error. This error comes from a mismatch between leaves' label number and those located at zero position. Probably, having very similar samples may cause this mismatch.

For the moment, I have changed the code to silence the error (still printing a warning).

@koonimaru
Copy link
Owner

No, it did not work. Please wait...

@koonimaru
Copy link
Owner

Hi there,

I may find a solution. It is not a beautiful solution, but providing radial tree with xticks may solve your issue.

import scipy.cluster.hierarchy as sch
import numpy as np
import radialtree as rt
np.random.seed(1)
numleaf=20
_alphabets=[chr(i) for i in range(97, 97+24)]
labels=sorted(["".join(list(np.random.choice(_alphabets, 10))) for i in range(numleaf)])
x = np.random.rand(numleaf)
D = np.zeros([numleaf,numleaf])
D[0,0]=1
D[5,10]=1

Y = sch.linkage(D, method='ward')

_fig, _ax=plt.subplots()
Z2 = sch.dendrogram(Y,labels=labels, ax=_ax)   #this is important point. you need to remove "no_plot" option
xticks=set(_ax.get_xticks())
plt.close(_fig)

type_num=6
type_list=["ex"+str(i) for i in range(type_num)]
sample_classes={"example_color": [np.random.choice(type_list) for i in range(numleaf)]}
rt.plot(Z2, sample_classes=sample_classes, xticks=xticks)

You could also try omniplot.
It has the same functionality with more user friendly functions, if you are familiar with pandas dataframe.

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