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

Warn or message when recycling scalar as Idents #232

Open
rharao opened this issue Dec 20, 2024 · 0 comments
Open

Warn or message when recycling scalar as Idents #232

rharao opened this issue Dec 20, 2024 · 0 comments

Comments

@rharao
Copy link

rharao commented Dec 20, 2024

I've occasionally seen users get confused when they do something like Idents(foo) <- "bar", expecting the Idents of foo to take the value of a column bar that doesn't exist in the metadata. I believe it would help users if this were called out.

Here is my idea:

obj <- pbmc_small
levels(obj)
## [1] "0" "1" "2"
Idents(obj) <- "group"
## Warning: 'group' not found in this object's metadata. All Idents are now the string 'group'.
## Set the Idents to `I('group')` to bypass this warning.
levels(obj)
## [1] "group"
colnames(obj[[]])
## [1] "orig.ident"      "nCount_RNA"      "nFeature_RNA"    "RNA_snn_res.0.8" "letter.idents"   "groups"         
## [7] "RNA_snn_res.1"
Idents(obj) <- "groups"
levels(obj)
## [1] "g2" "g1"
Idents(obj) <- I("group")
levels(obj)
## [1] "group"

Would this be welcome as a PR?

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

1 participant