Rename Idents in Seurat Object
0
0
Entering edit mode
2.1 years ago
Thorerges ▴ 10

I have a seurat object that looks as such:

> object
An object of class Seurat  15780 features across 6272 samples within 1 assay  Active assay: RNA (15780 features)  2 dimensional
> reductions calculated: pca, umap


Identities based on the clustering I've done look as such:

> head(uc@active.ident)
N7.EpiA.AGACTCGAAAGGGC N7.EpiA.GACGATTGGAAACA N7.EpiA.GACGGCACGACGTT N7.EpiA.GTACTTTGCTAAGC N7.EpiA.TAGGCAACTCCTTA
0                      0                      0                      0                      0
N7.EpiA.TATCACTGCTATTC
0
Levels: 0 1 2 3 4


How do I assign barcodes based on pre-determined clusters in seurat V3? I already know which barcodes belong to which cluster.

Any help is appreciated!

RNA-Seq • 8.2k views
2
Entering edit mode

You mean, you want to assign some categorical value to each cell that you already know belongs to a particular class? You can simply edit the meta.data field. To access meta.data, do this: object@meta.data. This will give you a table. The row of the table are all cells, you can get their sequence from, row.names(object@meta.data). Now, if your category is A, B and C, with X, Y and Z cells (let suppose in sequence) then make a character vector: New_idents <- rep(c("A","B","C), times =c("X,Y,Z)). Then assign this to meta.data as : object@meta.data\$"Newcluster" <- as.factor(New_idents).

If they are not in sequence, you would have to do little more work, but in principle you can modulate meta.data. To then plot this, just use group.by="Newcluster" in DimPlot().