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

var_names_make_unique fails on some indices #344

Closed
bkmartinjr opened this issue Mar 20, 2020 · 1 comment · Fixed by #345
Closed

var_names_make_unique fails on some indices #344

bkmartinjr opened this issue Mar 20, 2020 · 1 comment · Fixed by #345

Comments

@bkmartinjr
Copy link
Contributor

bkmartinjr commented Mar 20, 2020

If I load a loom file with non-unique var names, and then call var_names_make_unique(), it appears to do nothing -- the var names are still non-unique.

if it is called again, it seems to work.

update: the "run twice" solution will not resolve the failure for all datasets. See below for root cause discussion.

Example:

>>> adata = sc.read_loom('matrix.loom')
Variable names are not unique. To make them unique, call `.var_names_make_unique`.
>>> adata.var.index.is_unique
False
>>> adata.var_names_make_unique()
>>> adata.var.index.is_unique
False
>>> adata.var_names_make_unique()
>>> adata.var.index.is_unique
True
@mweiden
Copy link
Contributor

mweiden commented Mar 22, 2020

Hi 👋,

We've chased this down a bit further. The code is working as intended, appending a join + str(counter[v]) to each duplicate entry. The issue is when you have names that will collide with the newly renamed vars or obs. Take the following example:

['SNORD113', 'SNORD113', 'SNORD113-1`, `SNORD113-1-1', `SNORD113-1-1-1`, ...]

running .var_names_make_unique once:

['SNORD113-1', 'SNORD113-2', 'SNORD113-1`, `SNORD113-1-1', `SNORD113-1-1-1`, ...]

This is not unique. Run it again:

['SNORD113-1-1', 'SNORD113-2', 'SNORD113-1-1`, `SNORD113-1-1', `SNORD113-1-1-1`, ...]

Still not unique.

Given the right sequence, this could be infinite.

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

Successfully merging a pull request may close this issue.

2 participants