Repository navigation
Report a missing key as NA rather than failing - #312
Closed
BenjaminDEMAILLE wants to merge 1 commit into
Closed
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
Key.Seurat() vapplies over the keyed members with FUN.VALUE character(1),
so a member carrying no key returns length 0 and the whole call fails:
Error in vapply(X = keyed.objects, FUN = function(x) { :
values must be length 1, but FUN(X[[2]]) result is length 0
Since Key() is called by FetchData(), that takes down everything that
fetches or plots, and the message names neither the object nor the key.
Objects made before keys were enforced still carry keyless members, and
they load without complaint, so the object looks fine until something
asks for a key.
Return NA_character_ for a member with no key. NA is already what the rest
of the code expects for one: `[[<-` checks `is.na(object.keys[i])` when
resolving duplicate keys.
Fixes satijalab#41.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
|
Superseded by #318, which groups the correctness PRs into one so that a single review covers the subject. The commit is carried over unchanged; closing here to keep the queue down rather than because anything was wrong with it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #41, and the
DotPlotvariant @boluofen reported in the same thread.Cause
Key.Seurat()vapplies over the keyed members withFUN.VALUE = character(1):A member carrying no key at all returns
character(0), so the whole call fails.Key()is called byFetchData(), which is why this surfaces as a failure ofFeatureScatter,DotPlot, or anything else that fetches, with a message that names neither the object nor the key.Objects built before keys were enforced still carry keyless members, and they load without complaint, so nothing signals the problem until something asks for a key. That matches the reports here: an assay brought in from another package, in an object that otherwise behaves.
Fix
Return
NA_character_for a member with no key.NAis already what the rest of the code expects for one;[[<-checksis.na(object.keys[i])when resolving duplicate keys.Key()then returns a full vector,FetchData()works, and the keyless member is visible asNArather than fatal.Tests
tests/testthat/test_key_missing.R:Key()andKeys()on an object whose second assay has had its key removed,FetchData()on the same object, and keys unchanged when every member has one.Two assertions fail without the change. SeuratObject suite: 184 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