Skip to content

Say which cell names a rename would repeat - #314

Closed
BenjaminDEMAILLE wants to merge 1 commit into
satijalab:mainfrom
BenjaminDEMAILLE:fix/rename-duplicate-names
Closed

BenjaminDEMAILLE wants to merge 1 commit into
satijalab:mainfrom
BenjaminDEMAILLE:fix/rename-duplicate-names

Conversation

@BenjaminDEMAILLE

Copy link
Copy Markdown

Fixes #256.

> RenameCells(object, new.names = rep("dup", ncol(object)))
Error in `.rowNamesDF<-`(x, value = value): duplicate 'row.names' are not allowed

The mapping is applied to the meta data, the identities and every assay in turn, so the failure comes from whichever frame is renamed first. The message names neither the cells nor the renaming, and the traceback lands in .rowNamesDF<-, which is why that issue reads as a mystery.

Checking the mapping before applying it:

Renaming would give the same name to more than one cell. 1 name is repeated: 'dup'

Cell names have to be unique, so this was never going to succeed; it just says so now, and names what to fix.

The other half of that issue

The reporter also hits it through RunAzimuth(), with a different message (missing values in 'row.names' are not allowed) and a different cause: an SCT model naming cells the assay no longer has. That one is satijalab/seurat#10481, since the code is in Seurat. It also explains why passing make.unique(Cells(object)) did not help them: uniqueness was not the problem in that path.

Tests

tests/testthat/test_rename_duplicates.R: every cell renamed to one name, a single collision named exactly, and unique names plus add.cell.id still renaming.

Three assertions fail without the change. SeuratObject suite: 182 passing, 0 failures. Seurat's own suite against this build: 1184 passing, the only 2 failures being ones that predate it and are unrelated (Read10X_Image, satijalab/seurat#10454).

🤖 Generated with Claude Code

Renaming to names that are not unique leaves the frames being renamed with
duplicate row names:

  > RenameCells(object, new.names = rep("dup", ncol(object)))
  Error in `.rowNamesDF<-`(x, value = value):
    duplicate 'row.names' are not allowed

The message names neither the cells nor the renaming, and it comes from far
enough inside that the traceback is no help either.

Check the mapping before applying it:

  Renaming would give the same name to more than one cell. 1 name is
  repeated: 'dup'

Fixes satijalab#256.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BenjaminDEMAILLE

Copy link
Copy Markdown
Author

Superseded by #319, which groups the message-only PRs into one, since they share a rationale and none of them changes behaviour. The commit is carried over unchanged; closing here to keep the queue down rather than because anything was wrong with it.

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 this pull request may close these issues.

Bug: duplicate 'row.names' are not allowed when running RunAzimuth() or RenameCells()

1 participant