why renaming Idents in Seurat object doesn't work?
2
0
Entering edit mode
7 months ago
Assa Yeroslaviz ★ 1.9k

I'm trying to rename my clusters in a Seurat object.

my old cluster IDs are numers

Idents(seuObj) <- 'RNA_snn_res.0.1'
levels(seuObj)
 [1] "0"  "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"

I would like to assign the clusters names from a named vector

Following the vignette from the web site I tried to assign the vector to the numbers -

cluster_ids <- c("DC2_genes",  "mregDC_genes", "mregDC_genes", "Bcell_genes",...)
names(cluster_ids) <- levels(seuObj)
seuObj <- RenameIdents(seuObj, cluster_ids)

But this just assigns numbers to the new Idents

head(Idents(seuObj))
C7_AAACCCAAGGGTGGGA-1 C7_AAACCCAAGTAGCATA-1 C7_AAACCCACAAGAGGTC-1 C7_AAACCCACAGTCTCTC-1 C7_AAACCCACATGAATCC-1 
    0.346464052287582     0.177389184397163     0.132815134099617     0.300105882352941     0.497196167423096 
C7_AAACCCAGTAGAGGAA-1 
    0.335241176470588

What am I doing wrong here?

Seurat RenameIdents R • 1.2k views
ADD COMMENT
0
Entering edit mode
7 months ago
Assa Yeroslaviz ★ 1.9k

I manage to find a workwround, but I don't understand what I did wrong here.

my solution was to extract the cluster column as vector and assign the new names to it. Then I created a new column in my seurat obj.

vec <- seuObj$RNA_snn_res.0.1
levels(vec) <- cluster_ids
seuObj[["UCell_clusters"]] <- vec
Idents(seuObj) <- 'UCell_clusters'

But is this the correct way to go?

ADD COMMENT
0
Entering edit mode
7 months ago
Bioinfotec ▴ 10

I think when you give indent to seuObj :

Idents(seuObj) <- 'RNA_snn_res.0.1'

You may wrongly assign other value to it such as "pANN_..." because the output Idents(seuObj) is really similar to the value of seuObj$pANN_...

ADD COMMENT
0
Entering edit mode

Don't understand this comment. I don't have any columns with this name.

ADD REPLY

Login before adding your answer.

Traffic: 1918 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6